Backend Deep Dive
Welcome
You have called an API from the outside. This book is about the inside: how a request becomes a typed value at the edge, how HTTP methods and status codes are a contract that a retrying client acts on, how identity is established and authorization enforced where it cannot be skipped, and why two buyers were both sold seat 14C. Then the half that separates a service that works from one that survives: timeouts, retries, idempotency keys, the outbox, jobs that run twice, caches that lie, and a payment provider that answers late. One system, Stagedoor, carries every example from the first page to the last.
About This Course
The network can fail between any two lines of your code. Every call that leaves the process, to Postgres, to Redis, to the payment provider, to the client that asked, can time out, arrive twice, arrive late, or succeed while its answer is lost, and the caller cannot tell the first case from the last. Nearly everything that makes a backend hard falls out of that one fact: the timeout on every call, the retry that is only safe when the operation is idempotent, the outbox that makes a row and a message one unit, the job handler that must tolerate running twice, the webhook that replays, the reconciliation that asks the neighbour for the truth. This book states that idea on page one and keeps cashing it in.
The second thing it returns to constantly is the boundary. A service has an edge, and at the edge three things happen exactly once: bytes are parsed into typed values, the caller is authenticated, and the outside vocabulary is translated into the inside one. Inside the boundary everything is typed, trusted and yours. Most of the bugs in the identity and data chapters are a check that ran inside instead of at the edge, or an outside value that leaked in without being parsed.
Every example comes from one running system. Stagedoor is an event-ticketing service: two API instances and a worker, one Postgres primary with a replica, one Redis, and a payment provider called Payrail on the far side of the internet. Marek owns that service for all fourteen chapters. Three failures open in Chapter 1 and are left deliberately unexplained: on the night of the spring on-sale, seat 14C was sold to two buyers, one buyer was charged twice after her browser retried a slow checkout, and ticket emails arrived forty minutes late. The seat is settled in Chapter 6, the double charge in Chapter 7 and the late emails in Chapter 8, each by the machinery the book has built by then rather than by a guess that happened to work.
Who This Is For
Engineers who have used an API and are about to own one, or already do and have been guessing. The bar is concrete: you have sent a request and read the JSON that came back, you can read a SELECT with a JOIN in it, and you have written some code in some language. The reference language is Python, with FastAPI where a framework is unavoidable, and every snippet has narrated prose beside it that stands on its own. A reader who writes Go or TypeScript should lose nothing but the syntax, because the framework is a detail and the design pressure is the lesson.
It is not a first course on APIs or on databases. If a status code or a primary key is a term you would have to look up, read APIs for Beginners and Databases for Beginners in this catalogue first and come back; this book assumes both and goes one layer down on every page. It is also not a book about the things between services or about composing many of them: brokers, gateways, meshes, sharding and multi-region belong to the courses named in Chapter 1, and this one stays with a single service and a single database on purpose.
What You Should Already Know
- How to call an API: a method, a path, headers, a JSON body, and what a status code is telling you
- Working SQL:
SELECT,JOIN, what a transaction is for, what an index is for - Some programming in any language: functions, types, and reading a stack trace without alarm
- Nothing about building a service: the boundary, identity, pools, transactions, retries, queues, caches, testing and observability are all built from zero
New to this? Start with APIs for Beginners and Databases for Beginners - the first chapter of every course is free, and the rest is one membership.
How the Course Is Built
The fourteen chapters run in three movements. The API half (Chapters 1–5) is the boundary: what a backend is and where its time goes, HTTP used as a contract rather than a transport, resources and shapes and errors a client can act on, the layers a service is made of, and identity from the password hash up to multi-tenancy. The reliability half (Chapters 6–10) is the core of the book: the pool and the transaction and the seat sold twice, timeouts and retries and the key that stops the double charge, the worker and the jobs that run twice, the cache and the four ways it lies, and one real neighbour with its webhook, its reconciliation and its saga. The operations half (Chapters 11–14) is running it: configuration and secrets and the thirty seconds after SIGTERM, a test suite that runs against a real database and a fake provider, logs and metrics and traces from inside the code, and what breaks first on the night twenty thousand buyers arrive at once.
Every topic has the same shape: an opening that says what the thing is and why it exists, the mechanics with real code and real exchanges, the specific mistakes that cause real incidents, the practices that prevent them, and a short knowledge check. Every mechanism gets a number, because a pool of twenty against a limit of two hundred, a three-second timeout, a ten-minute hold and a thirty-second grace period are the difference between predicting a service and guessing at it.
Chapter Map
Disclaimer
This course is an independent educational project created and maintained by Sergey Okinchuk. It is provided for learning and reference purposes only.
No affiliation. This course is not affiliated with, sponsored by, endorsed by, or officially connected to any company, product, or project mentioned — including the Python Software Foundation, the FastAPI project, the PostgreSQL Global Development Group, Redis Ltd., Stripe, Adyen, Amazon Web Services, Google, or Microsoft. All opinions, interpretations, and recommendations expressed are those of the author.
Trademarks. Product and project names referenced — including "Python", "FastAPI", "PostgreSQL", "Redis", "Kafka", "RabbitMQ", "Stripe", "Kubernetes", "Docker", and "OpenTelemetry" — are the property of their respective owners. Use of these names is for identification and educational purposes only and does not imply any endorsement. Stagedoor and Payrail are fictional; any resemblance to a real product or company is coincidental.
Not operational advice. This material teaches how a backend service is designed and the practices that follow from it, not turnkey instructions for any specific environment. Code snippets, configuration values and numbers are simplified for learning and sized for one fictional workload. Always consult the official documentation and test on a system you can afford to lose before changing a production service.
Accuracy and currency. Libraries, protocols and providers change. Facts in this course reflect the author's understanding at the time of writing against Python 3.14, PostgreSQL 18 and Redis 8; version-dependent behaviour drifts. Always verify against the official documentation for the versions you actually run.
No warranty. This material is provided "as is" without warranty of any kind. The author accepts no liability for any loss or damage arising from reliance on the content.