Skip to main content

SENIOR SOFTWARE ENGINEER · SYSTEM ARCHITECT

Blog · Design Systems

Atomic layers without stylesheet sprawl

How strict L0–L5 contracts let dozens of multi-tenant sites share one engine without per-page CSS hacks.

Architecture

Category

5 min read

Reading time

Nov 2026

Published

Design Systems, Go, CSS Tokens

Topics

Summary

Most multi-tenant platforms start with a clean component library and slowly decay into a pile of per-client CSS overrides. Six months in, every accessibility fix or layout refactor risks breaking a customer's live homepage.

When I designed the web engine inside Yin Business, I made a hard rule: a site is pure validated JSON—a theme plus pages composed from atomic contracts. Components expose typed CSS custom properties and named variants, never free-form stylesheets. If a site needs something new, we add a universal capability to the library rather than patching one tenant.

Why strict atomic layers matter

In a typical CMS or visual page builder, customization happens by attaching arbitrary CSS rules to individual blocks. Early on, that feels fast. On my first attempt at migrating my own portfolio onto our platform, chasing visual parity with local overrides produced over 600 per-instance overrides across 33 blocks—and the pages still drifted on mobile.

The fix was separating visual responsibility into six strict layers where each layer can only compose from the layers below it:

  • L0 Theme tokens: Palette roles, typography scale, spacing scale, border widths, radii, soft and hard shadows, motion timings, and layout gutters. Changing a single token cascades across the entire site.
  • L1 Atoms: Pure primitives with zero business logic—buttons, headings, badges, chips, inputs, icons, and links. Every button on a site is rendered by the button atom and nothing else.
  • L2 Molecules & L3 Organisms: Composed groups such as stat tiles, cards, navbars, filter grids, and modals. They steer their child atoms exclusively through declared component CSS variables.
  • L4 Sections & L5 Pages: Data-only compositions with content slots. A section never invents new markup or hardcodes brand colors.

Because every component declares a machine-readable contract—its layer, typed props, slots, stylable parts, variants, and allowed CSS variables—the Go renderer and the visual editor validate every page before it ever publishes. There is no guesswork and no silent stylesheet sprawl.

Enforcing contrast and brand safety by contract

Design systems often break the moment a customer brings a high-energy brand palette. Take this portfolio's own palette: vivid volt #D2FF00 paired with warm stone #F4F4ED and deep ink #1C1E17. If a component blindly uses --y-color-primary for body links, borders, or text on a light background, WCAG contrast fails immediately.

To prevent that class of bug structurally, L0 separates surface roles from foreground ink roles:

  • --y-color-primary & --y-color-on-primary: Volt fills always pair with dark ink text, never white.
  • --y-color-ink & --y-color-on-ink: Dark panels automatically flip nested text, leads, and status badges to currentColor so nothing disappears on dark surfaces.
  • --y-color-border & --y-color-border-strong: Structural rules and focus rings read ink-derived tokens rather than accent colors.

Customization then splits into exactly two scopes: Everywhere (editing a site's global definition of an atom or theme token, which updates every page at once) and Only here (a scoped instance override that can always be reset back to the global default). That single boundary keeps ten-page sites and hundred-page sites equally maintainable.

Atomic token compilation pipeline

Zero runtime CSS-in-JS
  • Theme JSONL0
  • Site library overridesL1–L4
  • Contract validatorGo
  • Minified page CSS + :rootCompiler
  • Sub-15ms HTML shellEdge
  • Small JS behavioursOptional

Key trade-offs

Trade-off 01

Reject undeclared CSS properties at validation time

Every component stylesheet is checked by contract tests so organisms can only steer child atoms through declared custom properties. Adding a new layout knob takes a deliberate contract update instead of a quick inline hack, which slows down one-off tweaks slightly but eliminates cross-tenant regressions.

Trade-off 02

Compile CSS per route from the component graph

Rather than shipping a monolithic utility bundle on every request, the Go engine walks the JSON tree of a page and compiles only the theme tokens, component rules, and variants that page actually uses. Keeping the emitted CSS pruned is an ongoing discipline—whenever a site library grows, we audit the compiled HTML output directly to catch unused variant bloat.

Trade-off 03

Prove equivalence by construction, not screenshot tweaking

A component is only considered done when its JSON contract, Go renderer, and automated golden tests exist together. That lets us upgrade shared atoms across every tenant site with confidence instead of manually checking screenshots for every customer.

Continue reading

Have an architecture challenge to discuss?

Get in touch for staff-level architecture advisory or product collaboration.

DIRECT MESSAGE

Hiring for a Senior/Staff Architect role, scaling a venture, or looking to collaborate?

Message sent

Thank you. I reply within 24 hours.

Sending…

hi@nazmulislamfahim.com

Thank you. I reply within 24 hours.