A modern React frontend application built with Vite for a pet owners social network, featuring user authentication, post management, and pet profiles.
- User Authentication: JWT-based login and registration system
- Social Posts: Create, view, and interact with posts from other pet owners
- Pet Management: Register and manage multiple pets per user
- Comments System: Comment on posts and view threaded discussions
- Profile Images: Upload and display user profile pictures
- Responsive Design: Mobile-friendly interface with modern CSS
- Real-time Updates: Dynamic content loading with pagination
- Protected Routes: Secure navigation with authentication guards
- React 18 - Modern React with functional components and hooks
- Vite - Fast build tool and development server
- React Router DOM - Client-side routing and navigation
- Axios - HTTP client for API communication
- CSS3 - Custom styling with responsive design
- ESLint - Code linting and quality assurance
- Node.js (v16 or higher)
- npm or yarn package manager
- Running FastAPI backend server
-
Clone the repository
git clone <repository-url> cd react-aws
-
Install dependencies
npm install
-
Environment Configuration
# Copy the environment template cp .env-sample .env # Edit .env with your configuration VITE_API_URL='http://localhost:8000'
-
Start the development server
npm run dev
-
Access the application
- Open your browser and navigate to
http://localhost:3000
- Open your browser and navigate to
src/
βββ auth/
β βββ AuthContext.jsx # Authentication state management
β βββ LoginPage.jsx # User login interface
β βββ ProtectedRoute.jsx # Route protection component
β βββ NotFound.jsx # 404 error page
βββ register/
β βββ RegisterPage.jsx # User registration interface
βββ posts/
β βββ PostsList.jsx # Main feed with infinite scroll
β βββ PostDetails.jsx # Individual post view with comments
βββ dogs/
β βββ DogsAccount.jsx # User's pet management
β βββ UserDogs.jsx # View other users' pets
βββ nav/
β βββ Navbar.jsx # Navigation component
βββ App.jsx # Main application component
βββ App.css # Global styles
βββ index.css # Base styles
βββ main.jsx # Application entry point
- AuthContext: Centralized authentication state management
- ProtectedRoute: Guards routes requiring authentication
- LoginPage/RegisterPage: User authentication interfaces
- PostsList: Main feed with infinite scroll pagination
- PostDetails: Detailed post view with comments functionality
- New Post Creation: Inline post creation with image support
- DogsAccount: CRUD operations for user's pets
- UserDogs: View pets belonging to other users
- Navbar: Responsive navigation with authentication-aware links
| Variable | Description | Default |
|---|---|---|
VITE_API_URL |
Backend API base URL | http://localhost:8000 |
- Secure login/logout with JWT tokens
- User registration with profile image upload
- Persistent authentication state
- Automatic token validation
- Create and share posts
- View posts from other pet owners
- Comment on posts with threaded discussions
- View user profiles and their pets
- Infinite scroll pagination
- Register multiple pets per user
- Add pet details (name, breed, age)
- View pets belonging to other users
- Delete owned pets
The application uses custom CSS with:
- Responsive Design: Mobile-first approach with breakpoints
- Component-based Styles: Scoped styling for each component
- Modern UI Elements: Cards, hover effects, and smooth transitions
- Consistent Color Scheme: Professional blue and grey palette
- Accessibility: Proper contrast ratios and semantic markup
The frontend communicates with the FastAPI backend through:
- Authentication Endpoints: Login, registration, token management
- Posts API: CRUD operations for posts and comments
- Dogs API: Pet management functionality
- User Management: Profile and image handling
// Axios interceptors for authentication
headers: { 'Authorization': `Bearer ${token}` }| Script | Description |
|---|---|
npm run dev |
Start development server on port 3000 |
npm run build |
Build production-ready application |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint for code quality checks |
- JWT Token Management: Secure storage in localStorage
- Route Protection: Authentication guards for sensitive routes
- Input Validation: Client-side form validation
- XSS Prevention: Proper data sanitization
- CORS Handling: Configured for cross-origin requests
- Code Splitting: React Router-based lazy loading
- Image Optimization: Base64 encoding for profile pictures
- Infinite Scroll: Efficient pagination for large datasets
- Memoization: React hooks for performance optimization
- Bundle Optimization: Vite's tree-shaking and minification
# Clear node modules and reinstall
rm -rf node_modules package-lock.json
npm install- Verify backend server is running on correct port
- Check CORS configuration in FastAPI backend
- Ensure
.envfile has correct API URL
- Clear localStorage:
localStorage.clear() - Check JWT token expiration
- Verify backend authentication endpoints
-
Feature Development
# Create feature branch git checkout -b feature/new-feature # Make changes and test npm run dev # Run linting npm run lint
-
Building for Production
npm run build npm run preview # Test production build
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the Issues section
- Review the FastAPI backend documentation
- Ensure both frontend and backend are running on correct ports
Note: This frontend application requires the FastAPI backend to be running for full functionality. Make sure to start the backend server before running the React development server.# react-aws