Reality A, teardown.

LIVE SPECIMEN — L. candidum — interact with the systemLIVE SPECIMEN — L. candidum, exploded — interact with the system

Adnan HusainSystems · markets · browser tools

I take things apart to find out how they work.

Systems software developer

Final-year computer science. Nine projects in three groups: systems built up from the rule, markets, and tools that run entirely in the browser. Mostly Rust, with some C++ and TypeScript.

Every figure is the real rule, running. Scroll to take it apart.

drawn by
Adnan Husain
sheet
01 of 01
parts
09
scale
1 : 1
units
px
status
final year
scroll to take it apart

Parts list

drag to reorder · alt + arrows to move · order is saved

  1. P-0164 × 32 PX CHIP-8 emulator rust · minifb Systemscomplete
  2. P-02ZERO COPIES A grep clone rust · memmap · regex Systemscomplete
  3. P-03PENDING → 0 Concurrent web crawler rust · tokio · reqwest Systemscomplete
  4. P-04DIFFICULTY husaynex rust · blake3 Systemscomplete
  5. P-05INVENTORY SKEW Avellaneda-Stoikov market maker c++17 · imgui · implot Marketscomplete
  6. P-06BPS / ROUND TRIP Haircut typescript · solana · pyth Marketslive
  7. P-07SPREAD Δ Solana arbitrage bot rust · tokio · jito Marketsin progress
  8. P-080 BYTES SENT UPInsight typescript · pdf.js · web workers · ocr Browser toolslive
  9. P-0910 MB CHUNKS LocalCrunch rust · wasm · web worker Browser toolslive

R-14 partsP-01 – P-04

Systems

built up from the rule

P-0164 × 32 PX

CHIP-8 emulator

rust · minifb

An interpreter for a 1970s virtual machine: 35 instructions, 4 KB of memory, and a display that draws sprites by XOR, so anything overlapping erases rather than stacks.

opcodes00/35last----drawidleVF0

Anything overlapping erases rather than stacks.

language
Rust
display
64 × 32
opcodes
35
clocks
700 Hz · 60 Hz
status
complete

The interpreter loop and the timers run on separate clocks: 700 Hz for instructions, 60 Hz for the timers, both independent of the display refresh. Share one and instruction throughput fights frame timing: fast enough to feel responsive and the display tears; slowed to 60 Hz and the games crawl.

P-02ZERO COPIES

A grep clone

rust · memmap · regex

Line-by-line matching spent most of its time allocating rather than comparing. Memory-mapping the file and matching over borrowed slices removed the copies entirely.

pattern"timeout"head0x0000matches0copies:0allocs / line0

Nothing is copied in order to be looked at.

language
Rust
approach
mmap + slices
allocations
none per line
status
complete

Profiling put the allocator above the matcher. Memory-mapping hands you the file as one borrowed slice, so a match becomes a pair of offsets into memory the kernel already paged in. Nothing is copied in order to be looked at.

P-03PENDING → 0

Concurrent web crawler

rust · tokio · reqwest

Throughput is bounded by other people’s servers, not by my code, so the work is restraint: capped concurrency, robots.txt and per-origin crawl delays, hard limits on pages and depth.

queue0in flight0/4pages0/24duplicates0pending1queue isopen

The crawl ends when nothing is pending, not when the queue looks empty.

language
Rust
runtime
Tokio
politeness
robots.txt · crawl-delay
status
complete

The queue is unbounded on purpose. Workers both consume and produce, so a bounded queue deadlocks the moment every worker blocks on a full one. What bounds the crawl instead is the visited set and a page slot reserved atomically before each fetch. A pending counter covers queued plus in-flight work; when it reaches zero the queue closes and the workers exit.

P-04DIFFICULTY

husaynex

rust · blake3

A blockchain written from first principles: blocks, hashes, a difficulty, and a loop that keeps guessing until the leading digits come out right.

difficulty3 hex zerosguesses0is_valid()truehash32-bit stand-in for blake3

The nonce is an integer you increment. There is no cleverness in the search at all.

language
Rust
consensus
proof of work
hash
blake3
status
complete

Each block commits to the hash of the one before it, so validation is recomputation: index continuity, the previous hash, the block’s own hash, then the proof of work. Change one byte and that block’s hash moves, the next block is left pointing at a hash that no longer exists, and repairing it means mining every later block again. Difficulty is a count of leading hex zeros, so it moves in steps of sixteen. The nonce is an integer you increment; there is no cleverness in the search at all.

R-23 partsP-05 – P-07

Markets

prices, spreads, inventory

P-05INVENTORY SKEW

Avellaneda-Stoikov market maker

c++17 · imgui · implot

