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

FastAPI + Pydantic + Postgres

Python for the libraries, Pydantic for the types, and a single service that runs the jobs and serves their results.
Agent fit5/5 MVP · Ship it Reviewed

The stack

Framework
FastAPI
Runtime
Python 3.14 with uv
Data
Postgres (Neon or Supabase) via SQLAlchemy 2 or SQLModel, pgvector if you embed
Hosting
Fly, Railway, or Modal for the heavy jobs
Also
  • Pydantic v2 models shared between API and jobs
  • APScheduler or a cron for schedules
  • pytest with a real database
AGENTS.md + real projects on STACK IT FAST (opens in a new tab)

Why agents do well here

5/5
  • Pydantic models give Python the explicit shapes an agent needs; the data flowing through a pipeline has a type at every step.
  • FastAPI generates OpenAPI from those same models, so the API contract is never out of date with the job output.
  • Python's data and AI libraries are the most heavily represented in training data, so the agent's first attempt is usually the idiomatic one.

Avoid at this tier

  • A workflow orchestrator before there is more than one pipeline.
  • Notebooks as the source of truth; jobs live in modules with tests.
  • Untyped dicts between steps; every boundary is a Pydantic model.

How it fits together

A data MVP is a few jobs and an API that exposes their output. Keep both in one FastAPI service so the models are shared, and run the heavy steps as functions that can be called from a schedule or a request.

Folder layout

app/
  main.py         FastAPI app
  models/         Pydantic models used by routes and jobs
  db/             SQLAlchemy models, alembic/ migrations
  jobs/           ingest.py, embed.py, each a plain function with a test
  routes/         search.py, items.py

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 Pydantic everywhere
  2. 02 Alembic migrations
  3. 03 Jobs as plain functions before any orchestrator
  4. 04 Pgvector inside Postgres rather than a separate vector store
  5. 05 Pytest against a real database

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 Growth when:

  • A breaking response change would break a client
  • Background work, emails or webhooks exist
  • Someone asks for an API reference
  • You have been paged at least once
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. Next tier

Same tier, other profiles