A full-stack e-commerce application built with FastAPI, React, and Azure Cosmos DB for MongoDB (DocumentDB). Features both a customer-facing storefront and an admin dashboard.
- Browse Products - View all products with category filtering
- Shopping Cart - Add/remove items, update quantities
- Checkout - Create orders with customer information
- Responsive Design - Mobile-friendly interface
- Dashboard Overview - Real-time statistics and metrics
- Product Management - CRUD operations for products
- Order Management - View and update order statuses
- Customer Management - View customer information
βββββββββββββββββββ
β React SPA β Port 80 (Frontend)
β (Nginx) β
ββββββββββ¬βββββββββ
β
β /api/*
βΌ
βββββββββββββββββββ
β FastAPI β Port 8000 (Backend)
β (Python) β
ββββββββββ¬βββββββββ
β
β MongoDB Protocol
βΌ
βββββββββββββββββββ
β DocumentDB β Port 10260 (Database)
β (Host Machine) β
βββββββββββββββββββ
- FastAPI - Modern, fast Python web framework
- Motor - Async MongoDB driver
- Beanie - ODM for MongoDB
- Pydantic - Data validation
- Uvicorn - ASGI server
- React 18 - UI library
- TypeScript - Type safety
- Vite - Build tool
- Tailwind CSS - Styling
- React Router - Navigation
- Axios - HTTP client
- Lucide Icons - Icon library
- Azure Cosmos DB for MongoDB (DocumentDB) - NoSQL database
- Docker & Docker Compose
- DocumentDB running on port 10260
docker-compose up --build -d- Storefront: http://localhost
- Admin Dashboard: http://localhost/admin
- API Documentation: http://localhost:8000/docs
- API Health Check: http://localhost:8000/health
# All services
docker-compose logs -f
# Backend only
docker-compose logs -f backend
# Frontend only
docker-compose logs -f frontendGET /api/v1/products- List productsPOST /api/v1/products- Create productGET /api/v1/products/{id}- Get productPUT /api/v1/products/{id}- Update productDELETE /api/v1/products/{id}- Delete product
GET /api/v1/customers- List customersPOST /api/v1/customers- Create customerGET /api/v1/customers/{id}- Get customerPUT /api/v1/customers/{id}- Update customer
GET /api/v1/orders- List ordersPOST /api/v1/orders- Create orderGET /api/v1/orders/{id}- Get orderPATCH /api/v1/orders/{id}/status- Update order status
{
"id": "string",
"name": "Product Name",
"description": "Product description",
"price": 99.99,
"category": "Electronics",
"stock": 100,
"sku": "PROD-001",
"created_at": "2025-10-09T..."
}{
"id": "string",
"name": "Customer Name",
"email": "customer@example.com",
"phone": "+1234567890",
"address": {
"street": "123 Main St",
"city": "Seattle",
"state": "WA",
"zip_code": "98101",
"country": "USA"
},
"created_at": "2025-10-09T..."
}{
"id": "string",
"customer_id": "string",
"items": [
{
"product_id": "string",
"product_name": "Product Name",
"quantity": 2,
"price": 99.99
}
],
"total_amount": 199.98,
"status": "pending",
"created_at": "2025-10-09T..."
}cd backend
pip install -r requirements.txt
uvicorn app.main:app --reloadcd frontend
npm install
npm run devEdit .env file:
# Database
DOCUMENTDB_URL=mongodb://patty:chow@host.docker.internal:10260/?tls=true&tlsAllowInvalidCertificates=true&authMechanism=SCRAM-SHA-256
DOCUMENTDB_DB_NAME=shop
# API
API_V1_PREFIX=/api/v1
BACKEND_CORS_ORIGINS=["http://localhost:3000","http://localhost:8000","http://localhost"]
# App Settings
DEBUG=true
RELOAD=true- Browse products at http://localhost/products
- Click "Add to Cart" for desired products
- View cart at http://localhost/cart
- Click "Proceed to Checkout"
- Fill in customer information
- Submit order
This creates:
- A new Customer record
- A new Order record with order items
- Automatically decrements product stock
- Navigate to http://localhost/admin/orders
- View all orders with status filters
- Update order status using dropdown
- Track order progression:
pending β processing β shipped β delivered
- Image:
fastapi-vscode-backend - Port: 8000
- Features: Hot-reload enabled for development
- Image:
fastapi-vscode-frontend - Port: 80
- Features: Nginx serves React SPA, proxies /api/* to backend
# Stop containers
docker-compose down
# Remove containers and volumes
docker-compose down -v
# Remove images
docker-compose down --rmi all- Customer browses products and adds to cart
- During checkout, system creates:
- Customer record (if new)
- Order record with items
- Automatically updates product stock
- Order appears in admin dashboard
- Admin can track and update order status
- Real-time Dashboard: View total products, orders, customers, and revenue
- Product Management: Add, edit, delete products with stock tracking
- Order Tracking: Filter orders by status, update order workflow
- Customer Insights: View all customer information and order history
Orders progress through these statuses:
pending- Order created, awaiting processingprocessing- Order is being preparedshipped- Order has been shippeddelivered- Order delivered to customercancelled- Order cancelled
- Responsive Design - Works on desktop, tablet, and mobile
- Real-time Updates - Cart updates instantly
- Toast Notifications - User-friendly feedback
- Loading States - Clear loading indicators
- Error Handling - Graceful error messages
This project is part of the FastAPI + DocumentDB demonstration.
Built with β€οΈ using FastAPI, React, and Azure Cosmos DB for MongoDB