first commit

This commit is contained in:
debu-2 2026-10-03 21:14:44 +05:30
commit cce9a8c9ba
73 changed files with 8665 additions and 0 deletions

27
backend/app/database.py Normal file
View file

@ -0,0 +1,27 @@
from collections.abc import AsyncIterator
from pymongo import AsyncMongoClient
from sqlalchemy.ext.asyncio import (
AsyncSession,
async_sessionmaker,
create_async_engine,
)
from app.config import get_settings
settings = get_settings()
engine = create_async_engine(settings.database_url, pool_pre_ping=True)
SessionFactory = async_sessionmaker(engine, expire_on_commit=False)
mongo_client: AsyncMongoClient = AsyncMongoClient(settings.mongo_url)
mongo_db = mongo_client[settings.mongo_database]
async def get_postgres_session() -> AsyncIterator[AsyncSession]:
async with SessionFactory() as session:
yield session
def get_mongo_database():
return mongo_db