Marketplace is a highβperformance, scalable, and modular eβcommerce backend built with FastAPI. It provides a fully structured architecture that covers every essential part of an online marketplace: user authentication, product catalog, carts, orders, delivery logistics, image upload system, and review management.
Designed following clean architecture principles, the project is maintainable, extendable, and productionβready.
-
User registration & login
-
Logout and token revocation
-
Refresh token workflow
-
Password recovery via email
-
Secure JWTβbased authentication (access + refresh tokens)
-
Role system with permissions:
- Buyer
- Seller
- Courier
- Admin
- Password hashing with bcrypt
- Revoked token tracking (logout / logout_all)
- Roleβbased access control
- Strict Pydantic validation for all input/output data
- Secure and isolated file upload handling
| Layer | Technologies |
|---|---|
| Backend | FastAPI, SQLAlchemy 2.0, Alembic |
| Database | PostgreSQL |
| Async | asyncpg, aiofiles |
| Authentication | OAuth2, JWT (Access & Refresh) |
| Caching (optional) | Redis |
| File Storage | /media directory with hashed filenames |
| Testing | Pytest |
| DevOps (optional) | GitHub Actions |
Project SQL diagram overview
- users
- sellers
- couriers
- delivery_addresses
- deliveries
- product_variants
- products
- product_images
- orders
- order_items
- brands
- categories
- carts
- cart_items
- promo_codes
src/
βββ api/
β βββ v1/
β βββ auth/
β βββ users/
β βββ products/
β βββ categories/
β βββ seller/
β βββ courier/
β βββ orders/
β βββ delivery/
βββ core/
β βββ config.py
β βββ security.py
βββ db/
β βββ session.py
β βββ base.py
β βββ models/
β βββ users.py
β βββ products.py
β βββ categories.py
β βββ brands.py
β βββ cart.py
β βββ orders.py
β βββ delivery.py
β βββ seller_profile.py
β βββ courier_profile.py
β βββ review.py
βββ services/
βββ media/- Clear separation between API, services, repositories, and database models
- Easy to extend and maintain
- Each domain (products, orders, delivery, etc.) is fully isolated
- Can be easily split into microservices (catalog, delivery, payments, etc.)
- High throughput thanks to async stack
- Perfect for realβtime tasks such as courier tracking
git clone https://github.com/RustamovAkrom/Marketplace-FastAPI.git
cd Marketplace-FastAPIDATABASE_URL=postgresql+asyncpg://user:pass@localhost/db
SECRET_KEY=your-secret-key
DEBUG=truepython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
pip install -r requirements.txtalembic upgrade headuvicorn src.main:app --reload --host 0.0.0.0 --port 8000http://localhost:8000/docs
Run all tests using:
pytest -vvAkrom β Backend developer passionate about scalable architecture, clean code, and modern engineering practices. Building a productionβready eβcommerce backend for real-world use and portfolio purposes.
MIT License
