项目
在 GitHub 查看
jujumilk3/fastapi-clean-architecture
关于
用于创建通用 API 的 FastAPI 基础项目。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文fastapi-clean-architecture
description
Base FastAPI project for applying general RestAPI Application cases.

concept
- Minimal functionality.
- Convincing architecture.
- Easy to read.
- Compatibility.
- Versatility.
base models
- user
- post [user (1 : n) post]
- tag [post (n : n) tag]
integrated with
- Python3.9+
- Fastapi 0.78.0
- Database
- MySQL5.7+
- Migration with alembic
- pytest with real DB
- Load with two ways (eager, lazy)
- Modeling with schema (1:1, 1:n, n:n)
- dependency-injector
- service-repository pattern
- JWT authentication
- role separation each endpoint
- Deployment
- container environment(k8s, docker)
- raw WAS(Web Application Server)
commands
- db(alembic)
alembic upgrade head: apply every migrationsalembic downgrade base: rollback every migrationsalembic revision --autogenerate -m "revision_name": create new migrationalembic history: get alembic revision history
- How to migration
- Create or modify models from
app/model/*.py alembic -x ENV=[dev|stage|prod] revision --autogenerate -m "revision_name"- Check auto generated migration file from
app/migrations/versions/*.py alembic -x ENV=[dev|stage|prod] upgrade head
If ENV does not exist, it will be applied to the test.
- Create or modify models from
- server
uvicorn app.main:app --reload: base- options
- host:
--host 0.0.0.0 - port:
--port 8000
- host:
- test
pytest: basepytest --cov=app --cov-report=term-missing: coverage with stdoutpytest --cov=app --cov-report=html: coverage with html
sample env
# mysql case
ENV=dev
DB=mysql
DB_USER=root
DB_PASSWORD=qwer1234
DB_HOST=localhost
DB_PORT=3306
# postgres case
ENV=dev
DB=postgresql
DB_USER=gyu
DB_PASSWORD=
DB_HOST=localhost
DB_PORT=5432
references
探索相关项目
加载中…