Skip to content

pratheep-bit/ecommerce-platform-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Scalable E-Commerce Platform

A production-ready, fullstack e-commerce system built with modern technologies.
FastAPI Β· React Β· Flutter Β· PostgreSQL Β· Redis Β· Docker


Overview

A fullstack e-commerce platform designed with scalability, security, and developer experience as core principles. The system supports the complete purchase lifecycle β€” from product discovery and cart management through payment processing and shipment tracking β€” across web and mobile clients.

Built with an API-first architecture, the platform cleanly separates concerns between a high-performance Python backend, a modern React SPA, and a cross-platform Flutter mobile app, all orchestrated through Docker for consistent development and deployment environments.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Client Layer                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                     β”‚
β”‚  β”‚   React SPA      β”‚  β”‚   Flutter App    β”‚                     β”‚
β”‚  β”‚   (TypeScript)   β”‚  β”‚   (Dart)         β”‚                     β”‚
β”‚  β”‚   Vite + ShadCN  β”‚  β”‚   Riverpod       β”‚                     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚     HTTPS / REST     β”‚
            β–Ό                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      API Gateway Layer                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚              FastAPI (Uvicorn / Gunicorn)                 β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚  β”‚  β”‚  Auth    β”‚ β”‚ Products β”‚ β”‚  Orders  β”‚ β”‚  Payments  β”‚  β”‚   β”‚
β”‚  β”‚  β”‚  Routes  β”‚ β”‚  Routes  β”‚ β”‚  Routes  β”‚ β”‚  Routes    β”‚  β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚  β”‚  β”‚  Cart   β”‚  β”‚  Admin  β”‚  β”‚ Webhooks β”‚ β”‚  Users     β”‚  β”‚   β”‚
β”‚  β”‚  β”‚  Routes β”‚  β”‚  Routes β”‚  β”‚  Routes  β”‚ β”‚  Routes    β”‚  β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                      β”‚
            β–Ό                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL 15      β”‚  β”‚   Redis 7            β”‚
β”‚   (Primary Store)    β”‚  β”‚   (Cache + Sessions) β”‚
β”‚   via Supabase       β”‚  β”‚   Rate Limiting      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            External Services                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Razorpay β”‚ β”‚ Twilio   β”‚ β”‚  Shiprocket  β”‚  β”‚
β”‚  β”‚ Payments β”‚ β”‚ OTP/SMS  β”‚ β”‚  Shipping    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Layer Technology Purpose
Backend Python 3.11, FastAPI, SQLAlchemy 2.0 REST API, business logic, ORM
Frontend React 18, TypeScript, Vite, TailwindCSS Single-page application
Mobile Flutter 3.x, Dart, Riverpod Cross-platform mobile app
Database PostgreSQL 15 (Supabase) Persistent data storage
Cache Redis 7 Rate limiting, session caching
Payments Razorpay Payment gateway integration
SMS/OTP Twilio OTP-based authentication
Shipping Shiprocket Order fulfillment & tracking
Email SMTP (aiosmtplib) Transactional notifications
DevOps Docker, Docker Compose, Render Containerized deployment
Monitoring Sentry Error tracking & performance

Features

πŸ” Authentication & Security

  • OTP-based passwordless authentication via SMS (Twilio)
  • JWT access + refresh token rotation with blacklist support
  • Rate-limited OTP requests (per-hour limits)
  • Bcrypt password hashing for admin accounts
  • Request ID middleware for distributed tracing

πŸ›οΈ Product Management

  • Paginated product catalog with slug-based routing
  • Rich product schema: images, specifications, MRP vs. selling price
  • Admin CRUD operations with stock management
  • Active/inactive product visibility control

πŸ›’ Cart System

  • Persistent server-side cart for authenticated users
  • Guest cart merge on login (seamless handoff)
  • Real-time stock validation on add/update
  • Quantity limits (max 10 per item)

πŸ“¦ Order Lifecycle

  • Stock reservation on order creation (prevents overselling)
  • Stock commit on payment verification
  • Auto-cancellation of expired unpaid orders (30-min TTL via background task)
  • Order number generation with timestamp + random suffix
  • Full order history with pagination

πŸ’³ Payment Processing

  • Razorpay integration with server-side order creation
  • Cryptographic signature verification
  • Idempotent payment verification (safe retries)
  • Automatic refund on cancellation
  • Webhook support for async payment events

