Build It Yourself: System Components in TypeScript
Build a cache, consistent hash ring, message broker, circuit breaker, CQRS system and more in 50–150 lines of readable TypeScript, each with a live playground.
- Build Your Own Cache — put(), get(), LRU eviction and TTL expiry.
- Build a Consistent Hash Ring — Virtual nodes and minimal key movement when servers change.
- Build a Mini Message Broker — Topics, partitions, offsets and consumer groups in ~100 lines.
- Build a Retry Mechanism — Exponential backoff with jitter and a retry budget.
- Build a Circuit Breaker — Closed, open and half-open states with a failure threshold.
- Build a Simple Event Bus — Publish/subscribe with isolated subscriber failures.
- Build a Repository — A collection-like interface backed by an in-memory store.
- Build a Unit of Work — Track new, dirty and removed objects; commit them together.
- Build a Simple CQRS System — Commands update a write model; events project read models.