feat: Initialize FastAPI AI Gateway project structure with authentication, module management, and LLM API routing.

This commit is contained in:
2026-01-28 03:24:04 +08:00
commit b88dfec5fd
26 changed files with 1691 additions and 0 deletions

24
app/core/database.py Normal file
View File

@@ -0,0 +1,24 @@
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
# For development, we can use SQLite if DATABASE_URL is not set or for simplicity
# But we'll follow the user's request for PostgreSQL
SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL or "sqlite:///./sql_app.db"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
# check_same_thread is only needed for SQLite
**({"connect_args": {"check_same_thread": False}} if "sqlite" in SQLALCHEMY_DATABASE_URL else {})
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()