πŸ“Š Admin Panel

  • Secure admin authentication (email/password + JWT)
  • Order management (status updates, bulk operations)
  • Analytics dashboard (revenue, order counts, daily trends)
  • Product CRUD (create, update stock, toggle visibility)
  • Shiprocket integration for shipment creation

🚚 Shipping & Tracking

  • Shiprocket API integration for label generation
  • Real-time shipment status tracking
  • AWB number and courier assignment
  • Tracking URL generation for customers

πŸ“§ Notifications

  • Transactional email service (order confirmation, payment receipt, refund)
  • SMS notifications for OTP and order updates
  • Async, fire-and-forget notification delivery

Project Structure

β”œβ”€β”€ backend/                    # Python FastAPI application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/                # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ deps.py         # Dependency injection (auth, rate limiting)
β”‚   β”‚   β”‚   └── v1/             # Versioned API endpoints
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.py     # OTP send/verify, token refresh, logout
β”‚   β”‚   β”‚       β”œβ”€β”€ products.py # Product listing & detail
β”‚   β”‚   β”‚       β”œβ”€β”€ cart.py     # Cart CRUD & merge
β”‚   β”‚   β”‚       β”œβ”€β”€ orders.py   # Order creation, listing, cancellation
β”‚   β”‚   β”‚       β”œβ”€β”€ payments.py # Razorpay create/verify
β”‚   β”‚   β”‚       β”œβ”€β”€ users.py    # Profile & address management
β”‚   β”‚   β”‚       β”œβ”€β”€ admin.py    # Admin operations & analytics
β”‚   β”‚   β”‚       └── webhooks.py # Razorpay & Shiprocket webhooks
β”‚   β”‚   β”œβ”€β”€ core/               # Core utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py       # Pydantic settings (env validation)
β”‚   β”‚   β”‚   β”œβ”€β”€ security.py     # JWT, OTP, password hashing
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware.py   # Request ID middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ logging.py      # Structured logging
β”‚   β”‚   β”‚   β”œβ”€β”€ retry.py        # Retry utilities for external APIs
β”‚   β”‚   β”‚   └── order_state.py  # Order state machine
β”‚   β”‚   β”œβ”€β”€ db/                 # Database layer
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py     # Async engine & session factory
β”‚   β”‚   β”‚   β”œβ”€β”€ models.py       # SQLAlchemy ORM models
β”‚   β”‚   β”‚   └── migrations/     # Alembic migration scripts
β”‚   β”‚   β”œβ”€β”€ schemas/            # Pydantic request/response schemas
β”‚   β”‚   β”œβ”€β”€ services/           # Business logic services
β”‚   β”‚   β”‚   β”œβ”€β”€ razorpay_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ email_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ shiprocket_service.py
β”‚   β”‚   β”‚   └── twilio_sms.py
β”‚   β”‚   └── integrations/       # External API clients
β”‚   β”‚       β”œβ”€β”€ shiprocket.py
β”‚   β”‚       └── sms.py
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ gunicorn.conf.py
β”‚   β”œβ”€β”€ alembic.ini
β”‚   └── seed_db.py              # Database seeding script
β”‚
β”œβ”€β”€ frontend/                   # React TypeScript application
β”‚   β”œβ”€β”€ client/
β”‚   β”‚   β”œβ”€β”€ App.tsx             # Root component with routing
β”‚   β”‚   β”œβ”€β”€ pages/              # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Index.tsx       # Home / product showcase
β”‚   β”‚   β”‚   β”œβ”€β”€ Cart.tsx        # Shopping cart
β”‚   β”‚   β”‚   β”œβ”€β”€ Checkout.tsx    # Checkout flow
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.tsx       # OTP authentication
β”‚   β”‚   β”‚   └── Account.tsx     # User profile & orders
β”‚   β”‚   β”œβ”€β”€ components/         # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   └── ui/             # ShadCN UI primitives
β”‚   β”‚   β”œβ”€β”€ context/            # React context providers
β”‚   β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”‚   └── lib/                # Utility functions
β”‚   β”œβ”€β”€ server/                 # SSR / BFF layer (Express)
β”‚   β”œβ”€β”€ shared/                 # Shared types (client ↔ server)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ vite.config.ts
β”‚   └── package.json
β”‚
β”œβ”€β”€ mobile/                     # Flutter mobile application
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ main.dart           # App entry point
β”‚   β”‚   β”œβ”€β”€ core/               # Theme, routing, constants
β”‚   β”‚   β”œβ”€β”€ screens/            # Feature screens
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”œβ”€β”€ home/
β”‚   β”‚   β”‚   β”œβ”€β”€ product/
β”‚   β”‚   β”‚   β”œβ”€β”€ cart/
β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/
β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚   β”‚   β”‚   └── profile/
β”‚   β”‚   β”œβ”€β”€ providers/          # Riverpod state management
β”‚   β”‚   β”œβ”€β”€ services/           # API service layer
β”‚   β”‚   └── widgets/            # Reusable UI widgets
β”‚   └── pubspec.yaml
β”‚
β”œβ”€β”€ infra/                      # Infrastructure & deployment
β”‚   β”œβ”€β”€ docker-compose.yml      # Full stack orchestration
β”‚   └── render.yaml             # Render.com deployment config
β”‚
β”œβ”€β”€ docs/                       # Documentation
β”‚   β”œβ”€β”€ architecture.md         # System design & decisions
β”‚   └── api.md                  # API reference
β”‚
β”œβ”€β”€ .gitignore
└── README.md

