Skip to content

rfpga/react-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Frontend - Pet Owners Social Network

A modern React frontend application built with Vite for a pet owners social network, featuring user authentication, post management, and pet profiles.

πŸš€ Features

  • 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

πŸ›  Tech Stack

  • 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

πŸ“‹ Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn package manager
  • Running FastAPI backend server

πŸ”§ Installation

  1. Clone the repository

    git clone <repository-url>
    cd react-aws
  2. Install dependencies

    npm install
  3. Environment Configuration

    # Copy the environment template
    cp .env-sample .env
    
    # Edit .env with your configuration
    VITE_API_URL='http://localhost:8000'
  4. Start the development server

    npm run dev
  5. Access the application

    • Open your browser and navigate to http://localhost:3000

πŸ“ Project Structure

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

🎯 Key Components

Authentication System

  • AuthContext: Centralized authentication state management
  • ProtectedRoute: Guards routes requiring authentication
  • LoginPage/RegisterPage: User authentication interfaces

Posts Management

  • PostsList: Main feed with infinite scroll pagination
  • PostDetails: Detailed post view with comments functionality
  • New Post Creation: Inline post creation with image support

Pet Management

  • DogsAccount: CRUD operations for user's pets
  • UserDogs: View pets belonging to other users

Navigation

  • Navbar: Responsive navigation with authentication-aware links

πŸ”‘ Environment Variables

Variable Description Default
VITE_API_URL Backend API base URL http://localhost:8000

πŸ“± Features Overview

User Authentication

  • Secure login/logout with JWT tokens
  • User registration with profile image upload
  • Persistent authentication state
  • Automatic token validation

Social Features

  • 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

Pet Management

  • Register multiple pets per user
  • Add pet details (name, breed, age)
  • View pets belonging to other users
  • Delete owned pets

🎨 Styling Approach

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

πŸ”„ API Integration

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

HTTP Client Configuration

// Axios interceptors for authentication
headers: { 'Authorization': `Bearer ${token}` }

🚦 Available Scripts

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

πŸ”’ Security Features

  • 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

πŸ“ˆ Performance Optimizations

  • 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

πŸ› Common Issues & Solutions

Development Server Won't Start

# Clear node modules and reinstall
rm -rf node_modules package-lock.json
npm install

API Connection Issues

  • Verify backend server is running on correct port
  • Check CORS configuration in FastAPI backend
  • Ensure .env file has correct API URL

Authentication Problems

  • Clear localStorage: localStorage.clear()
  • Check JWT token expiration
  • Verify backend authentication endpoints

πŸ”„ Development Workflow

  1. Feature Development

    # Create feature branch
    git checkout -b feature/new-feature
    
    # Make changes and test
    npm run dev
    
    # Run linting
    npm run lint
  2. Building for Production

    npm run build
    npm run preview  # Test production build

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors