feat: add FastAPI backend with SQLite models and Docker setup

Implement milestone M2 (backend setup):

- FastAPI app factory (core/app.py) with CORS, lifespan table
  creation, and global error handlers using a standardized
  {detail, code, errors?} envelope
- Endpoints: GET /health, GET /api/v1/health, GET /api/v1/version
- SQLAlchemy 2.0 ORM: Article, Author, Category models with
  relationships, unique constraints, and FK pragma for SQLite
- Pydantic v2 schemas (create/update/read) for all models
- Env-driven config (DATABASE_URL, CORS_ORIGINS) + .env.example
- pytest suite (19 tests, ~95% coverage) with per-test SQLite
  databases via fixtures
- Dockerfile (python:3.11-slim) and docker-compose.yml with a
  persistent ./data/db volume and healthcheck
This commit is contained in:
Daniel Samson committed 2026-10-30 12:44:54 +00:00
1 parent 357a72114b
commit 9a6f75ebd8
32 files changed
+1465 -1

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
FROM python:3.11-slim
WORKDIR /app
# Install dependencies first to leverage Docker layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# SQLite database lives on a mounted volume (see docker-compose.yml)
VOLUME /app/data/db
# Expose port
EXPOSE 8000
# Run application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]