fastapp-cli
FastAPI 项目脚手架:一条命令生成完整、可直接运行的 FastAPI 工程。
fastapp create my-server
特性
- 分层架构:
api / schemas / crud / services / models分层,内置泛型 CRUD / Service 基类 - 开箱即用的工程能力:统一响应 / 异常体系、TraceID 中间件、loguru 日志、pydantic-settings 多环境配置
- 分页 CRUD + 过滤:基于 fastapi-pagination 与 fastapi-filter 的完整示例(
/api/v1/items) - Celery 可选:
--celery启用时生成完整任务骨架(默认 redis broker,本地无 redis 时启动自动降级memory://并告警);默认不启用 - Alembic 迁移:接入 SQLModel.metadata,含 autogenerate 过滤钩子
- 优雅降级:MySQL 缺席不阻塞启动,
/api/v1/health返回database: up/down - 工程化配套:Makefile、scripts/、pre-commit、ruff + mypy + pytest 配置全套
- 可选部署文件:
--pm2/--docker按需生成(pm2.config.js,celery 未启用时对应启动命令自动注释) - AI Agent 友好:生成项目自带
docs/agent_guide.md开发参考文档(架构、核心方法清单、扩展流程)
安装
# uv tool(推荐)
uv tool install fastapp-cli
# 或 pipx
pipx install fastapp-cli
# 或一次性使用
uvx fastapp create demo
使用
fastapp create <project_name> [options]
| 参数 | 默认 | 说明 |
|---|---|---|
project_name |
必填 | 项目名;小写字母/数字/连字符,如 my-server |
--description |
交互提问 | 项目描述 |
--pm2 / --no-pm2 |
交互提问 | 是否生成 pm2.config.js |
--docker / --no-docker |
交互提问 | 是否生成 Dockerfile |
--celery / --no-celery |
交互提问(默认不启用) | 是否启用 Celery 异步任务 |
--python |
3.12 |
目标 Python 版本(写入 .python-version) |
--author |
git config user.name |
作者署名 |
--force |
关 | 目标目录已存在时覆盖重建 |
--no-git |
关 | 跳过 git init |
全部关键项通过 flag 提供时零交互:
fastapp create my-server --description "demo" --no-pm2 --no-docker --no-celery
生成完成后:
cd my-server && uv sync
make dev # 访问 /api/v1/docs
生成项目依赖
fastapi、sqlmodel、alembic、fastapi-pagination、fastapi-filter、loguru、pydantic-settings 等,dev 组含 pytest / ruff / mypy / pre-commit;--celery 启用时额外引入 celery[redis] 与 flower。
开发 fastapp-cli 自身
uv sync --group dev
uv run pytest # 单元 + 冒烟测试
uv run ruff check .
发布
uv build # 构建 sdist + wheel(模板随包发布)
uv publish # 发布到 PyPI
版本策略:v0.1.0 起,语义化版本。
Metadata
Release files for fastapp-cli 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapp_cli-0.4.0.tar.gz | 91.2 kB | Without provenance | Details for fastapp_cli-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapp_cli-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for fastapp_cli-0.4.0-py3-none-any.whl |
Total release size: 159.9 kB
Release files / fastapp_cli-0.4.0.tar.gz
| Download URL | fastapp_cli-0.4.0.tar.gz |
|---|---|
| Size | 91.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a97bcfd4fdc033c2465994a6b41112e5b1f28474aeb3496159fdeba8c0340964
|
|
BLAKE2b-256 checksum How to use checksums |
bb15cc80a85c419e94d9e30b9f0b983847975d2efe7c0603fb77bf78e99917f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fastapp_cli-0.4.0-py3-none-any.whl
| Download URL | fastapp_cli-0.4.0-py3-none-any.whl |
|---|---|
| Size | 68.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1418ab6febc9063321a1fe3b6c93451ca8b8f0e81ca1df632734ad4328389279
|
|
BLAKE2b-256 checksum How to use checksums |
94e02f616a207b88289b65ca4369c1fff3f132d118ef4546a67b0fc844b7817e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for fastapp-cli 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.