Skip to content

Production-grade upgrade: modular monolith, hardening, deploy & CI#1

Merged
Nate-Soul merged 4 commits into
mainfrom
feat/production-grade-upgrade
Jul 11, 2026
Merged

Production-grade upgrade: modular monolith, hardening, deploy & CI#1
Nate-Soul merged 4 commits into
mainfrom
feat/production-grade-upgrade

Conversation

@Nate-Soul

Copy link
Copy Markdown
Owner

Summary

Upgrades the boilerplate from the legacy year-old starter into a lean, production-grade template aligned with Arc's canonical FastAPI architecture and the conventions proven across four production backends.

What changed

Structure — layered → modular monolith

  • app/{core,common,infrastructure,modules} with a service layer: routes are thin, business logic lives in per-module service.py taking an AsyncSession explicitly.
  • Central app/api/v1/router.py aggregates module routers (kept, per request, like the Node routes/v1 pattern).
  • modules/users owns User/Role; modules/auth owns RefreshToken, token logic, and auth dependencies.

Core hardening (closes two Arc-standard gaps)

  • SecurityHeadersMiddleware — HSTS (prod), CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy.
  • RequestIDMiddleware (X-Request-ID) + structlog structured logging.
  • /health (liveness) and /health/ready (DB-pinging readiness); lifespan disposes the engine; docs disabled when ENVIRONMENT=production.

Deploy & CI

  • Non-root Dockerfile, docker-compose.yml (api + postgres, migrations auto-applied).
  • GitHub Actions: ruff, mypy, migrations, pytest (70% coverage gate), docker build against real Postgres.
  • requirements-dev.txt split; ops scripts (create_super_admin, seed).

Preserved as-is: refresh-token rotation + family-reuse revocation, algorithm-pinned JWTs, error envelope, UUID PKs + soft delete, passlib+bcrypt<4.1 hashing.

Deliberately not added (lean): Redis, email flows, OAuth, HTTP clients, background workers — documented as extension points.

Verification

  • ruff check . — clean
  • mypy app --ignore-missing-imports — clean (35 files)
  • pytest — 19 passed, 85% coverage
  • alembic upgrade head — applies on sqlite
  • Live uvicorn boot confirmed: /health/ready pings DB, security + X-Request-ID headers present, /docs renders
  • Docker build not run locally (no daemon) — CI covers it

🤖 Generated with Claude Code

Nate-Soul and others added 4 commits July 11, 2026 19:53
… hardening

Reorganize the layered app (api/models/schemas/db) into Arc's canonical
modular-monolith layout: core/ + common/ + infrastructure/ + modules/{auth,users}.
Routes become thin; business logic moves to per-module service.py taking an
AsyncSession explicitly. A central app/api/v1/router.py aggregates module routers.

Also closes two Arc-standard gaps and adds observability:
- SecurityHeadersMiddleware (HSTS/CSP/X-Frame/nosniff/Referrer/Permissions)
- RequestIDMiddleware (X-Request-ID) + structlog structured logging
- /health (liveness) and /health/ready (DB-pinging readiness)
- lifespan (dispose engine on shutdown); docs disabled when ENVIRONMENT=production

Alembic env + init migration updated to the new model paths and GUID import.
Removes legacy year-old scaffolding (flat app/, public/fonts, .vscode, mock.db).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Update conftest to the new infrastructure import paths; split tests into
unit/ and integration/. Add auth service-layer unit tests and health/
security-header/request-id integration tests. 19 tests, 85% coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ripts

Non-root Dockerfile + compose (api + postgres, migrations auto-applied).
GitHub Actions CI runs ruff, mypy, migrations, pytest (70% gate), docker build
against a real Postgres service. Split requirements-dev.txt from requirements.txt.
Add scripts/create_super_admin.py and scripts/seed.py (idempotent).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Document the modular-monolith layout, service-layer pattern, Docker/CI usage,
"adding a module" flow, and extension points (Redis/email/OAuth/tasks) kept
intentionally out of the lean starter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Nate-Soul
Nate-Soul merged commit 0c21ef9 into main Jul 11, 2026
1 check passed
@Nate-Soul
Nate-Soul deleted the feat/production-grade-upgrade branch July 11, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant