debate/.planning/phases/01-core-infrastructure-security/01-01-PLAN.md
Mikkel Georgsen 262a32673b docs(01): create phase plan
Phase 01: Core Infrastructure & Security
- 5 plans in 3 waves
- 3 parallel (Wave 1-2), 1 sequential (Wave 3)
- Ready for execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:59:49 +00:00

6.1 KiB

phase plan type wave depends_on files_modified autonomous must_haves
01-core-infrastructure-security 01 execute 1
pyproject.toml
backend/app/__init__.py
backend/app/main.py
backend/app/core/__init__.py
backend/app/core/config.py
backend/app/api/__init__.py
backend/app/api/v1/__init__.py
backend/app/api/v1/router.py
backend/app/api/v1/endpoints/__init__.py
backend/app/api/v1/endpoints/health.py
.env.example
true
truths artifacts key_links
FastAPI app starts without errors
Health endpoint returns 200 OK
Configuration loads from environment variables
Project dependencies install via uv
path provides contains
pyproject.toml Project configuration and dependencies fastapi
path provides exports
backend/app/main.py FastAPI application entry point
app
path provides contains
backend/app/core/config.py Application configuration via pydantic-settings BaseSettings
path provides contains
backend/app/api/v1/endpoints/health.py Health check endpoint @router.get
from to via pattern
backend/app/main.py backend/app/api/v1/router.py include_router app.include_router
from to via pattern
backend/app/api/v1/router.py backend/app/api/v1/endpoints/health.py include_router router.include_router
Establish the FastAPI backend project structure with configuration management and basic health endpoint.

Purpose: Create the foundational Python project that all subsequent infrastructure builds upon. Output: A runnable FastAPI application with proper project structure, dependency management via uv, and environment-based configuration.

<execution_context> @/home/mikkel/.claude/get-shit-done/workflows/execute-plan.md @/home/mikkel/.claude/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/phases/01-core-infrastructure-security/01-RESEARCH.md (Standard Stack section, Architecture Patterns section) Task 1: Initialize Python project with uv and dependencies pyproject.toml, .env.example Create pyproject.toml with: - Project name: debate-backend - Python version: >=3.12 - Dependencies from research standard stack: - fastapi[all]>=0.128.0 - uvicorn[standard]>=0.30.0 - sqlalchemy[asyncio]>=2.0.0 - asyncpg<0.29.0 - alembic - pydantic>=2.12.0 - pydantic-settings - slowapi - fastapi-csrf-protect - python-multipart - Dev dependencies: - pytest - pytest-asyncio - pytest-cov - httpx - ruff - mypy

Configure ruff in pyproject.toml:

  • line-length = 88
  • target-version = "py312"
  • select = ["E", "F", "I", "N", "W", "UP"]

Create .env.example with documented environment variables:

  • DATABASE_URL (postgresql+asyncpg://...)
  • SECRET_KEY (for JWT/CSRF)
  • ENVIRONMENT (development/production)
  • DEBUG (true/false)
  • ALLOWED_HOSTS (comma-separated)
  • ALLOWED_ORIGINS (comma-separated, for CORS)

Initialize project with uv: uv venv && uv pip install -e ".[dev]" Run: cd /home/mikkel/repos/debate && uv pip list | grep -E "(fastapi|uvicorn|sqlalchemy|pydantic)" Expected: All core dependencies listed with correct versions. pyproject.toml exists with all specified dependencies, virtual environment created, packages installed.

Task 2: Create FastAPI application structure with health endpoint backend/app/__init__.py backend/app/main.py backend/app/core/__init__.py backend/app/core/config.py backend/app/api/__init__.py backend/app/api/v1/__init__.py backend/app/api/v1/router.py backend/app/api/v1/endpoints/__init__.py backend/app/api/v1/endpoints/health.py Create directory structure following research architecture: ``` backend/ app/ __init__.py main.py core/ __init__.py config.py api/ __init__.py v1/ __init__.py router.py endpoints/ __init__.py health.py ```

backend/app/core/config.py:

  • Use pydantic-settings BaseSettings
  • Load: database_url, secret_key, environment, debug, allowed_hosts, allowed_origins
  • Parse allowed_hosts and allowed_origins as lists (comma-separated in env)
  • Set sensible defaults for development

backend/app/main.py:

  • Create FastAPI app with title="Debate API", version="1.0.0"
  • Disable docs in production (docs_url=None if production)
  • Include v1 router at /api/v1 prefix
  • Add basic health endpoint at root /health (outside versioned API)

backend/app/api/v1/router.py:

  • Create APIRouter
  • Include health endpoint router with prefix="/health", tags=["health"]

backend/app/api/v1/endpoints/health.py:

  • GET /health returns {"status": "healthy"}
  • GET /health/ready for readiness check (will add DB check in next plan)

All init.py files should be empty (or contain only necessary imports). Run: cd /home/mikkel/repos/debate && source .venv/bin/activate && uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 & Wait 2 seconds, then: curl -s http://localhost:8000/health | grep -q healthy && echo "Health check passed" Kill the server. FastAPI application starts, health endpoint returns {"status": "healthy"}.

1. `uv pip list` shows all dependencies at correct versions 2. `ruff check backend/` passes with no errors 3. `uvicorn backend.app.main:app` starts without errors 4. `curl http://localhost:8000/health` returns 200 with {"status": "healthy"} 5. `curl http://localhost:8000/api/v1/health` returns 200

<success_criteria>

  • FastAPI backend structure exists following research architecture
  • All dependencies installed via uv
  • Health endpoint responds at /health
  • Configuration loads from environment (or .env file)
  • ruff passes on all code </success_criteria>
After completion, create `.planning/phases/01-core-infrastructure-security/01-01-SUMMARY.md`