TypeScript / Python API Tutorial: Five Frameworks, One CRUD API
A hands-on tutorial that builds the same CRUD API five times — with Next.js, Express, NestJS, Flask, and FastAPI — so you can compare routing styles, validation, and architecture side by side.
Get the Full Source Code on GitHub
This article is a summary. The full, runnable tutorial —
five complete framework implementations of the same CRUD
API, plus a shared Next.js UI and per-framework docs —
lives in the audoir/ts-python-api-tutorial repository.
Introduction
There is no single "right" framework for building REST APIs — Next.js, Express, NestJS, Flask, and FastAPI each represent a different philosophy, from minimal flexibility to structured, opinionated architecture. The best way to understand the trade-offs is to build the same API five times and compare.
The ts-python-api-tutorial repository does exactly that: a simple CRUD API implemented in five popular frameworks, each in its own sub-folder, demonstrated through a shared Next.js UI. This post summarizes the framework comparison and what each tab covers — head to the repo for the full, runnable code and per-framework docs.
Framework Comparison
Not sure which framework to reach for? Here is a quick reference comparing all five at a glance.
| Framework | Language | Routing | Validation | Best For |
|---|---|---|---|---|
| Next.js | TypeScript | File-system (app/api/route.ts) | Zod | Full-stack web apps |
| Express | TypeScript | Imperative (app.get(...)) | Zod | Simple APIs, microservices, prototypes |
| NestJS | TypeScript | Decorators (@Get()) | Zod | Large, structured backend APIs |
| Flask | Python | Decorators (@app.route(...)) | Pydantic | Python APIs, data science backends |
| FastAPI | Python | Decorators (@app.get(...)) | Pydantic (built-in) | High-performance Python APIs, ML serving |
Six Tabs, Six Implementations
Each tab builds the exact same REST API contract — the same URLs, methods, and JSON shapes — so you can see how each framework approaches the identical problem.
🟦 Next.js CRUD
A full-stack React framework with file-system routing — route.ts files under app/api/ become HTTP endpoints, validated with Zod.
🟩 Express CRUD
The minimal, unopinionated Node.js web framework. Routes are declared imperatively with calls like app.get(...) — a blank canvas with no enforced structure.
🐦 NestJS CRUD
Built on Express but adds an Angular-inspired architectural layer — decorators, dependency injection, and modules — that enforces conventions for large codebases.
🚀 Advanced NestJS
Builds on Tab 3 with four real-world patterns served under /api/advanced: a @Public() custom decorator, an ApiKeyGuard, a response-wrapping interceptor, and constructor-based dependency injection.
🐍 Flask CRUD
A minimal, synchronous (WSGI) Python framework using decorator-based routing and Pydantic for request validation.
⚡ FastAPI CRUD
The same API as the Flask tab, rebuilt on the async-first (ASGI) FastAPI framework with built-in Pydantic validation and auto-generated Swagger/ReDoc documentation.
📚 Core Concepts Reference
New to web APIs? The repo's docs/concepts.md explains the foundational ideas that appear across all five frameworks — HTTP and REST, CRUD, middleware, routing, validation (Zod vs. Pydantic), dependency injection, decorators, CORS, WSGI vs. ASGI, sync vs. async, and OpenAPI/Swagger. If you hit an unfamiliar term in any tab, that's the place to look it up.
Getting Started
Clone the repo, then install dependencies per framework — Node.js
frameworks use npm install, Flask's virtual environment is created automatically by uv on first run, and FastAPI uses uv sync.
From the repo root, run ./scripts/start-servers.sh to launch every tutorial server in the background at once (killed together with Ctrl-C), or start each framework individually — Next.js on :3000, Express on :3001, NestJS on :3002, Flask on :3003, and FastAPI on :3004. FastAPI also exposes interactive docs at /docs (Swagger) and /redoc. See the repository README for exact commands.
Conclusion
There is no single "right" framework for building REST APIs. Each of the five frameworks covered here represents a different philosophy — from the minimal flexibility of Express and Flask, to the structured power of NestJS, to the full-stack convenience of Next.js, to the async-first performance of FastAPI.
The key insight is that the concepts of web APIs are universal — routing, validation, middleware, error handling — only the syntax and conventions change. Building the same CRUD API in all five frameworks side by side shows exactly where each framework adds value and where it adds complexity.
Ready to Build It Yourself?
Clone the repository and run all five servers side by side to compare Next.js, Express, NestJS, Flask, and FastAPI in action.
Clone ts-python-api-tutorial on GitHubAbout the Author
Wayne Cheng is the founder and AI app developer at Audoir, LLC. Prior to founding Audoir, he worked as a hardware design engineer for Silicon Valley startups and an audio engineer for creative organizations. He holds an MSEE from UC Davis and a Music Technology degree from Foothill College.
Further Exploration
Explore the ts-python-api-tutorial repository and experiment with extending the examples. Consider replacing the in-memory store with a real database, adding authentication, or deploying one of the backends to a cloud provider to deepen your understanding of API development.
For more AI-powered development tools and tutorials, visit Audoir .