A modern, scalable backend API for an E-commerce platform built with Python & FastAPI. This project demonstrates real-world backend architecture β covering authentication, database relationships, payment integration, and RESTful API design.
β User Management
- User registration & login with JWT authentication
- Role-based access (Admin, Customer)
β Product Management
- CRUD operations for products
- Category-based product listing
- Search & filtering
β Order Management
- Create & manage customer orders
- Track order status (Pending β Shipped β Delivered)
- Admin order control
β Payment Integration
- Simulated/real payment handling (e.g., Stripe/Paystack ready)
- Secure transaction flow
β Database Relationships
- One-to-Many: User β Orders
- Many-to-Many: Orders β Products
β API Design
- RESTful endpoints
- Pagination, validation, and error handling
| Layer | Technology |
|---|---|
| Framework | FastAPI |
| Database ORM | SQLAlchemy |
| Database Migration | Alembic |
| Authentication | JWT (via python-jose, passlib[bcrypt]) |
| Environment Management | python-dotenv |
| Server | Uvicorn |
| Testing | Pytest |
| Docs | Built-in Swagger UI (/docs) & Redoc (/redoc) |
ecommerce-backend/
βββ app/
β βββ main.py # Entry point
β βββ config.py # Environment & DB settings
β βββ database.py # DB connection setup
β βββ models/ # SQLAlchemy models
β βββ schemas/ # Pydantic schemas
β βββ routers/
β β βββ users.py
β β βββ products.py
β β βββ orders.py
β β βββ payments.py
β βββ services/ # Business logic layer
β βββ utils/ # Helpers (auth, hashing, etc.)
βββ tests/ # Unit & integration tests
βββ requirements.txt
βββ README.md
git clone https://github.com/<your-username>/ecommerce-backend.git
cd ecommerce-backendpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the root directory:
DATABASE_URL=postgresql://user:password@localhost:5432/ecommerce_db
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30alembic upgrade headuvicorn app.main:app --reloadNow open your browser and navigate to: π Swagger Docs: http://127.0.0.1:8000/docs
| Method | Endpoint | Description |
|---|---|---|
POST |
/users/signup |
Register new user |
POST |
/users/login |
Login & get JWT token |
GET |
/products/ |
List all products |
POST |
/orders/ |
Create an order |
POST |
/payments/checkout |
Process a payment |
- Integrate Paystack or Stripe API
- Implement Redis caching for performance
- Add Celery background tasks (e.g., email notifications)
- Build an admin dashboard frontend
Olabowale Babatunde Ipaye π§ b.tunde.ipaye@gmail.com π Lagos, Nigeria π LinkedIn | GitHub
This project is licensed under the MIT License. Feel free to use, modify, and distribute.