Key Engineering Highlights

Modular Backend Design

The backend follows a clean layered architecture β€” routes handle HTTP concerns, services encapsulate business logic, and the database layer provides an async ORM abstraction. Each domain (auth, cart, orders, payments) is self-contained with its own router, schemas, and dependencies.

Stock Reservation Pattern

A two-phase stock management system prevents overselling in concurrent environments:

  1. Reserve β€” Stock is reserved (not deducted) when an order is created
  2. Commit β€” Reserved stock is committed (deducted) only after payment verification
  3. Release β€” If payment fails or the order expires, reserved stock is returned to the available pool

Background Task Orchestration

The application runs async background loops for:

  • Order cleanup β€” Cancels unpaid orders after 30 minutes, releasing reserved stock
  • Token cleanup β€” Purges expired JWT blacklist entries daily

API-First Architecture

All three clients (web, mobile, admin) consume the same versioned REST API (/api/v1), ensuring consistent behavior and enabling independent client development. The API is designed with proper:

  • Request/response validation via Pydantic schemas
  • Pagination on all list endpoints
  • Idempotent payment verification
  • Structured error responses

Containerized Deployment

The entire stack is orchestrated via Docker Compose with health checks, service dependencies, and persistent volumes. Production deployment is configured for Render.com with auto-generated secrets.


Getting Started

Prerequisites

  • Docker & Docker Compose (recommended)
  • Or individually: Python 3.11+, Node.js 18+, Flutter 3.2+

Quick Start (Docker)

# Clone the repository
git clone https://github.com/pratheep-bit/ECOMMERCE-SITE-CKM.git
cd ECOMMERCE-SITE-CKM

# Copy environment template
cp backend/.env.example backend/.env
# Edit backend/.env with your credentials (Supabase, Razorpay, Twilio, etc.)

# Start all services
docker-compose -f infra/docker-compose.yml up --build

# Services will be available at:
#   Backend API:  http://localhost:8000
#   Frontend:     http://localhost:3000
#   API Docs:     http://localhost:8000/docs (dev mode only)

Manual Setup

Backend
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your configuration
uvicorn app.main:app --reload --port 8000
Frontend
cd frontend
npm install
npm run dev
# Opens at http://localhost:5173
Mobile
cd mobile
flutter pub get
flutter run

Environment Variables

See backend/.env.example for the complete list. Key variables:

Variable Description
DATABASE_URL PostgreSQL connection string (async)
REDIS_URL Redis connection URL
JWT_SECRET_KEY Secret for JWT signing
RAZORPAY_KEY_ID Razorpay API key
RAZORPAY_KEY_SECRET Razorpay API secret
TWILIO_ACCOUNT_SID Twilio SMS account SID
SUPABASE_URL Supabase project URL

API Documentation

Interactive API docs are available at /docs (Swagger UI) and /redoc when running in development mode.

For a complete endpoint reference, see docs/api.md.


Future Roadmap

  • Search & Filtering β€” Elasticsearch integration for product search
  • Caching Layer β€” Redis-backed response caching for product catalog
  • CI/CD Pipeline β€” GitHub Actions for automated testing and deployment
  • Microservices Split β€” Extract payments and notifications into independent services
  • WebSocket Notifications β€” Real-time order status updates
  • Internationalization β€” Multi-language and multi-currency support
  • Analytics Dashboard β€” Grafana + Prometheus for operational metrics

License

This project is built for educational and portfolio demonstration purposes.


Built with precision by Pratheep

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors