Chapter 7

From first principles

Rebuild the tools you have been using.

~170 min total11 lessonsAssignment

By the end of this chapter you'll be able to

  • What we are building
  • Three layers, decided before any code
  • The type and its rules
  • The store
  • Listing, which is where the work actually is

Lessons

Module: From first principles

01

Build your own CRUD API from scratch

Every backend job, in the end, asks for the same thing: create a record, read one, list many with a filter, change one, delete one.

20mhard
02

Build your own CLI framework

Every tool you write grows a command line eventually, and most people reach straight for Cobra without ever knowing what it does.

15mhard
03

Build your own JSON parser

JSON is the smallest grammar worth parsing properly.

15mhard
04

Build your own key-value store: a write-ahead log and crash recovery

A map in memory is a key-value store until the process restarts.

15mhard
05

Build your own on-disk index: pages and a B-tree

The key-value store in chapter fifty one has a limit it does not advertise: on startup it replays the whole log into a map, so the index lives in.

15mhard
06

Build your own Redis: RESP over raw TCP

Everything you have written so far has spoken HTTP, which is a protocol somebody else parsed for you.

15mhard
07

Build your own HTTP server, from a TCP socket

Chapter twenty one used net/http, which hides the protocol so completely that most web developers have never seen a request line.

15mhard
08

Build your own Git

Git is the tool you use most and understand least.

15mhard
09

Build your own reverse proxy and load balancer

Every production system has one of these in front of it, and most developers treat it as a configuration file somebody else wrote.

15mhard
10

Build your own job queue

Chapter forty three used a queue.

15mhard
11

Build your own test runner, and what go test really does

go test feels like magic in a way the rest of Go does not.

15mhard

Chapter assignment

Finish every assignment in From first principles

Each lesson in this part ends with its own assignment, named for the leaderboard. Finish them in order.

See success criteria

Lesson 1 takes ~20 min.

Start chapter

Spot a typo? Have an idea?

Help us improve this chapter. One click opens a GitHub issue with this chapter's URL pre-filled — suggest a clearer wording, report a bug, or request a new lesson. The course keeps improving thanks to learners like you.

Suggest an improvement on GitHub