View all files | ||||
A lightweight, modular FastAPI application for order management.
Built as a modular monolith, the project organizes code by domain (e.g., orders, users) rather than by technical layers alone. It uses PostgreSQL for data storage, Alembic for schema migrations, and SQLite for fast, isolated unit tests. The application is containerized with Docker for consistent local development and deployment.
This structure keeps concerns well-defined in a monolithic codebase while encouraging boundaries that translate well to microservices, without introducing that complexity prematurely.
The codebase follows a domain-oriented structure combined with the Service Layer and Repository patterns. Each module (e.g., orders, users) is self-contained and implements a consistent internal layout:
| routes | HTTP interface (request/response handling, validation entrypoints) |
| service | Business logic and orchestration (Service Layer pattern) |
| repository | Data access abstraction over the database |
| models | Database models (ORM entities) |
| schemas | API contracts (input/output validation and serialization) |
Key characteristics:
The design prioritizes clarity, testability, and maintainability, while remaining flexible enough to evolve into a distributed architecture if needed.
This will spin up two containers:
API will be available at:
Swagger UI at:
| make help | List all available commands |
| make build | Build the Docker container |
| make run | Run the app (development with auto-reload) |
| make stop | Stop the app |
| make clean | Clean up Docker containers and volumes |
| make test | Run all tests |
| make test-unit | Run unit tests |
| make test-integration | Run integration tests |
| make migrations msg=<msg> | Generate alembic migrations |