Skip to content

JeetInTech/E-Commerce-Website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-Commerce Website πŸ›’

A modern full-stack e-commerce web application template for electronics stores - featuring product catalog, shopping cart, user authentication, order management, and repair services.

React FastAPI Supabase Vite

⚠️ Note: This is a demonstration/portfolio project and is not intended for production use at this time.


οΏ½ Complete Full-Stack Project

This is a production-ready, complete full-stack e-commerce application with:

Layer Technology Status
🎨 Frontend React 19 + Vite βœ… Complete
βš™οΈ Backend FastAPI (Python) βœ… Complete
πŸ—„οΈ Database PostgreSQL (Supabase) βœ… Complete
πŸ” Authentication Supabase Auth βœ… Complete
πŸ“‘ API RESTful API βœ… Complete

⚑ Quick Start - It Just Works!

Once you configure your Supabase credentials and run both frontend & backend:

  1. Database tables are auto-created in your Supabase project on first run
  2. Frontend connects to Backend via the configured API URL
  3. Authentication flows work out of the box with Supabase
  4. Your e-commerce site is live on localhost!

πŸ’‘ No manual database setup required - just add your Supabase credentials and everything connects automatically.


οΏ½πŸ“‹ Table of Contents


🎯 Overview

This is a full-stack e-commerce platform designed for retail electronics businesses. The application bridges online convenience with offline trust, supporting features like:

  • Pay Online: Complete purchases with online payment
  • Reserve & Pickup: Reserve items online and pay at the store
  • Pre-booking: Advance booking for out-of-stock items
  • Repair Services: Submit repair inquiries for fans, motors, and appliances

This system is designed to support the unique requirements of an Indian retail business where customers often prefer to see products in person and negotiate prices.


✨ Features

Customer Features

  • πŸ›’ Product Browsing - Browse products by category with search and filters
  • πŸ“¦ Shopping Cart - Add items, manage quantities, and checkout
  • πŸ” Authentication - Sign up/login with email or Google (via Supabase)
  • πŸ“± Responsive Design - Mobile-first design with dedicated mobile navigation
  • πŸ› οΈ Repair Inquiries - Submit service requests for electrical repairs
  • πŸ“… Pre-booking - Book items in advance for store visits
  • πŸ‘€ User Account - View order history and manage profile

Admin/Staff Features

  • πŸ“Š Inventory Management - Track stock levels and reservations
  • πŸ“‹ Order Management - Process and update order statuses
  • 🏷️ Category Management - Create and organize product categories
  • πŸ‘₯ Role-based Access - Customer, Staff, and Admin roles

Product Categories

  • πŸŒ€ Ceiling & Table Fans
  • 🍳 Kitchen Appliances
  • πŸ”§ Spare Parts & Motors
  • ⚑ Electrical Accessories

πŸ› οΈ Tech Stack

Frontend

Technology Purpose
React 19 UI Framework
React Router 7 Client-side routing
Vite 7 Build tool & dev server
Supabase JS Authentication & real-time
Lucide React Icon library
CSS Modules Component styling

Backend

Technology Purpose
FastAPI REST API framework
SQLAlchemy 2.0 Async ORM
PostgreSQL Database (via Supabase)
Alembic Database migrations
Pydantic v2 Data validation
Supabase Auth & database hosting

Infrastructure

Technology Purpose
Supabase Backend-as-a-Service
PostgreSQL Relational database
Uvicorn ASGI server

πŸ“ Project Structure

