fastapi-backend-template
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFastAPI Backend Template
FastAPI后端模板
FastAPI with PostgreSQL, async SQLAlchemy 2.0, Alembic migrations, and Docker.
集成FastAPI、PostgreSQL、异步SQLAlchemy 2.0、Alembic迁移工具和Docker的后端模板。
Tech Stack
技术栈
- Framework: FastAPI
- Language: Python
- ORM: SQLAlchemy 2.0 (async)
- Migrations: Alembic
- Database: PostgreSQL
- 框架: FastAPI
- 编程语言: Python
- 对象关系映射: SQLAlchemy 2.0 (异步)
- 迁移工具: Alembic
- 数据库: PostgreSQL
Prerequisites
前置要求
- Python 3.11+
- Docker (recommended)
- PostgreSQL
- Python 3.11及以上版本
- Docker(推荐使用)
- PostgreSQL
Setup
环境搭建
1. Clone the Template
1. 克隆模板
bash
git clone --depth 1 https://github.com/Aeternalis-Ingenium/FastAPI-Backend-Template.git .If the directory is not empty:
bash
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_templatebash
git clone --depth 1 https://github.com/Aeternalis-Ingenium/FastAPI-Backend-Template.git .如果目标目录非空:
bash
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_template2. Remove Git History (Optional)
2. 移除Git历史记录(可选)
bash
rm -rf .git
git initbash
rm -rf .git
git init3. Setup Virtual Environment
3. 搭建虚拟环境
bash
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txtbash
python -m venv venv
source venv/bin/activate # Windows系统请使用 venv\Scripts\activate
pip install -r requirements.txt4. Setup Database
4. 配置数据库
Configure PostgreSQL and run Alembic migrations.
配置PostgreSQL并运行Alembic迁移命令。
Development
开发运行
bash
uvicorn main:app --reloadbash
uvicorn main:app --reload