Skip to content
STACK IT FIRST
Install the skills
03 · Backend · Growth · Data & AI

LangGraph + FastAPI + Postgres

Pipelines and agent workflows as explicit graphs, each step typed and retried, served through the same FastAPI you started with.
Agent fit4/5 Growth · Charge for it Reviewed

The stack

Framework
FastAPI + LangGraph
Runtime
Python 3.14 with uv
Data
Postgres with pgvector, object storage for raw files
Hosting
Fly or Modal for the API, Modal or a worker pool for jobs
Also
  • Pydantic models as the graph state
  • A queue (Redis or Postgres-backed) with retries and dead letters
  • Langfuse or OpenTelemetry for traces
  • Evals in CI for the LLM steps
AGENTS.md + real projects on STACK IT FAST (opens in a new tab)

Why agents do well here

4/5
  • A graph with typed state makes every step's input and output explicit, which is what lets an agent modify one node without breaking the rest.
  • Idempotent steps with retries turn flaky external calls into a visible queue instead of silent data loss.
  • Traces and evals give the agent something to check against, which matters more here than in any other profile.

Avoid at this tier

  • Hiding LLM calls inside helper functions; each is a node with a schema.
  • A separate vector database while pgvector still fits.
  • Shipping prompt changes without an eval run.

How it fits together

Growth-tier data work is pipelines that fail partway and workflows that call models. Make both explicit graphs with typed state so the agent can see each step, and put retries and traces around every external call.

Folder layout

app/
  api/            FastAPI routes
  graphs/         <pipeline>/ {graph.py, nodes.py, state.py, test_graph.py}
  models/         Pydantic state and schemas
  jobs/           queue workers running graphs
evals/            datasets and scoring for LLM nodes

First five decisions

Lock these in before the agent writes the second feature. Each one removes a choice it would otherwise make differently every time.

  1. 01 Typed graph state
  2. 02 One queue with retries
  3. 03 Pgvector in Postgres
  4. 04 Traces on every node
  5. 05 Evals in CI for prompt changes

Also fits this cell

Same tier, same profile, a different stack. Pick one of these only for the reason given.

When to move on

Stay here until the product forces the next tier. You are ready for Scale when:

  • More than one team deploys backend code independently
  • Data lives in more than one region or under residency rules
  • An auditor will ask who changed what
  • Latency and throughput are contractual, not aspirational
Scale · Data & AI ClickHouse + a typed ingestion layer + Postgres Analytical storage separated from transactional, with typed ingestion and a query layer the product reads through one client. Next tier

Same tier, other profiles