ecommerce-website/
β”œβ”€β”€ πŸ“‚ backend/                 # FastAPI Backend
β”‚   β”œβ”€β”€ πŸ“‚ alembic/            # Database migrations
β”‚   β”‚   └── versions/          # Migration files
β”‚   β”œβ”€β”€ πŸ“‚ app/
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ deps.py        # Dependency injection
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware.py  # Custom middleware
β”‚   β”‚   β”‚   └── πŸ“‚ routes/     # API endpoints
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.py    # Authentication
β”‚   β”‚   β”‚       β”œβ”€β”€ users.py   # User management
β”‚   β”‚   β”‚       β”œβ”€β”€ products.py # Products & categories
β”‚   β”‚   β”‚       β”œβ”€β”€ orders.py  # Order processing
β”‚   β”‚   β”‚       β”œβ”€β”€ prebookings.py # Pre-booking system
β”‚   β”‚   β”‚       └── repairs.py # Repair inquiries
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py      # Settings management
β”‚   β”‚   β”‚   β”œβ”€β”€ logging.py     # Structured logging
β”‚   β”‚   β”‚   └── security.py    # Security utilities
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ db/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py    # SQLAlchemy setup
β”‚   β”‚   β”‚   └── supabase.py    # Supabase client
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/         # SQLAlchemy models
β”‚   β”‚   └── πŸ“‚ schemas/        # Pydantic schemas
β”‚   β”œβ”€β”€ πŸ“‚ scripts/            # Utility scripts
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   └── alembic.ini           # Alembic configuration
β”‚
β”œβ”€β”€ πŸ“‚ src/                    # React Frontend
β”‚   β”œβ”€β”€ πŸ“‚ assets/            # Static assets
β”‚   β”‚   β”œβ”€β”€ categories/       # Category images
β”‚   β”‚   └── products/         # Product images
β”‚   β”œβ”€β”€ πŸ“‚ components/
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ common/        # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ Badge.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Input.jsx
β”‚   β”‚   β”‚   └── ProductCard.jsx
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ home/          # Homepage sections
β”‚   β”‚   β”‚   β”œβ”€β”€ HeroSection/
β”‚   β”‚   β”‚   β”œβ”€β”€ CategoryShowcase/
β”‚   β”‚   β”‚   β”œβ”€β”€ FeaturedProducts/
β”‚   β”‚   β”‚   β”œβ”€β”€ WhyChooseUs/
β”‚   β”‚   β”‚   β”œβ”€β”€ RepairHighlight/
β”‚   β”‚   β”‚   └── StorePresence/
β”‚   β”‚   └── πŸ“‚ layout/        # Layout components
β”‚   β”‚       β”œβ”€β”€ Header.jsx
β”‚   β”‚       β”œβ”€β”€ Footer.jsx
β”‚   β”‚       └── MobileNav.jsx
β”‚   β”œβ”€β”€ πŸ“‚ context/           # React Context
β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx
β”‚   β”‚   └── CartContext.jsx
β”‚   β”œβ”€β”€ πŸ“‚ hooks/             # Custom hooks
β”‚   β”œβ”€β”€ πŸ“‚ pages/             # Page components
β”‚   β”‚   β”œβ”€β”€ HomePage.jsx
β”‚   β”‚   β”œβ”€β”€ ShopPage.jsx
β”‚   β”‚   β”œβ”€β”€ ProductPage.jsx
β”‚   β”‚   β”œβ”€β”€ CartPage.jsx
β”‚   β”‚   β”œβ”€β”€ RepairPage.jsx
β”‚   β”‚   β”œβ”€β”€ SparePartsPage.jsx
β”‚   β”‚   β”œβ”€β”€ LoginPage.jsx
β”‚   β”‚   β”œβ”€β”€ SignupPage.jsx
β”‚   β”‚   β”œβ”€β”€ AccountPage.jsx
β”‚   β”‚   β”œβ”€β”€ AboutPage.jsx
β”‚   β”‚   └── ContactPage.jsx
β”‚   β”œβ”€β”€ πŸ“‚ services/          # API services
β”‚   β”‚   β”œβ”€β”€ api.js            # Backend API calls
β”‚   β”‚   └── supabase.js       # Supabase client
β”‚   β”œβ”€β”€ App.jsx               # Root component
β”‚   β”œβ”€β”€ main.jsx              # Entry point
β”‚   └── index.css             # Global styles
β”‚
β”œβ”€β”€ πŸ“‚ public/                # Static public files
β”œβ”€β”€ index.html                # HTML entry point
β”œβ”€β”€ vite.config.js            # Vite configuration
β”œβ”€β”€ eslint.config.js          # ESLint configuration
β”œβ”€β”€ package.json              # Frontend dependencies
└── README.md                 # This file

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn
  • Python 3.11+
  • Supabase Account (free tier works)

Frontend Setup

  1. Clone the repository

    git clone https://github.com/yourusername/ecommerce-website.git
    cd ecommerce-website
  2. Install dependencies

    npm install
  3. Configure environment variables

    # Create .env file in root directory
    cp .env.example .env

    Add your Supabase credentials:

    VITE_SUPABASE_URL=your_supabase_project_url
    VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
    VITE_API_BASE_URL=http://localhost:8000/api/v1
  4. Start development server

    npm run dev

    The app will be available at http://localhost:5173

