Skip to main content
All use casesUse Case

Ship an AI code review backend that handles async jobs at scale.

Receive GitHub webhooks, queue long-running LLM analysis jobs via Celery, store results in Postgres, and stream findings back — all pre-wired in FastAPI AI Kit.

FastAPICeleryRedisOpenAIPostgreSQLSSE

The usual pain points

  • Handling GitHub webhooks reliably without blocking the HTTP thread
  • Running long LLM analysis jobs asynchronously
  • Storing and retrieving review results efficiently
  • Streaming partial results as the LLM generates them

How the kit solves them

  • Background jobs via Celery + Redis — offload webhook processing immediately
  • Long-running LLM calls run in workers, not HTTP threads
  • SQLAlchemy async ORM for storing analysis results with Alembic migrations
  • SSE streaming endpoint for pushing incremental results to clients

Example implementation

main.py
@router.post("/v1/webhooks/github")
async def github_webhook(
    payload: GitHubPushEvent,
    background: BackgroundTasks,
):
    # Immediately enqueue — don't block
    job = await review_queue.enqueue(
        analyze_pull_request,
        pr_url=payload.pull_request.url,
        files=payload.files_changed,
    )
    return {"job_id": job.id, "status": "queued"}

# Worker picks up job, streams LLM analysis to DB
@celery.task
async def analyze_pull_request(pr_url: str, files: list):
    async for chunk in llm.stream(build_review_prompt(files)):
        await store_chunk(pr_url, chunk)

Ready to build your ai code review tool backend?

FastAPI AI Kit ships with everything shown above, pre-configured and production-ready. Clone the repo and start building in minutes.

Ready to ship your AI backend this weekend?

Join developers who skipped weeks of boilerplate and went straight to building.

Read the docs
No subscriptions · One-time payment · Lifetime updates