Automated Action 07f6a51f6f Add complete FastAPI backend for AI tutor application
- User authentication with JWT tokens (register/login)
- Tutor session management with CRUD operations
- Message tracking for tutor conversations
- SQLite database with Alembic migrations
- CORS configuration for frontend integration
- Health check and service info endpoints
- Proper project structure with models, schemas, and API routes
2025-06-23 17:55:19 +00:00

23 lines
521 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()