mcpField
F
fastapi-backend-template

fastapi-backend-template

github.com/rebyteai-template开发17238 次安装19 周前更新
代码仓库

关于 fastapi-backend-template

面向 Python 项目的 FastAPI 后端模板,集成 PostgreSQL、异步 SQLAlchemy 2.0、Alembic 和 Docker。可作为构建 API 并管理数据库迁移的起点。

主要功能

  1. 01FastAPI 应用基础结构
  2. 02PostgreSQL 数据库配置
  3. 03异步 SQLAlchemy 2.0 集成
  4. 04支持 Alembic 迁移
  5. 05提供 Docker 配置指引

适用场景

  1. 01启动 Python API 项目
  2. 02构建由 PostgreSQL 支持的 API
  3. 03使用迁移管理数据库结构变更

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/rebyteai-template/rebyte-skills --skill fastapi-backend-template

安装后在 Claude Code 中输入/fastapi-backend-template确认已加载。

详细介绍

FastAPI 后端模板

使用 PostgreSQL、异步 SQLAlchemy 2.0、Alembic 迁移和 Docker 的 FastAPI。

技术栈

  • 框架:FastAPI
  • 语言:Python
  • ORM:SQLAlchemy 2.0(异步)
  • 迁移:Alembic
  • 数据库:PostgreSQL

前置条件

  • Python 3.11+
  • Docker(推荐)
  • PostgreSQL

设置

1. 克隆模板
git clone --depth 1 https://github.com/Aeternalis-Ingenium/FastAPI-Backend-Template.git .

如果目录不为空:

git clone --depth 1 https://github.com/Aeternalis-Ingenium/FastAPI-Backend-Template.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template
2. 移除 Git 历史(可选)
rm -rf .git
git init
3. 设置虚拟环境
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt
4. 设置数据库

配置 PostgreSQL 并运行 Alembic 迁移。

开发

uvicorn main:app --reload

评论

支持 Markdown