A scalable backend REST API built with FastAPI following Clean Architecture principles.
This project demonstrates how to structure a production-ready backend separating business logic, infrastructure, and presentation layers.
This project is based on Clean Architecture:
-
Domain Layer
- Core business rules
- Entities and Value Objects
- No external dependencies
-
Application Layer
- Use cases (business logic orchestration)
- DTOs and interfaces
- Service coordination
-
Infrastructure Layer
- Persistence implementation
- Storage handling
- Repository implementations
-
Presentation Layer
- FastAPI controllers
- Request/Response handling
- API routing
- Create product
- Get all products
- Get product by ID
- Delete product
- Domain validation using Value Objects
- Repository pattern
- Dependency injection (manual)
- Clean separation of concerns
- Python 3.10+
- FastAPI
- Pydantic
- Uvicorn
domain/ application/ infrastructure/ presentation/ main.py
git clone https://github.com/your-username/clean-python-fastapi.git cd clean-python-fastapi
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload
POST /products
GET /products
GET /products/{product_id}
DELETE /products/{product_id}
{ "id": 1, "name": "Laptop", "price": 1500, "stock": 10 }
{ "data": { "id": 1, "name": "Laptop", "price": 1500, "stock": 10 }, "message": "Product created successfully" }
This project was built to demonstrate:
- Scalable backend design
- Clean Architecture principles
- Separation of concerns
- Maintainable code structure
- Real-world backend patterns
Nimer Cerna Espinoza
Backend Developer (Python / .NET / PHP)
This project is for learning and portfolio demonstration purposes.