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.