A production-ready template for building scalable API microservices following best practices and clean architecture principles.
- Modular API routing with versioning
- Built-in authentication and authorization
- Database agnostic with support for multiple databases
- Standardized error handling and responses
- Comprehensive logging and monitoring
- Docker and Kubernetes ready
- Testing framework with pytest
- OpenAPI documentation
service-name/
├── app/ # Application core
│ ├── api/ # API endpoints and routers
│ ├── core/ # Core configurations
│ ├── models/ # Database models
│ ├── schemas/ # Request/response schemas
│ ├── services/ # Business logic
│ └── utils/ # Utilities and helpers
├── tests/ # Test suite
├── scripts/ # Operational scripts
└── docs/ # Documentation
- API Layer: Route definitions and request handling
- Core: Application configuration and essential setup
- Models: Database structure definitions
- Schemas: Data validation and serialization
- Services: Business logic implementation
- Utils: Shared utilities and helpers
- Clone template
- Configure environment variables
- Add domain-specific models, schemas, and services
- Implement business logic
- Run tests and deploy
- Add new domains under
api/v1/endpoints/
- Extend models and schemas for specific needs
- Implement custom services
- Configure database connections
- Add middleware as needed
- Keep endpoints thin
- Move logic to services
- Use dependency injection
- Maintain consistent error handling
- Document interfaces
- Follow test-driven development