initial project structure

This commit is contained in:
Sean McElwain 2026-03-31 20:45:15 -05:00
commit 8b3b4f968a
11 changed files with 80 additions and 0 deletions

0
.env.example Normal file
View File

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
# Python
.venv/
__pycache__/
*.pyc
# Env
.env
# Data (local only)
data/
# Alembic cache
alembic/versions/*.pyc

0
README.md Normal file
View File

9
app/core/config.py Normal file
View File

@ -0,0 +1,9 @@
import os
from dotenv import load_dotenv
load_dotenv()
class Settings:
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql://user:pass@localhost:5432/document_processor")
settings = Settings()

6
app/db/base.py Normal file
View File

@ -0,0 +1,6 @@
from sqlalchemy.orm import declarative_base
Base = declarative_base()
# import models so Alembic sees them later
from app.models import document # noqa

14
app/db/session.py Normal file
View File

@ -0,0 +1,14 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
engine = create_engine(settings.DATABASE_URL, echo=True)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()

10
app/main.py Normal file
View File

@ -0,0 +1,10 @@
from fastapi import FastAPI
from app.routes.health import router as health_router
app = FastAPI()
app.include_router(health_router)
@app.get("/")
def root():
return {"app": "document-processor", "status": "running"}

12
app/models/document.py Normal file
View File

@ -0,0 +1,12 @@
from sqlalchemy import Column, Integer, String, DateTime
from datetime import datetime
from app.db.base import Base
class Document(Base):
__tablename__ = "documents"
id = Column(Integer, primary_key=True, index=True)
file_path = Column(String, nullable=False)
status = Column(String, default="pending")
created_at = Column(DateTime, default=datetime.utcnow)

11
app/routes/health.py Normal file
View File

@ -0,0 +1,11 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter()
@router.get("/health/db")
def db_health(db: Session = Depends(get_db)):
db.execute("SELECT 1")
return {"status": "ok"}

0
pyproject.toml Normal file
View File

5
run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
source .venv/bin/activate
uvicorn app.main:app --reload --host 0.0.0.0 --port 3004