jonnify·bcs /bcs

BCS · the Branded Component System

Boundaries around systems, not objects.

Object orientation drew the encapsulation boundary around the object. The Branded Component System keeps encapsulation and moves the boundary outward, around the system: a system is a process that owns its private state and shares nothing, a component is data with no behaviour, and the only value that crosses a boundary is a branded identity — a fourteen-byte name — and messages about it.

The successor to Entity-Component-System, adapted to the BEAM: it gives up the shared component arrays of classic ECS for distribution and fault tolerance. Nine chapters, B0 to B8, with the Cache in depth.

The law in one picture: each system owns its state, and only a branded id and messages about it cross. Select a field of the id to read its job.
system A · owns the USR state one process · a private table USR0KHTOWnGLuCproperties USR0NgWEfAEJfsproperties USR… owned here · never shared the one value that crosses USR0KHTOWnGLuC a branded id, and messages about it object graph refused · no object, no id list system B · keeps its own state one process · a private table ROM…USR0KHTOWnGLuC ROM…properties ROM… holds the name · asks the owner system A · owns the USR state one process · a private table USR0KHTOWnGLuCproperties USR0NgWEfAEJfsproperties USR… owned here · never shared USR0KHTOWnGLuC the one value that crosses a branded id + messages refused object graph one process · a private table ROM…USR0KHTOWnGLuC ROM…properties ROM… holds the name · asks the owner system B · keeps its own state the name, taken apart USRnamespace 0KHTOWnGLuC eleven base62 = the 63-bit snowflake below timestamp · 41 bits node · 10 seq · 12 epoch 2024-01-01 · horizon September 2093
readout · Select a field. The first three characters are the type; the remaining eleven are the instant, the machine, and the order within the millisecond.
§1

How to read this course

the reading order
  1. Start with B0. Three dives carry the whole idea — the one relocation, identity as a contract, the stack and the floor — and every other chapter elaborates one of them.
  2. Read down the stack. B1 and B2 lay the identity and the Elixir core; B3 is the bus; B4 and the Cache are the near-cache; B5 is the durable floor beneath it all. B6 composes the libraries into one umbrella, B7 is the course’s worked example written on top, and B8 is the production shape on Fly.
  3. Take each figure apart. A chapter is a landing and its dives; B2, the Cache and B7 group their dives into modules. Each dive is one idea with one figure: select a part to read its job.
  4. Trust what the tree proves. The course keeps one rule: a number the committed tree cannot prove does not appear. The contract’s own figures are the vectors echo_data asserts at boot, before either code path is trusted.
The stack the course builds, top to bottom, and the chapter that teaches each tier.
your systemswritten against BCSB1 · B7 echo_databranded id · stores · CHAMPB2 echo_mqthe bus, on ValkeyB3 echo_storethe declared near-cacheB4 · Cache the durable floorCubDB volume · Tigris remoteB5 B6 B6 · the libraries as one umbrella
echo_data · the vectors self_check! asserts at boot (placement is hash32 of the parsed snowflake)verified
placement(USR0KHTOWnGLuC)        →  234878118            native and pure agree
parse(USR0NgWEfAEJfs)            →  {:ok, "USR", 320636799581945856}
decode(USRzzzzzzzzzzz)           →  :error               an overflow is refused, not wrapped
§2

Course map

B0–B8 · the Cache in depth
  1. B0

    Overview

    The shortest path in: the one move the system makes, the contract that move leaves behind, and the shape of the stack the course builds.

    3 dives

  2. B1

    Ideas Behind

    The conceptual floor: the system substrate, the identity contract read as architecture, and the step from ECS to BCS.

    3 dives

  3. B2

    The Elixir BCS Core

    The law landed on OTP and ETS: a system as an OTP application, property stores, the CHAMP forest, archetypes composed by a fold, relations as systems, and the gate at the boundary.

    6 modules · 21 dives

  4. B3

    The Bus

    EchoMQ, the bus the stack uses, where the BCS law meets the network: between systems, only branded identities and messages about them cross.

    3 dives

  5. B4

    EchoStore

    The declared near-cache: L1 ETS tables in front of the shared L2 Valkey, one fill per herd, and coherence by mint time.

    3 dives

  6. B4

    The Cache, in depth

    The near-cache built out: cache-aside at ETS speed, coherence by mint time, the single writer and its ring, and the lane that remembers.

    in depth4 modules · 12 dives

  7. B5

    The Persistence Floor

    Where state lives when the heap is gone: a single-writer engine on CubDB, a lazy reader at a snapshot, and a portable remote on Tigris.

    3 dives

  8. B6

    Putting It All Together

    The four libraries as one dependency-ordered umbrella: one write all the way down, one read all the way up.

    3 dives

  9. B7

    Codemojex

    The course’s worked example: a game in the Mastermind family, modelled as branded systems from its rooms and modes to fair-lane guesses, scoring and settlement, its economy, and its live surface.

    6 modules · 18 dives

  10. B8

    Production on Fly

    The production shape on Fly: the release and its image, Valkey on its own Fly machine, the bus’s setup and monitoring, and the fly.toml beside a local stack.

    4 dives

Every chapter and module on this map is a page in the course. A chapter title opens its landing; a numbered line opens the module or dive itself.

§3

The doors

related courses
§4

References

sources · related

Sources

Related in this course