This project is a fully-featured e-commerce backend written in FastAPI 🚀 with a focus on DevOps principles, clean architecture, and modular design. It supports user authentication, role-based access control, stock and product management, PayPal integration for payments, and much more.
-
✅ User Management
Register, login, JWT-based auth, password reset, role assignment -
🛡 Role-Based Access Control
Admin-only endpoints, dynamic role linking -
📦 Stock & Inventory Management
CRUD operations on products, stock updates on checkout -
🛒 Cart & Checkout
Cart with multiple items, item quantity tracking -
💳 PayPal Integration
Create and capture PayPal orders via API -
📊 Reports & KPIs
Generate downloadable PDF reports -
🔐 Token Blacklisting
Secure logout with token blacklisting -
🧪 Full Test Coverage
Unit + integration tests withpytest,factory_boy, and SQLite in-memory DB -
🐳 Dockerized Setup
Clean service separation using Docker Compose (dev-ready)
| Layer | Technology |
|---|---|
| API | FastAPI |
| Auth | JWT, PassLib |
| DB | PostgreSQL |
| ORM | SQLAlchemy |
| Payments | PayPal REST API |
| Docs | Swagger/OpenAPI |
| Testing | Pytest, Factory Boy |
| DevOps | Docker, Compose |
- back/
- docker/
- .env.template
- docker-compose-dev.yml
- docker-compose-prod.yml
- README.md
- script_fixture_product.py
cp .env.template .envMake sure Docker is running, then:
docker-compose -f docker-compose-dev.yml --profile back --env-file .env up -dThis spins up:
- PostgreSQL database
- FastAPI app (with hot reload)
- Optional: pgAdmin (if tools profile is used)
docker-compose downdocker exec -it back bash -c "pytest"| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register new user |
| POST | /auth/login |
Login and receive JWT |
| GET | /users |
List all users (admin only) |
| POST | /stocks |
Add new stock (admin only) |
| POST | /create-paypal-order |
Create PayPal order (auth) |
| POST | /capture-paypal-order/:id |
Capture PayPal payment |
| GET | /reports |
Download PDF report (admin) |
This project is educational and open-source. Feel free to adapt it for your own use. Contributions welcome!