This repository is a hands-on, opinionated curriculum for learning API design from beginner to advanced, using real, production-style code in:
- PHP (
Laravel-style) - TypeScript (
Express-style Node) - Python (
FastAPI)
You will learn how to design, implement, and evolve APIs that are clean, consistent, secure, and maintainable.
README.md
docs/
examples/
projects/
patterns/
languages/
docs/– Core API design concepts and theory.examples/– Focused bad vs good code samples.projects/– Two mini production-style APIs (Blog + E‑commerce).patterns/– Reusable API patterns (pagination, filtering, sorting, caching).languages/– Language-specific foundations and bootstrapping.
Follow this order if you want a guided curriculum:
- Foundations
docs/api-basics.mddocs/api-design-principles.mddocs/rest-vs-graphql.md
- API Types & Trade-offs
docs/api-types.md
- Core Cross-Cutting Concerns
docs/authentication.mddocs/error-handling.mddocs/rate-limiting.mddocs/versioning.md
- Patterns
patterns/pagination/README.mdpatterns/filtering/README.mdpatterns/sorting/README.mdpatterns/caching/README.md
- Bad vs Good Examples
examples/bad/vsexamples/good/(compare side by side)
- Mini Projects
projects/BlogApi/– posts, comments, JWT auth, paginationprojects/EcommerceApi/– products, orders, inventory logic
- Advanced Topics
docs/advanced-topics.md
At every step, you will see Laravel, Express (TypeScript), and FastAPI implementations.
- PHP 8.1+ with Composer
- Node.js 18+ with npm or pnpm
- Python 3.10+ with
pip
Each language folder has its own minimal setup.
Code lives in languages/php/ and per-project folders.
Install dependencies:
cd languages/php
composer installRun the example HTTP server (using Laravel-style controllers/services but a minimal bootstrap script):
# Run the Blog API
cd projects/BlogApi/php
php -S localhost:8001 bootstrap.php
# Run the E-commerce API
cd projects/EcommerceApi/php
php -S localhost:8002 bootstrap.phpSee:
examples/good/php/for focused examplesprojects/BlogApi/php/andprojects/EcommerceApi/php/for mini APIs
Code lives in languages/typescript/ and project-specific subfolders.
Install dependencies:
cd languages/typescript
npm installRun a project (example: Blog API):
npm run dev:blogSee:
examples/good/typescript/projects/BlogApi/typescript/projects/EcommerceApi/typescript/
Code lives in languages/python/ and project-specific subfolders.
Install dependencies:
cd languages/python
pip install -r requirements.txtRun a project (example: Blog API):
uvicorn projects.blog_api.main:app --reloadSee:
examples/good/python/projects/BlogApi/python/projects/EcommerceApi/python/
- API Types: REST, GraphQL, RPC, Webhooks, gRPC – when to use each, with realistic examples.
- Bad vs Good Design: Naming, endpoints, validation, error handling, and security mistakes, plus corrected versions.
- Architecture: Controllers vs Services vs Repositories, DTOs, Validation, Dependency Injection, and thin controllers, fat services.
- SOLID for APIs: How SRP, OCP, and others apply to request handling and business logic.
- Advanced Topics: Versioning, idempotency, rate limiting, caching, OpenAPI/Swagger, JWT & OAuth2 basics, logging & monitoring.
- As a guided course: Follow the roadmap from top to bottom and implement exercises as you go.
- As a reference: Jump to
patterns/orprojects/when you need real examples of clean API design. - As a teaching aid: Use the
examples/badvsexamples/goodsections for code reviews and workshops.
The code is deliberately opinionated but grounded in real-world production experience.