v7.3.0 llm.txt Download
DocsArchitecture

Reference · docs/architecture.md

Architecture

Boundaries

This repository owns one thing: the Cardsite visual language as files. It draws, builds and documents icons and brand assets. It doesn't own Studio's design system (pinned and vendored), the Cardsite mark (fixed artwork from the Partner Kit), partner logos (their owners' trademarks), or any product that uses the icons.

src/                 →  tools/  →  build/            the package (committed)
vendor/ + overrides  →  tools/  →  public/design/    the design kit
docs/ + build/       →  tools/  →  public/, index.html   the site

Everything right of an arrow is generated, carries a "do not edit" header, and is checked for drift by make validate.

Contracts

Contract Where Promise
Icon names src/taxonomy.txt → build/manifest.json A name never changes meaning within a major version. A removed or renamed name stays as an alias for at least one major version
Geometry build/svg/<style>/<name>.svg 24 × 24 viewBox, filled paths only, currentColor, no strokes, masks, scripts or external references, correct under the non-zero fill rule
JS API build/js/cardsite-icons.d.ts svg(), resolve(), ICONS, ALIASES, MIN_SIZE, STYLES, names, VERSION
React build/react/CsIcon.tsx <CsIcon name variant size title tone>
Tokens build/tokens/tokens.css, public/design/tokens.css Roles named --cs-icon-*, --cs-tile-*, --cs-ill-*, --cs-file-*; values come only from Studio plus overrides.json
Agents tools/mcp/server.mjs, tools/cli.mjs, public/llm.txt Read-only access to build/; no network, no writes

Data model

  • Taxonomy entry: name, category, metaphor, tags, legacy aliases (src/taxonomy.txt, one line each). minSize and the container exemption come from lists in tools/lib/taxonomy.mjs.
  • Source icon: a stroke skeleton in SVG with a small class vocabulary (plate, solid, dot, fill, ko, front, accent), defined in construction.
  • Style: stroke width and knockout gap: Light 1.25 / 1.25, Regular 1.75 / 1.5, Bold 2.5 / 1.75, Duotone 1.75 / 1.5 plus a 20 % plate, Fill 2.0 / 1.5 (the plate made solid, with details cut out).
  • Manifest: every icon with its metadata, the brand index, and the legacy map from v6 names to brand assets.

How a source becomes an icon

tools/engine/geometry.mjs runs Skia path operations through CanvasKit, which is WebAssembly, so results are identical on every platform (ADR 0003). For each style it:

  1. parses the source and bakes fillets (data-r) into the path;
  2. strokes every line at the style's width, with flat ends and round joins (computed at 64× and scaled back, so circles stay true to within 0.01 unit);
  3. grows or shrinks solid shapes and dots with the weight;
  4. cuts knockouts (ko: around the stroke; front: the whole enclosed area) by the style's gap;
  5. unions everything into one line path, and subtracts it from the plate for Duotone; for Fill, the plate is made solid and the line inside it becomes negative space;
  6. orients each contour by its containment depth, so the output is correct under SVG's default non-zero fill rule.

Surfaces

Surface Path Audience
Package build/ (npm @csxbase/cardsite-icons) product engineers
Site public/: landing, collection, design kit, system graph, docs, llm.txt designers, engineers, agents
Root page index.html anyone who just unzipped the repository
CLI and MCP server tools/cli.mjs, tools/mcp/server.mjs scripts and AI agents

The public/ site is static and opens from disk. Fonts are self-hosted, every path is relative, and it makes no external requests and has no runtime dependencies.

Two small scripts ship with it, both local:

  • public/assets/site.js (hand-written): the light, dark and system theme switch (stored in localStorage and applied as data-theme on <html>, which tokens.css already reads), the compact site menu, and copy buttons on code blocks. Every page loads it with defer. A one-line script in <head> applies the stored theme before first paint.
  • public/assets/prism.js (generated): syntax highlighting for the collection's detail panel, which builds its SVG, React and JavaScript snippets in the browser. Everything else (docs code blocks, the landing and root page snippets) is highlighted at build time by tools/site/prism.mjs, so those pages need no JavaScript.

Both come from vendor/prism-1.30.0/ (vendor/prism-1.30.0/README.md): a trimmed, MIT-licensed fork of Prism 1.30.0 with only the grammars the site needs, manual mode, and an SVG path-data token. Its theme is the "code" section of site.css, built from the --color-code-* tokens that tools/design/build.mjs solves to AA contrast from overrides.json.

Testing strategy

make validate runs, in order:

  1. Lockfile: the lockfile pins every platform's native binary, so npm ci works on macOS, Linux and Windows.
  2. Design tokens: public/design/ matches the pinned system plus overrides, and site.css and hand-written pages use tokens only.
  3. Site: generated pages and index.html match the generator.
  4. Dev logins: every default in .env.example and the code is listed in dev logins.
  5. Typecheck: tsc over the React component and type definitions.
  6. Lint: icon sources against the construction rules.
  7. Tests: node --test. Covers the engine, the JS API, every v6 name resolving, the CLI, the MCP server, output safety (no script or external references), and a drift check on build/.

make e2e runs browser checks against the served site (light and dark, 390 px and 1440 px, no overflow, no console errors, no broken links). Visual review uses the QA sheets (QA).