An implementation of the Avellaneda-Stoikov paper: a market maker quoting both sides of a mid-price, with the quotes moving as inventory, volatility and time left in the session change. One engine drives a CLI, a native GUI and a browser dashboard, run against a random walk or real historical prices.

inventory q0r − s0.00spread δ0.00T − t1.00r = s − qγσ²(T−t)γ 0.1 · σ 2 · k 1.5

Quote around the price you are indifferent at, not the mid.

language
C++17
based on
Avellaneda & Stoikov, 2008
frontends
CLI · ImGui · web
status
complete

I built it to understand how market making actually works rather than to produce anything new, and the code was the easy half. The idea worth the attention is the reservation price: not the mid, but the price you are indifferent to holding your current inventory at. Quote around that instead and the skew that unloads a position falls out of the model rather than being bolted on. Everything the paper leaves out (an order book with depth, queue position, what happens when its assumptions do not hold) is where the rest of the work went.

P-06BPS / ROUND TRIP

Haircut

typescript · solana · pyth

What a tokenized stock actually costs to trade on Solana. Buy $N and sell it straight back; whatever does not come back is the cost. Round-tripping $10,000 of METAx costs $126, the same trade in SPYx costs $3.

round trip · buy $10,000, sell it straight back

METAx $10,000.00 came back$10,000.00
SPYx $10,000.00 came back$10,000.00
    size$10,000quotesJupiter, livemeasured2026-09-14 16:14 UTCreference pricenone needed

    Whatever does not come back is the cost.

    language
    TypeScript
    chain
    Solana · Token-2022
    spread
    42× at $10k
    status
    live

    A round trip needs no reference price, and that matters: Jupiter’s price is an index, not the mid of the pool you route through, and measuring against it put METAx at −4.4 bps, buying below mid. Both legs are quoted in raw units, so Token-2022’s scaled-UI multiplier cancels too; ignore it anywhere else and a holding is off by up to 57 bps.

    P-07SPREAD Δ

    Solana arbitrage bot

    rust · tokio · jito

    Two exchanges disagree on a price for a few hundred milliseconds. Polling returned too late, so market state lives in memory and WebSocket pushes mutate it in place.

    1. compute budget
    2. swap A
    3. swap B
    4. jito tip
    5. simulate
    pushes0spread+0.00%fees0.29%net−0.29%simulated0RwLockread ×3

    One shared truth, briefly locked.

    language
    Rust
    venues
    Raydium · Orca
    ingestion
    WebSocket push
    execution
    simulated · Jito bundles
    status
    in progress

    State sits behind an Arc<RwLock<…>>: many readers evaluating, one writer applying each push. Channels were the alternative, but then every consumer keeps its own copy of the book and they drift under load. One shared truth, briefly locked.

    R-32 partsP-08 – P-09

    Browser tools

    the file never leaves the tab

    P-080 BYTES SENT

    UPInsight

    typescript · pdf.js · web workers · ocr

    UPI and bank statement analytics that runs entirely in the browser. Drop in a PhonePe or Google Pay PDF; it comes back as categorised transactions, recurring payments and cashflow, and none of it leaves the device.

    pdf.js text layer · sample statement

      transactions

        anchors0blocks0threadweb workerbytes sent0

        Anchor on the one thing every transaction has: a date and a time.

        language
        TypeScript
        runs
        browser only
        parse
        pdf.js + Tesseract
        status
        live

        Statements are chaos as text, so parsing anchors on the one thing every transaction has: a date and time. Lines are split into blocks at those anchors, then vendor, amount, UTR and direction are pulled out of each block. Extraction runs in a Web Worker so the page never freezes, and scanned pages with no text layer fall back to OCR.

        P-0910 MB CHUNKS

        LocalCrunch

        rust · wasm · web worker

        A data profiler that runs in the browser. Drop in a CSV and get column types, distributions, missing values, duplicates and quality problems, then filter and explore, and the file never leaves your machine.

        read0 Bheld1 chunkcarry0 Brows0mean0.00sd (Welford)0.00

        Size is limited by time, not memory.

        language
        Rust → WASM
        memory
        bounded, streamed
        tests
        chunk edges, quoted newlines
        status
        live

        A Rust engine compiled to WebAssembly streams the file through a worker in 10 MB chunks, so size is limited by time, not memory. Chunks rarely end on a record, so the unfinished tail is carried into the next one. Stats are single-pass (Welford), duplicates are 64-bit row fingerprints rather than rows, and medians come from a reservoir sample.

        Nwriting

        Notes, in progress

        not published yet

        1. N-01What XOR sprites taught me about statein draft
        2. N-02Polling is a bet that nothing happenedin draft
        3. N-03Reading a binary with no documentationoutlined