Files
2026-04-24 17:46:03 +08:00

1.3 KiB
Raw Permalink Blame History

Loom Backend

FastAPI + SQLAlchemy 2.0 (async) + Celery + PostgreSQL + Redis。

本地开发

# 1. 创建虚拟环境并安装依赖
python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

# 2. 配置(根目录 .env 由 .env.example 复制)
# 生成 APP_SECRET_KEY:openssl rand -hex 32
# 生成 FERNET_KEY:python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# 3. 起 pg/redis
docker compose -f ../docker-compose.yml up -d postgres redis

# 4. 跑迁移(P1 暂无迁移文件,可跳过)
alembic upgrade head

# 5. 启动
uvicorn app.main:app --reload

# 6. 检查
open http://localhost:8000/api/v1/healthz
open http://localhost:8000/docs

测试

pytest

目录

app/
├── main.py              FastAPI 入口
├── core/                配置、日志、异常、JWT、依赖
├── db/                  SQLAlchemy 引擎 & Base
├── api/v1/              REST 路由
├── models/              ORM(P2 起)
├── schemas/             Pydantic DTO(P2 起)
├── services/            业务服务(P2 起)
├── tasks/               Celery 任务(P5 起)
├── integrations/        Lobster / OpenAI 客户端(P4/P6)
└── utils/