Initial commit for resumeformatter project

This commit is contained in:
Laxmi Khilnani
2025-10-14 19:51:35 +05:30
commit ee030b70bc
43 changed files with 1668 additions and 0 deletions

3
backend/app/db/base.py Normal file
View File

@@ -0,0 +1,3 @@
# Import all the models, so that Base has them before being imported by Alembic
from app.db.base_class import Base # noqa
from app.models.person import Person # noqa

View File

@@ -0,0 +1,13 @@
from typing import Any
from sqlalchemy.ext.declarative import as_declarative, declared_attr
@as_declarative()
class Base:
id: Any
__name__: str
# Generate __tablename__ automatically based on class name
@declared_attr
def __tablename__(cls) -> str:
return cls.__name__.lower()

19
backend/app/db/session.py Normal file
View File

@@ -0,0 +1,19 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.db.base_class import Base
# Use a file-based SQLite database instead of in-memory
SQLALCHEMY_DATABASE_URL = "sqlite:///./ResumeFormatter.db"
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# Dependency to get DB session
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()