r/coolgithubprojects • • 2d ago

fastapi-prod-ready – A Claude Code skill that audits FastAPI + PostgreSQL prototypes before going to production

https://github.com/tuvatechvalley/fastapi-prod-ready

Hey! I built this open-source Claude Code skill after seeing how often FastAPI prototypes work fine for one user locally, then run into trouble once real traffic hits.

It targets FastAPI + PostgreSQL + SQLAlchemy (async) + Alembic apps and audits your existing codebase without asking for a full rewrite. It also includes three focused checks you can run on their own:

- `backend-review` – full pre-launch audit with a readable report

- `concurrency-check` – catches things that break when multiple users hit the app at once

- `migration-review` – checks Alembic/Postgres migrations for locking or downtime risks

Happy to hear any feedback or edge cases you think should be added!

0 Upvotes

5 comments sorted by

2

u/Yarail 2d ago

Nice idea, especially the migration-review and concurrency checks. The thing that bit me hardest in FastAPI prod was accidentally running sync DB calls or blocking IO inside async def routes and starving the event loop under load, plus forgetting to tune SQLAlchemy pool sizes and timeouts. Checking for those would be super useful if it's not already in there.

1

u/-UniK-0 2d ago

Thanks! Glad those two stood out — migration locks and concurrency bugs are usually the hardest ones to spot just by eyeballing a PR.

Good news is both blocking IO / sync calls inside `async def` routes and SQLAlchemy pool hygiene + timeouts are already covered in the checks. Pool timeouts especially get overlooked all the time because default settings look completely fine until the DB slows down or traffic spikes.

If you end up running it on a project and notice any specific SQLAlchemy pool or timeout config it could be stricter about, feel free to open an issue or drop a note — always looking to sharpen the rules with real prod lessons.

1

u/avalexva 2d ago

Nice tool, the migration-lock angle is underrated. Three edge cases from real prod incidents that would fit your checks:

  1. Lazy-loaded relationships in async SQLAlchemy. Accessing a relationship without selectinload raises MissingGreenlet at runtime, and it only shows up on the code path that touches it. An AST check for relationship() fields that are accessed but never eager-loaded in the same query would catch the most common async crash there is.
  2. CORS misconfig: allow_origins=["*"] combined with allow_credentials=True. Browsers actually reject this combo, so it silently breaks auth in prod while looking fine in local testing with curl. Easy AST check on the CORSMiddleware kwargs.
  3. No statement_timeout set on the Postgres side. One bad query from an unindexed endpoint can hold connections until the pool is exhausted, and from the outside it looks like the app hung. Even just flagging "no default timeout configured" in the report would save someone a 3 a.m. incident.

1

u/-UniK-0 2d ago

This is gold, thank you! All three of these are exact "passes local tests, explodes in prod" traps.

  1. `MissingGreenlet` on lazy relationships is honestly probably #1 on the async SQLAlchemy pain list — flagging missing eager loads (or recommending `lazy="raise"` on async models) fits right into `backend-review`.
  2. The `allow_origins=["*"]` + `allow_credentials=True` combo is such a clean, zero-false-positive check to catch in `CORSMiddleware` — I already flag loose CORS, so tightening it for that exact pair is an easy win.
  3. Good call on `statement_timeout` at the Postgres connection level too (right now migration checks care about lock timeouts, but flagging missing default `statement_timeout` on the engine/pool config is huge).

Definitely adding these to the checks — really appreciate you taking the time to share real prod lessons!