[!NOTE] This repository as a template library open to any person or enterprise can be used for free!
English | ็ฎไฝไธญๆ
FastAPI framework based on the front-end and back-end separation of the middle and back-end solutions, follow the pseudo three-tier architecture design, support for python3.10 and above versions
๐ฅContinuously updated and maintained๐ฅ
The mvc architecture is a common design pattern in python web, but the three-tier architecture is even more fascinating
In python web development, there is no common standard for the concept of three-tier architecture, so we'll call it a pseudo three-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 |
You can view some of the preview screenshots in fastapi_best_architecture_ui
Luckily, we now have a demo site: FBA UI
tester: test / 123456
super: admin / 123456
โโ๐ backend--------------- # Backend
โโโโ๐ alembic------------- # DB migration
โโโโ๐ app----------------- # Application
โโโโโโ๐ admin------------- # System admin
โโโโโโโโ๐ api------------- # Interface
โโโโโโโโ๐ crud------------ # CRUD
โโโโโโโโ๐ model----------- # SQLA model
โโโโโโโโ๐ schema---------- # Data transmit
โโโโโโโโ๐ service--------- # Service
โโโโโโโโ๐ tests----------- # Pytest
โโโโโโ๐ generator--------- # Code generate
โโโโโโ๐ task-------------- # Celery task
โโโโ๐ common-------------- # public resources
โโโโ๐ core---------------- # Core configuration
โโโโ๐ database------------ # Database connection
โโโโ๐ log----------------- # Log
โโโโ๐ middleware---------- # Middlewares
โโโโ๐ scripts------------- # Scripts
โโโโ๐ sql----------------- # SQL files
โโโโ๐ static-------------- # Static files
โโโโ๐ templates----------- # Template files
โโโโ๐ utils--------------- # Toolkit
โโ๐ deploy---------------- # Server deployment
For more details, please check the official documentation
Initialize the test data using the backend/sql/init_test_data.sql
file.
(For reference only)
Execute unit tests through pytest
.
fba_test
with utf8mb4 encodingbackend/sql/create_tables.sql
filebackend/sql/init_pytest_data.sql
fileGo to the backend
directory and execute the test commands.
cd backend/
pytest -vs --disable-warnings
If this program has helped you, you can sponsor us with some coffee beans: :coffee: Sponsor :coffee:
This project is licensed by the terms of the MIT license