{"repo":"DimplesY/fastapi-ai-starter","free":true,"listed":false,"github":"https://github.com/DimplesY/fastapi-ai-starter","clone":"git clone https://github.com/DimplesY/fastapi-ai-starter.git","description":"🚀 现代化 FastAPI 项目模板 | Modern FastAPI template with Celery + PostgreSQL + Redis + Docker. Production-ready starter kit.","language":"Python","stars":34,"topics":["ai","celery","fastapi","postgresql","template"],"license":null,"category":"databases-storage","readme_excerpt":"FastAPI AI Starter 一个生产就绪的 FastAPI 项目模板，集成 Celery 异步任务、PostgreSQL/pgvector 和 Redis，适合构建 AI 应用。 特性 - 服务工厂架构 - 基于工厂模式的依赖注入系统，自动管理服务生命周期 - 异步全栈 - FastAPI + SQLModel 异步 ORM + Celery 任务队列 - AI 就绪 - PostgreSQL + pgvector 扩展，支持向量存储和搜索 - JWT 认证 - 完整的用户认证系统，密码 bcrypt 加密 - 自动迁移 - Alembic 数据库迁移，应用启动时自动执行 - 容器化部署 - Docker Compose + Nginx + Supervisord 技术栈 类别 技术 ------ ------ Web 框架 FastAPI, Starlette ORM SQLModel (Pydantic + SQLAlchemy) 任务队列 Celery + Redis 数据库 PostgreSQL 16 + pgvector 包管理 UV 代码质量 Ruff, MyPy, Pre-commit 日志 Loguru 快速开始 环境要求 - Python 3.12+ - Docker & Docker Compose 安装 启动服务 Docker Compose（推荐） 本地开发 访问 http://localhost:8000/docs 查看 API 文档。 项目结构 开发指南 数据库迁移 添加新服务 1. 在 app/services/ / 创建模块 2. 实现 service.py （继承 Service ）和 factory.py （继承 ServiceFactory ) 3. 在 ServiceType 枚举中添加类型 4. ServiceManager 自动发现并注册 添加 API 路由 1. 在 app/api/v1/ 创建路由文件 2. 在 app/api/router.py 中注册 添加 Celery 任务 1. 在 celery tasks/workers/ 创建任务 2. 在 celeryconfig.py 的 include 列表注册 代码检查 环境变量 变量 说明 ------ ------ ENVIRONMENT 运行环境 DATABASE URL 数据库连接 URL JWT SECRET JWT 密钥 架构说明 服务工厂模式 项目使用服务工厂模式管理依赖： - ServiceManager - 单例管理器，负责服务注册和创建 - ServiceFactory - 工厂基类，自动推断服务依赖关系 - Service - 服务基类，定义统一接口 服务通过依赖注入使用： 数据库 Session 应用启动时自动执行 Alembic 迁移。使用 injectable session scope 获取 session，自动处理提交和回滚。 License MIT","default_branch":null,"files":null,"tree":[],"storefront":"/r/DimplesY","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/DimplesY/fastapi-ai-starter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}