Backend Setup

  1. Navigate to backend directory

    cd backend
  2. Create virtual environment

    python -m venv venv
    
    # Windows
    .\venv\Scripts\activate
    
    # macOS/Linux
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment variables

    # Create .env file in backend directory
    cp .env.example .env

    Add your credentials:

    ENVIRONMENT=development
    DEBUG=True
    
    # Supabase
    SUPABASE_URL=your_supabase_project_url
    SUPABASE_KEY=your_supabase_anon_key
    SUPABASE_SERVICE_KEY=your_supabase_service_role_key
    SUPABASE_JWT_SECRET=your_supabase_jwt_secret
    
    # Database
    DATABASE_URL=postgresql+asyncpg://user:password@host:5432/database
    
    # CORS
    CORS_ORIGINS=http://localhost:5173,http://localhost:3000
    
    # Security
    SECRET_KEY=your-secret-key-change-in-production
  5. Run database migrations

    alembic upgrade head
  6. Start the backend server

    uvicorn app.main:app --reload

    The API will be available at http://localhost:8000

    • API Documentation: http://localhost:8000/docs
    • ReDoc: http://localhost:8000/redoc

⚠️ Troubleshooting: IPv4 / IPv6 Connection Issues

If you encounter database connection issues, it's likely due to IPv4 vs IPv6 compatibility with Supabase.

Common Symptoms:

  • Connection refused errors
  • Timeout when connecting to database
  • Backend fails to start with database errors

Solutions:

  1. Check your Supabase connection string

    • Go to Supabase Dashboard β†’ Settings β†’ Database
    • Use the Connection String for your network type
    • Some ISPs only support IPv4, others prefer IPv6
  2. Force IPv4 in your connection

    # Instead of using the hostname, try the direct IPv4 address
    # Find it in Supabase Dashboard β†’ Settings β†’ Database β†’ Connection Info
    
  3. Update your DATABASE_URL

    # If using IPv6 causes issues, check "Use connection pooling" in Supabase
    # and use the pooler connection string instead
    DATABASE_URL=postgresql+asyncpg://postgres:password@aws-0-region.pooler.supabase.com:5432/postgres
  4. Windows Users

    • Open Command Prompt as Administrator
    • Run: netsh interface ipv6 show prefixpolicies
    • If IPv6 is preferred, you may need to adjust or use IPv4 explicitly
  5. Test your connection

    # Test if you can reach Supabase
    ping db.your-project-id.supabase.co

πŸ’‘ Tip: Supabase's connection pooler (port 6543) often resolves these issues.


πŸ” Environment Variables

Frontend (.env)

Variable Description Required
VITE_SUPABASE_URL Supabase project URL βœ…
VITE_SUPABASE_ANON_KEY Supabase anonymous key βœ…
VITE_API_BASE_URL Backend API base URL βœ…

Backend (.env)

Variable Description Required
ENVIRONMENT development or production βœ…
DEBUG Enable debug mode ❌
SUPABASE_URL Supabase project URL βœ…
SUPABASE_KEY Supabase anonymous key βœ…
SUPABASE_SERVICE_KEY Supabase service role key βœ…
SUPABASE_JWT_SECRET Supabase JWT secret βœ…
DATABASE_URL PostgreSQL connection string βœ…
CORS_ORIGINS Allowed origins (comma-separated) βœ…
SECRET_KEY Application secret key βœ…

πŸ“š API Documentation

When running in development mode, API documentation is available at:

API Endpoints Overview

Method Endpoint Description
Authentication
POST /api/v1/auth/register Register new user
POST /api/v1/auth/login Login with email/password
POST /api/v1/auth/google Login with Google
POST /api/v1/auth/logout Logout user
Users
GET /api/v1/users/me Get current user profile
PUT /api/v1/users/me Update user profile
Products
GET /api/v1/products List products (with filters)
GET /api/v1/products/{id} Get product details
GET /api/v1/products/categories List categories
Orders
POST /api/v1/orders Create new order
GET /api/v1/orders List user orders
GET /api/v1/orders/{id} Get order details
Pre-bookings
POST /api/v1/prebookings Create pre-booking
GET /api/v1/prebookings List user pre-bookings
Repairs
POST /api/v1/repairs Submit repair inquiry
GET /api/v1/repairs List repair requests

πŸ“Έ Screenshots

Screenshots coming soon...


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License with Attribution Requirement.

You are free to use this code as a starting point for your own e-commerce website, but you must give credit to this repository. This can be done by:

  • Adding a credit line in your website footer
  • Mentioning the original repo in your About/Credits page
  • Referencing this repo in your project's README

You cannot claim this code as entirely your own original work.

See the LICENSE file for full details.


πŸ‘¨β€πŸ’» Author

E-Commerce Website Contributors

  • Website: [Coming Soon]
  • Email: [Contact Email]

Made with ❀️ in India

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors