first commit

This commit is contained in:
Anurag Jangid 2026-10-08 02:50:35 +05:30
commit 7a72438fd1
74 changed files with 7548 additions and 0 deletions

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

@ -0,0 +1,39 @@
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorGridFSBucket
from pymongo.server_api import ServerApi
from app.config import get_settings
settings = get_settings()
client: AsyncIOMotorClient = None
db = None
gridfs_bucket: AsyncIOMotorGridFSBucket = None
async def connect_db():
global client, db, gridfs_bucket
client = AsyncIOMotorClient(
settings.mongodb_uri,
server_api=ServerApi("1"),
)
db = client[settings.mongodb_db]
gridfs_bucket = AsyncIOMotorGridFSBucket(db, bucket_name="resumes")
# Ping to verify connection
await client.admin.command("ping")
print(f"[OK] Connected to MongoDB: {settings.mongodb_db}")
async def close_db():
global client
if client:
client.close()
print("[CLOSED] MongoDB connection closed")
def get_db():
return db
def get_gridfs():
return gridfs_bucket