feat (infra): Trae 完成 asset_helper_backend 微服务基础架构 V1 初始化

核心实现:搭建 Monorepo 架构,完成 shared 共享包、gateway、user-service 基础框架开发
技术落地:严格匹配指定技术栈版本,完成 Docker、gRPC、FastAPI、PostgreSQL、Redis 等配置,实现服务间基础连通
配套文件:生成 Makefile、环境变量模板、数据库 / 脚本初始化文件及启动验证文档
架构定位:仅搭建基础架构骨架,无任何业务逻辑、业务规则及业务相关字段,为后续业务开发提供支撑
This commit is contained in:
fish
2026-03-27 20:38:10 +08:00
parent 1ad8ec9be5
commit 3f4165fe78
44 changed files with 1407 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
from shared.models import BaseDBModel
from sqlalchemy import Column, String
class User(BaseDBModel):
__tablename__ = "users"
username = Column(String, unique=True, index=True, nullable=False)
password_hash = Column(String, nullable=False)

View File

@@ -0,0 +1,16 @@
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from services.user_service.app.core.config import settings
# 注意:这里使用 user_db 数据库
DATABASE_URL = f"postgresql+asyncpg://user_service:password@postgres:5432/user_db"
engine = create_async_engine(DATABASE_URL)
AsyncSessionLocal = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async def get_db():
async with AsyncSessionLocal() as session:
try:
yield session
finally:
await session.close()