Skip to main content

Backend Engineering From First Principles

Build a Senior Engineer From the Socket Up​

A comprehensive, first-principles handbook that takes a capable developer β€” especially one pivoting into backend β€” from "I can write an endpoint" to a senior backend engineer who can design, build, operate, and defend a real distributed system, and narrate every tradeoff aloud.

The promise: nothing here is memorized magic. Every higher layer is derived from the physics beneath it. You'll understand the event loop because you first understood non-blocking I/O; you'll choose an index because you first understood B-tree pages; you'll reason about CAP because you first internalized single-node transactions.

  • Primary lab: Node.js / TypeScript (Express, NestJS).
  • Enterprise lens: Java / Spring / JVM, used wherever it teaches a transferable principle.
  • Concepts are language-agnostic; the practice is concrete.
  • One running system: Pulsely, grown from a raw-socket server into a cloud-deployed, observable, distributed platform. See projects/pulsely/README.md.

How to use this book​

  1. Read in order the first time. The ordering is the teaching method β€” each chapter depends only on earlier ones (no forward references). Skipping ahead removes the derivation that makes the next idea obvious.
  2. Do the Pulsely increment at the end of each chapter. You learn why an abstraction exists by first living without it.
  3. Every chapter follows the same nine-beat anatomy (below), so you always know where to find the mental model, the pitfalls, the tradeoffs, and the interview angle.
  4. Use it as a reference later by jumping to any chapter β€” the "Mental model," "Pitfalls," and "Tradeoffs" beats are written to stand alone.
  5. Set up the lab first: appendices/appendix-a-lab-setup.md (Postgres, MongoDB, Redis, Kafka via Docker as a tool β€” internals come later in Ch 36).

The nine-beat chapter template​

  1. Problem & why it exists β€” a felt production pain, not a definition.
  2. Mental model β€” the transferable shape, before any tool is named.
  3. Theory & invariants β€” language-agnostic principles and vocabulary.
  4. Under the hood β€” concrete mechanics (Node/TS primary; Java/JVM contrast where it teaches).
  5. Production practice β€” what tutorials skip.
  6. Common pitfalls β€” failure signature β†’ fix.
  7. Tradeoffs β€” rejected alternatives and when you'd reverse the choice.
  8. Security & scale notes β€” woven into every chapter, not quarantined.
  9. Interview lens + exercises & Pulsely increment β€” wrong answer vs the senior tradeoff-narrating answer; drills; an ADR where relevant.

The knowledge-dependency spine​

Metal β†’ wire β†’ I/O β†’ runtime β†’ contract β†’ data (single node) β†’ distribution β†’ trust & operability β†’ delivery β†’ judgment.

I/O & networking physics come before the event loop; frameworks come after contracts; data modeling & storage internals come before database products; single-node ACID comes before distributed consistency; idempotency comes before messaging; security/reliability/observability come before delivery; synthesis comes last.


Table of contents​

Front matter

Part I β€” Foundations: the machine, the wire, the request lifecycle Β· part intro​

Part II β€” The Node.js runtime & its Java/enterprise contrast Β· part intro​

Part III β€” Designing APIs as contracts Β· part intro​

Part IV β€” Data & storage: databases from the disk up Β· part intro​

Part V β€” Distributed systems, messaging, realtime & scale Β· part intro​

Part VI β€” Security, identity, reliability & observability Β· part intro​

Part VII β€” Delivery: testing, containers, cloud, CI/CD Β· part intro​

Part VIII β€” Synthesis: architecture, brownfield, system design & career Β· part intro​

Appendices


Learning roadmap (phases & milestones)​

PhasePartsYou can now…
1 β€” Substrate fluencyI–IITrace any request end-to-end naming each hop/failure mode; build an HTTP server from raw sockets; explain the event loop as a consequence of OS/I/O.
2 β€” Contracts & servicesIIIDesign a versioned, validated, paginated, rate-limited API (incl. secure webhooks); choose REST/GraphQL/gRPC with justification.
3 β€” Data masteryIVModel data as a discipline; reason about isolation/MVCC; read EXPLAIN and choose indexes from first principles; operate Postgres; use Redis/search beyond caching.
4 β€” Distribution & scaleVReason about consistency/CAP/consensus; design idempotent retry-safe ops; decouple with queues/Kafka/events/realtime; scale with evidence.
5 β€” Secure, reliable, observableVIThreat-model & secure a system; implement correct authN/authZ + multi-tenancy; design for failure with SLOs; debug in production.
6 β€” Production deliveryVIIBuild a trustworthy test suite; containerize a 12-factor app; provision least-privilege AWS via IaC; ship zero-downtime via gated CI/CD.
7 β€” Senior synthesisVIIIChoose & defend an architecture (and write the ADR); work safely in brownfield systems; drive a system-design round; demonstrate senior judgment.

Goal-coverage map​

Your goalWhere it lives
Strong fundamentals / under the hoodPart I (Ch 1–6)
API designPart III (Ch 10–12)
NetworkingCh 5–6
Databases deep / SQL + NoSQL thinkingPart IV (Ch 15–22)
PostgreSQLCh 19 (+ 15–18)
MongoDBCh 20
Redis beyond cachingCh 21
Node.js deepCh 7–8
ExpressCh 13
NestJSCh 14
Java / enterprise principlesCh 9, 14, 39 (lens)
Scalability & distributed systemsPart V (Ch 23–30)
Reliability engineeringCh 33
Security engineeringCh 31
AuthN / AuthZCh 32
Messaging & event-driven / queues / backgroundCh 25–27
RealtimeCh 28
Observability / monitoring / debuggingCh 34
Cloud / AWSCh 37
Docker / deploymentCh 36, 38
CI/CDCh 38
System designCh 41
Interview-readyCh 44 (+ interview lens in every chapter)
Build a real scalable system from scratchThe Pulsely spine (Ch 1 β†’ 43)


Start reading β†’ Chapter 0 β€” How to Use This Book.