A blog series

Backend in Depth: Designing an API You'd Put in Production

From folder structure to N+1 queries: the choices a senior full-stack engineer must explain. Clean code, layers, REST design, validation, errors, logging, auth, databases, Prisma, GraphQL, Node speed and testing.

Started 
2026
Lessons 
12
Reading 
~3 h

Contents

Every lesson has the same steps: what it is, how it works, a real example, common mistakes, then interview questions with answers you can say out loud.

  1. Lesson 00Clean Code for Backends: Naming, Small Functions and BoundariesThe few clean-code rules that improve backend code reviews: pure domain logic, clear dependencies, no hidden I/O, and when not to add an abstraction.15 min
  2. Lesson 01API Folder Structure: Routes, Controllers, Services, RepositoriesLayers vs grouping by business feature, what goes in each layer, and why the request object should never reach your service layer.20 min
  3. Lesson 02REST API Design Best Practices: Resources, Versioning, Status CodesNouns, not verbs. One error format. Ways to version an API. Idempotency keys for POST, and partial updates.18 min
  4. Lesson 03Validation at the Edge: Schemas, DTOs and Trusting NothingCheck input where it enters the API, share schemas with the frontend, and keep validation errors apart from business-rule errors.15 min
  5. Lesson 04Error Handling: Operational vs Programmer ErrorsOne central error handler, typed error classes, how Express 5 treats rejected promises, and when to let the process crash and restart.18 min
  6. Lesson 05Logging and Observability: Structured Logs, Correlation IDs, MetricsJSON logs, log levels, request IDs that follow a request through every service, and what you must never log.15 min
  7. Lesson 06Authentication and Authorization on the ServerPassword hashing, session stores, checking JWTs properly, role-based vs attribute-based access control, and checking ownership on every resource.18 min
  8. Lesson 07Database Fundamentals for API Engineers: Indexes, Transactions, IsolationB-tree indexes, reading EXPLAIN ANALYZE, transactions and isolation levels, and the race conditions they stop, like selling too many items.20 min
  9. Lesson 08Prisma in Production: N+1, include, Batching and Connection PoolsHow N+1 appears in loops and GraphQL resolvers, how Prisma batches findUnique, how it loads relations, and why you share a single client.18 min
  10. Lesson 09REST vs GraphQL (vs Hasura): How to ChooseFetching too much or too little, how caching is different, changing the schema over time, limits on query cost, and where an auto-generated API fits.18 min
  11. Lesson 10Node.js Performance Basics: Event Loop Blocking, Streams, WorkersWhy one heavy CPU job can stop every request, plus streams for large data and worker threads.15 min
  12. Lesson 11Testing an API: Unit, Integration and ContractWhere to spend your testing effort in a backend, testing against a real database, and contract tests between the frontend and the API.15 min

Glossary

43 terms used in this series. Inside any lesson, hover or tap a dotted term to see its meaning without leaving the page. Browse all terms →