FastAPI Best Architecture
English | 简体中文
A backend and frontend separation solution based on the FastAPI framework, following the pseudo 3-tier architecture design, supporting Python 3.10 and above versions
🔥Continuously updated and maintained🔥
Note
This repository as a template library open to any person or enterprise can be used for free!
Pseudo 3-tier architecture
The mvc architecture is a common design pattern in python web, but the 3-tier architecture is even more fascinating
In python web development, there is no common standard for the concept of 3-tier architecture, so we'll call it a pseudo 3-tier architecture here
But please note that we don't have a traditional multi-app structure (django, springBoot...) If you don't like this pattern, use templates to transform it to your heart's content!
| workflow | java | fastapi_best_architecture |
|---|---|---|
| view | controller | api |
| data transmit | dto | schema |
| business logic | service + impl | service |
| data access | dao / mapper | crud |
| model | model / entity | model |
Features
- Design with FastAPI PEP 593 Annotated Parameters
- Global asynchronous design with async/await + asgiref
- Follows Restful API specification
- Global SQLAlchemy 2.0 syntax
- Pydantic v1 and v2 (different branches)
- Casbin RBAC access control model
- Role menu RBAC access control model
- Celery asynchronous tasks
- JWT middleware whitelist authentication
- Global customizable time zone time
- Docker / Docker-compose deployment
- Pytest Unit Testing
Built-in features
- User management: System User Role Management, Permission Allocation
- Department management: Configure system organization (company, department, team...)
- Menu management: Configure system menu, user menu, button permission tags
- Role management: role menu permission allocation, role route permission allocation
- Dictionary management: Maintain commonly used fixed data or parameters within the system
- Token management: System user online status detection, supports kicking users offline
- Login authentication: backend-based graphical captcha background authentication login
- Multipoint login: One-click modification of multipoint login through user information
- OAuth 2.0: Built-in self-developed OAuth 2.0 login integration
- Code generation: automatic backend code generation, supports preview, writing, and download
- Scheduled task: Automated task, asynchronous task, supports function calls
- Plugin system: Say goodbye to high coupling integration through hot-pluggable plugin mode
- Operation log: Record and query of system normal and abnormal operations
- Login log: Record and query of normal and abnormal user login
- Service monitoring: Server hardware device information and status
- API documentation: Automatically generate online interactive API documentation
Development and deployment
For more details, please check the official documentation
Contributors
Special thanks
Interactivity
Sponsor us
If this program has helped you, you can sponsor us with some coffee beans: ☕ Sponsor ☕
License
This project is licensed by the terms of the MIT license