- uv 工程(Python 3.12,pyproject + uv.lock,dev: pytest/ruff) - 分层包结构:api / application / domain / infrastructure / quant(qlib_adapter) / agent / core - app.core.config:加载根 config.yaml + .env,sqlite 相对路径解析到项目根 data/ - SQLAlchemy Base + Session 工厂(Infrastructure 层,业务走 Repository) - Alembic 迁移环境就位(env.py 复用应用配置,render_as_batch 兼容 SQLite) - GET /api/health + pytest 冒烟 6 项通过 / ruff clean / uvicorn 启动验证
12 lines
422 B
Python
12 lines
422 B
Python
"""Repository Protocol(接口)。
|
|
|
|
业务层只依赖这里定义的 Protocol,例如:
|
|
|
|
class StockRepository(Protocol):
|
|
def get_by_symbol(self, symbol: str) -> Stock | None: ...
|
|
def list(self, filters: StockFilter) -> list[Stock]: ...
|
|
def save(self, stock: Stock) -> Stock: ...
|
|
|
|
具体实现放在 infrastructure/persistence 下(SQLite 当前实现,未来 MySQL 同接口)。
|
|
"""
|