Computer science
you can drive

421737122529336890465160778495

An order-4 B-tree: at most three keys in a node.

Free, open-source courses on databases, RAG, language models and algorithms. Every chapter has a machine and a quiz.

Choose a course

This is the B-tree you build in Chapter 5 of Databases in Depth.

Databases in Depth

32 chapters · 28 machines · 165 questions

The consistent-hashing machine: three nodes on a ring, 24 keys coloured by the node that owns them, eight keys each.
Chapter 21's hash ring. Add a node and watch how few keys have to move.

How a database stores your rows, finds them fast and keeps them through a crash. Then how many machines agree on one answer. In the last part you write a real database in plain Java.

Read chapter 1

RAG in Depth

36 chapters · 42 machines · 402 questions

The HNSW machine: three graph layers of 24, 115 and 400 nodes, a greedy search path, and recall@10 of 0.900 after 41 distance computations.
Chapter 11's HNSW index. Run a search, read the recall, raise ef and run it again.

Everything between a question and a grounded answer: chunking, embeddings, BM25, HNSW, hybrid search, reranking, and how to tell whether any of it works. You finish by building PocketRAG in Python and TypeScript.

Read chapter 1

LLM in Depth

41 chapters · 81 machines · 462 questions

The attention machine: the sentence 'the cat sat on the mat because it was warm', a causal weight matrix, and the softmax row for 'it' putting 0.319 on 'mat' and 0.267 on 'cat'.
Chapter 5's attention head. Click a word to see what it attends to, then switch off the scaling.

What a language model is, one layer at a time: tokenizers, attention and the transformer block, pretraining, decoding, fine-tuning, quantization and serving. The last part builds PocketLM, a working model, in Python and C.

Read chapter 1

DSA by Patterns

49 chapters · 88 machines · 492 questions

The two-pointers machine: a sorted array with left and right pointers, the regions each invariant has ruled out shaded.
Chapter 8's two pointers. The shaded regions are what each invariant has already ruled out.

Data structures and algorithms as mechanisms, not recipes. Why two pointers touches each element once, why build-heap is linear, and what to do when a problem matches no pattern. Every routine in Python and Java.

Read chapter 1

First, read the mechanism

Each chapter explains one mechanism in plain prose, with real numbers and code that runs.

The opening of Chapter 8 of DSA by Patterns, 'Two Pointers and Sliding Windows', with its first section and a Python code sample. The next-token machine from Chapter 1 of LLM in Depth: an editable prompt and the probability of each candidate next token. A quiz question on why HNSW uses layers, answered correctly, with the explanation shown underneath. The journey map of RAG in Depth, showing Part 1 and Chapter 1 with the progress bar at the top.

Free and open source

HackDynamics is free and open source. The code is under the MIT licence and the course text under CC BY-SA 4.0, so you can read it, translate it, fork it or teach from it. There is no paywall, no card and no sign-up; an account only carries your progress between devices. The site is plain HTML, CSS and JavaScript with no build step. Clone the repository, run python3 -m http.server and the whole thing opens on your own machine. All 239 machines live in the js folder, and every chapter is one JavaScript file you can edit. The most useful thing you can send us is a correction: a wrong fact, a broken machine, a quiz with two right answers. Read the source on GitHub.

Being written now

Each is written the way the first four were: one mechanism per chapter, a machine beside the text, a quiz at the end. Open an issue to say which one you want first.

  • Operating systems: processes, schedulers, virtual memory, file systems and the system-call boundary.
  • Networking: from a voltage on a wire to HTTP/3, through routing, congestion control and TLS.
  • Compilers: lexers, parsers, type checkers, intermediate forms and optimisers, down to machine code.