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β
- 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.
- Do the Pulsely increment at the end of each chapter. You learn why an abstraction exists by first living without it.
- 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.
- Use it as a reference later by jumping to any chapter β the "Mental model," "Pitfalls," and "Tradeoffs" beats are written to stand alone.
- 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β
- Problem & why it exists β a felt production pain, not a definition.
- Mental model β the transferable shape, before any tool is named.
- Theory & invariants β language-agnostic principles and vocabulary.
- Under the hood β concrete mechanics (Node/TS primary; Java/JVM contrast where it teaches).
- Production practice β what tutorials skip.
- Common pitfalls β failure signature β fix.
- Tradeoffs β rejected alternatives and when you'd reverse the choice.
- Security & scale notes β woven into every chapter, not quarantined.
- 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β
- Ch 1 β What a Backend Is & the Request's Journey
- Ch 2 β The Server as a Process: Sockets, Ports & the Accept Loop
- Ch 3 β OS & Runtime Fundamentals: Processes, Threads, Memory, Syscalls
- Ch 4 β I/O & Concurrency Models: Blocking, Non-Blocking & the Event-Loop Idea
- Ch 5 β Networking I: IP, TCP/UDP, Sockets, DNS
- Ch 6 β Networking II: TLS, HTTP/1.1β3, Proxies, Load Balancers, CDNs
Part II β The Node.js runtime & its Java/enterprise contrast Β· part introβ
- Ch 7 β The Node Event Loop, libuv & the Async Model
- Ch 8 β Node Deeper: Streams, Memory/GC, Workers, Profiling, Graceful Shutdown
- Ch 9 β TypeScript for Backend & the JVM/Java Concurrency Contrast
Part III β Designing APIs as contracts Β· part introβ
- Ch 10 β APIs as Contracts: REST, HTTP Semantics, Idempotency, Errors
- Ch 11 β API Evolution at Scale: Versioning, Pagination, Validation, Rate Limiting
- Ch 12 β Beyond REST: GraphQL, gRPC, Webhooks & Integration Security
- Ch 13 β Express From First Principles: the Middleware Pipeline
- Ch 14 β NestJS, Dependency Injection & Application Architecture
Part IV β Data & storage: databases from the disk up Β· part introβ
- Ch 15 β Relational Foundations: Model, SQL, Keys, Constraints, Joins
- Ch 16 β Data Modeling as a Discipline
- Ch 17 β Transactions, ACID, Isolation & Concurrency Anomalies
- Ch 18 β How Databases Store Bytes: Pages, WAL, B-tree vs LSM, OLTP vs OLAP
- Ch 19 β PostgreSQL Deep Dive
- Ch 20 β NoSQL Thinking & MongoDB
- Ch 21 β Redis Beyond Caching
- Ch 22 β Search Infrastructure
Part V β Distributed systems, messaging, realtime & scale Β· part introβ
- Ch 23 β Distributed Systems Theory I: Failure, Time, Consistency, CAP/PACELC
- Ch 24 β Distributed Systems Theory II: Replication, Partitioning, Consensus
- Ch 25 β Idempotency, Delivery Semantics & the Exactly-Once Myth
- Ch 26 β Queues & Background Processing
- Ch 27 β Log-Based Streaming & Event-Driven Architecture (Kafka)
- Ch 28 β Realtime & Streaming Backends: WebSockets, SSE, Scaling Stateful Connections
- Ch 29 β Scalability Building Blocks
- Ch 30 β Performance Engineering & Tail Latency
Part VI β Security, identity, reliability & observability Β· part introβ
- Ch 31 β Security & Cryptography Engineering
- Ch 32 β Authentication & Authorization at Scale
- Ch 33 β Reliability Engineering: Resilience, SLOs, DR
- Ch 34 β Observability & Debugging in Production
Part VII β Delivery: testing, containers, cloud, CI/CD Β· part introβ
- Ch 35 β Testing & Quality Strategy
- Ch 36 β Containers & the 12-Factor App
- Ch 37 β Cloud & AWS for Backend Engineers
- Ch 38 β CI/CD, Infrastructure as Code & Deployment Strategies
Part VIII β Synthesis: architecture, brownfield, system design & career Β· part introβ
- Ch 39 β Software Architecture & Service Boundaries (+ ADRs/Design Docs/RFCs)
- Ch 40 β Working in Existing & Brownfield Systems
- Ch 41 β System Design Mastery
- Ch 42 β Backend for AI Features
- Ch 43 β Capstone: Designing, Building & Operating Pulsely End-to-End
- Ch 44 β Interview Readiness & the Senior Career
Appendices
- A β Lab Setup Β· B β Glossary Β· C β Command/Config Cheat-Sheets Β· D β Further Reading
Learning roadmap (phases & milestones)β
| Phase | Parts | You can now⦠|
|---|---|---|
| 1 β Substrate fluency | IβII | Trace 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 & services | III | Design a versioned, validated, paginated, rate-limited API (incl. secure webhooks); choose REST/GraphQL/gRPC with justification. |
| 3 β Data mastery | IV | Model 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 & scale | V | Reason about consistency/CAP/consensus; design idempotent retry-safe ops; decouple with queues/Kafka/events/realtime; scale with evidence. |
| 5 β Secure, reliable, observable | VI | Threat-model & secure a system; implement correct authN/authZ + multi-tenancy; design for failure with SLOs; debug in production. |
| 6 β Production delivery | VII | Build a trustworthy test suite; containerize a 12-factor app; provision least-privilege AWS via IaC; ship zero-downtime via gated CI/CD. |
| 7 β Senior synthesis | VIII | Choose & defend an architecture (and write the ADR); work safely in brownfield systems; drive a system-design round; demonstrate senior judgment. |
Goal-coverage mapβ
| Your goal | Where it lives |
|---|---|
| Strong fundamentals / under the hood | Part I (Ch 1β6) |
| API design | Part III (Ch 10β12) |
| Networking | Ch 5β6 |
| Databases deep / SQL + NoSQL thinking | Part IV (Ch 15β22) |
| PostgreSQL | Ch 19 (+ 15β18) |
| MongoDB | Ch 20 |
| Redis beyond caching | Ch 21 |
| Node.js deep | Ch 7β8 |
| Express | Ch 13 |
| NestJS | Ch 14 |
| Java / enterprise principles | Ch 9, 14, 39 (lens) |
| Scalability & distributed systems | Part V (Ch 23β30) |
| Reliability engineering | Ch 33 |
| Security engineering | Ch 31 |
| AuthN / AuthZ | Ch 32 |
| Messaging & event-driven / queues / background | Ch 25β27 |
| Realtime | Ch 28 |
| Observability / monitoring / debugging | Ch 34 |
| Cloud / AWS | Ch 37 |
| Docker / deployment | Ch 36, 38 |
| CI/CD | Ch 38 |
| System design | Ch 41 |
| Interview-ready | Ch 44 (+ interview lens in every chapter) |
| Build a real scalable system from scratch | The Pulsely spine (Ch 1 β 43) |
Start reading β Chapter 0 β How to Use This Book.