A production-ready, fullstack e-commerce system built with modern technologies.
FastAPI Β· React Β· Flutter Β· PostgreSQL Β· Redis Β· Docker
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.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β β
β ββββββββββββ ββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββ
| 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 |
| SMTP (aiosmtplib) | Transactional notifications | |
| DevOps | Docker, Docker Compose, Render | Containerized deployment |
| Monitoring | Sentry | Error tracking & performance |
- 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
- 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
- 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)
- 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
- 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
- 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
- Shiprocket API integration for label generation
- Real-time shipment status tracking
- AWB number and courier assignment
- Tracking URL generation for customers
- Transactional email service (order confirmation, payment receipt, refund)
- SMS notifications for OTP and order updates
- Async, fire-and-forget notification delivery
βββ 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
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.
A two-phase stock management system prevents overselling in concurrent environments:
- Reserve β Stock is reserved (not deducted) when an order is created
- Commit β Reserved stock is committed (deducted) only after payment verification
- Release β If payment fails or the order expires, reserved stock is returned to the available pool
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
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
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.
- Docker & Docker Compose (recommended)
- Or individually: Python 3.11+, Node.js 18+, Flutter 3.2+
# 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)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 8000Frontend
cd frontend
npm install
npm run dev
# Opens at http://localhost:5173Mobile
cd mobile
flutter pub get
flutter runSee 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 |
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.
- 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
This project is built for educational and portfolio demonstration purposes.
Built with precision by Pratheep