Production-grade upgrade: modular monolith, hardening, deploy & CI#1
Merged
Conversation
… 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
added a commit
that referenced
this pull request
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-moduleservice.pytaking anAsyncSessionexplicitly.app/api/v1/router.pyaggregates module routers (kept, per request, like the Noderoutes/v1pattern).modules/usersownsUser/Role;modules/authownsRefreshToken, 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 whenENVIRONMENT=production.Deploy & CI
Dockerfile,docker-compose.yml(api + postgres, migrations auto-applied).requirements-dev.txtsplit; 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.1hashing.Deliberately not added (lean): Redis, email flows, OAuth, HTTP clients, background workers — documented as extension points.
Verification
ruff check .— cleanmypy app --ignore-missing-imports— clean (35 files)pytest— 19 passed, 85% coveragealembic upgrade head— applies on sqliteuvicornboot confirmed:/health/readypings DB, security +X-Request-IDheaders present,/docsrenders🤖 Generated with Claude Code