A full-stack e-commerce application built with Next.js 15 (frontend) and Flask (backend), featuring user authentication, product catalog, shopping cart, wishlist, Stripe payments, and order management.
π Note for Instructor: The environment variables required for Docker setup will be provided separately via Canvas message. Please create a
backend/.envfile with those values before running Docker.
Link: https://youtu.be/l_OPJ-HBudc
- Frontend: https://mdsrtech.vercel.app
- Backend API: https://e-commerce-project-production-dd50.up.railway.app
| Document | Description |
|---|---|
| README.md | Project overview and setup instructions |
| docs/API.md | Complete API endpoint documentation |
| docs/DEPLOYMENT.md | Deployment process and CI/CD pipeline |
| docs/architecture.md | System architecture and UML diagrams |
- Docker installed
- Docker Compose installed
-
Clone the repository
git clone https://github.com/MDSR-Tech/E-commerce_project.git cd E-commerce_project -
Create environment file
Create
backend/.envwith the following variables (values provided separately via Canvas):# Flask FLASK_APP=app.py FLASK_ENV=development DEBUG=True # Database (Supabase PostgreSQL) DATABASE_URL=postgresql://... # JWT JWT_SECRET_KEY=... # CORS & Frontend CORS_ORIGINS=http://localhost:3000 FRONTEND_URL=http://localhost:3000 # Email (Gmail SMTP) MAIL_SERVER=smtp.gmail.com MAIL_PORT=587 MAIL_USE_TLS=True MAIL_USE_SSL=False MAIL_USERNAME=... MAIL_PASSWORD=... MAIL_DEFAULT_SENDER=... # Google OAuth GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=... GOOGLE_REDIRECT_URI=http://localhost:5000/api/auth/google/callback # GitHub OAuth GITHUB_CLIENT_ID=... GITHUB_CLIENT_SECRET=... GITHUB_REDIRECT_URI=http://localhost:5000/api/auth/github/callback # Stripe STRIPE_SECRET_KEY=sk_test_... STRIPE_PUBLISHABLE_KEY=pk_test_... STRIPE_WEBHOOK_SECRET=
-
Build and run with Docker Compose
docker-compose up --build
Note: The first build may take 3-10 minutes as it downloads base images and installs dependencies. Subsequent builds are faster due to Docker caching.
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api
-
Stop the application
docker-compose down
docker-compose.yml
βββ backend (Flask)
β βββ Port: 5000
β βββ Dockerfile.dev
β βββ Volume: ./backend:/app
β
βββ frontend (Next.js)
β βββ Port: 3000
β βββ Dockerfile.dev
β βββ Volume: ./frontend/mdsrtech:/app
β
βββ Network: ecommerce-network (internal communication)
The frontend connects to the backend using Docker's internal networking (http://backend:5000/api) for server-side rendering, while browser requests use http://localhost:5000/api.
-
Navigate to backend directory
cd backend -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables
Create
backend/.envwith required variables (see Environment Variables). -
Run the development server
flask run
Backend runs at http://localhost:5000
-
Navigate to frontend directory
cd frontend/mdsrtech -
Install dependencies
npm install
-
Set environment variables
Create a
.env.localfile:NEXT_PUBLIC_API_URL=http://localhost:5000/api
-
Run the development server
npm run dev
Frontend runs at http://localhost:3000
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string (Supabase) |
JWT_SECRET_KEY |
Secret key for JWT tokens |
CORS_ORIGINS |
Allowed CORS origins (e.g., http://localhost:3000) |
FRONTEND_URL |
Frontend URL for OAuth redirects |
STRIPE_SECRET_KEY |
Stripe secret key for payments |
STRIPE_PUBLISHABLE_KEY |
Stripe publishable key |
| Variable | Description |
|---|---|
GOOGLE_CLIENT_ID |
Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth client secret |
GOOGLE_REDIRECT_URI |
Google OAuth callback URL |
GITHUB_CLIENT_ID |
GitHub OAuth client ID |
GITHUB_CLIENT_SECRET |
GitHub OAuth client secret |
GITHUB_REDIRECT_URI |
GitHub OAuth callback URL |
MAIL_SERVER |
SMTP server (default: smtp.gmail.com) |
MAIL_PORT |
SMTP port (default: 587) |
MAIL_USE_TLS |
Use TLS (default: True) |
MAIL_USERNAME |
Gmail address for sending emails |
MAIL_PASSWORD |
Gmail app password |
MAIL_DEFAULT_SENDER |
Default sender email address |
- Email/password registration and login
- OAuth 2.0 (Google and GitHub)
- JWT-based authentication with refresh tokens
- Password reset via email
- Browse products by category
- Search functionality with filters
- Product details with multiple images
- Sale prices and discounts
- Add/remove items
- Update quantities
- Promo code support
- Persistent cart (survives page refresh)
- Save products for later
- Toggle add/remove
- View wishlist items
- Secure Stripe Checkout integration
- Shipping address collection
- Order confirmation emails
- View order history
- Order details and tracking
- Cancel pending orders
| Layer | Technology |
|---|---|
| Frontend | Next.js 15, React 19, TypeScript, TailwindCSS |
| Backend | Flask 3.0, Flask-SQLAlchemy, Flask-JWT-Extended |
| Database | PostgreSQL (Supabase) |
| Authentication | JWT, OAuth 2.0 (Google, GitHub) |
| Payments | Stripe Checkout |
| Deployment | Vercel (Frontend), Railway (Backend) |
| Containerization | Docker, Docker Compose |
See docs/architecture.md for detailed UML diagrams including:
- Package Diagram - System components and dependencies
- Class Diagram - Database models and relationships
E-commerce_project/
βββ backend/ # Flask API
β βββ app.py # Application factory
β βββ auth.py # Authentication routes
β βββ products.py # Product routes
β βββ cart.py # Cart routes
β βββ orders.py # Order routes
β βββ checkout.py # Stripe checkout
β βββ wishlist.py # Wishlist routes
β βββ models.py # SQLAlchemy models
β βββ extensions.py # Flask extensions
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Production Docker image
β βββ Dockerfile.dev # Development Docker image
β βββ tests/ # Test suite
β βββ conftest.py # Test fixtures
β βββ test_unit.py # Unit tests (18 tests)
β βββ test_integration.py # Integration tests (35 tests)
β βββ test_e2e_selenium.py # E2E tests (20 tests)
β
βββ frontend/mdsrtech/ # Next.js Frontend
β βββ app/ # App router pages
β β βββ page.tsx # Home page
β β βββ auth/ # Authentication pages
β β βββ cart/ # Shopping cart
β β βββ wishlist/ # Wishlist page
β β βββ orders/ # Order history
β β βββ checkout/ # Checkout flow
β β βββ product/ # Product details
β β βββ category/ # Category pages
β β βββ search/ # Search results
β β βββ components/ # Reusable components
β βββ contexts/ # React contexts
β βββ lib/ # Utilities and API clients
β βββ package.json # Node dependencies
β βββ Dockerfile.dev # Development Docker image
β
βββ docs/ # Documentation
β βββ API.md # API endpoint documentation
β βββ DEPLOYMENT.md # Deployment guide
β βββ architecture.md # Architecture & UML diagrams
β
βββ .github/workflows/ # CI/CD pipelines
β βββ ci.yml # GitHub Actions workflow
β
βββ docker-compose.yml # Docker Compose configuration
βββ README.md
Full API documentation is available in docs/API.md.
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/api/auth/register |
POST | Register new user | No |
/api/auth/login |
POST | Login with email/password | No |
/api/auth/refresh |
POST | Refresh JWT token | Yes |
/api/auth/me |
GET | Get current user | Yes |
/api/auth/google |
GET | Google OAuth | No |
/api/auth/github |
GET | GitHub OAuth | No |
/api/auth/forgot-password |
POST | Request password reset | No |
/api/auth/reset-password |
POST | Reset password | No |
/api/products |
GET | List all products | No |
/api/products/{id} |
GET | Get product by ID | No |
/api/products/slug/{slug} |
GET | Get product by slug | No |
/api/search?q= |
GET | Search products | No |
/api/categories |
GET | List categories | No |
/api/brands |
GET | List brands | No |
/api/cart |
GET | Get user's cart | Yes |
/api/cart/add |
POST | Add to cart | Yes |
/api/cart/update |
PUT | Update cart item | Yes |
/api/cart/remove |
DELETE | Remove from cart | Yes |
/api/cart/clear |
DELETE | Clear cart | Yes |
/api/wishlist |
GET | Get wishlist | Yes |
/api/wishlist/toggle |
POST | Toggle wishlist item | Yes |
/api/orders |
GET | Get user's orders | Yes |
/api/orders/{id} |
GET | Get order details | Yes |
/api/checkout/create-session |
POST | Create Stripe session | Yes |
The project includes comprehensive testing at three levels.
backend/tests/
βββ conftest.py # Pytest fixtures and configuration
βββ test_unit.py # Unit tests for core functionality (18 tests)
βββ test_integration.py # API endpoint integration tests (35 tests)
βββ test_e2e_selenium.py # Browser-based end-to-end tests (20 tests)
cd backend
# Install test dependencies
pip install pytest pytest-cov selenium webdriver-manager
# Run all tests
pytest
# Run unit tests only
pytest tests/test_unit.py -v
# Run integration tests only
pytest tests/test_integration.py -v
# Run E2E tests (requires frontend/backend running)
pytest tests/test_e2e_selenium.py -v
# Run with coverage report
pytest --cov=. --cov-report=html| Test Type | Tests | Description |
|---|---|---|
| Unit | 18 | Model properties, calculations, validation, password hashing |
| Integration | 35 | API endpoints, authentication, error handling |
| E2E (Selenium) | 20 | Browser flows, responsive design, accessibility |
| Total | 73 | (61 passing, 12 skipped for SQLite/PostgreSQL compatibility) |
- Product model properties (
is_on_sale,sale_price_cents) - Price calculations (subtotal, tax, totals)
- Password hashing and verification
- User model defaults and validation
- Authentication API (register, login, refresh, admin)
- Products API (list, get by ID/slug, search)
- Cart API (add, update, remove, count)
- Wishlist API (toggle, list, IDs)
- Orders API (list, get details)
- Error handling (401, 403, 404, 405)
- Home page and navigation
- User registration and login flows
- Product browsing and search
- Cart functionality
- Responsive design (mobile/tablet)
- Basic accessibility checks
Performance analysis of the deployed application using Google PageSpeed Insights.
-
Frontend (Next.js)
- Automatic code splitting
- Image optimization with
next/image - Static generation where possible
- Edge caching via Vercel CDN
-
Backend (Flask)
- Database query optimization
- Connection pooling via Supabase
- Response caching headers
- Gunicorn multi-worker setup
Full deployment documentation is available in docs/DEPLOYMENT.md.
| Component | Platform | URL | Auto-Deploy |
|---|---|---|---|
| Frontend | Vercel | mdsrtech.vercel.app | β On push to main |
| Backend | Railway | railway.app | β On push to main |
| Database | Supabase | Hosted PostgreSQL | N/A (managed) |
GitHub Actions runs on every push:
- Lint - Python (flake8) and TypeScript (ESLint)
- Test - Run pytest test suite
- Build - Build Next.js frontend
- Deploy - Auto-deploy to Vercel and Railway

