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).minSizeand the container exemption come from lists intools/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
legacymap 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:
- parses the source and bakes fillets (
data-r) into the path; - 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);
- grows or shrinks
solidshapes and dots with the weight; - cuts knockouts (
ko: around the stroke;front: the whole enclosed area) by the style's gap; - 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;
- 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 inlocalStorageand applied asdata-themeon<html>, whichtokens.cssalready reads), the compact site menu, and copy buttons on code blocks. Every page loads it withdefer. 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 bytools/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:
- Lockfile: the lockfile pins every platform's native binary, so
npm ciworks on macOS, Linux and Windows. - Design tokens:
public/design/matches the pinned system plus overrides, andsite.cssand hand-written pages use tokens only. - Site: generated pages and
index.htmlmatch the generator. - Dev logins: every default in
.env.exampleand the code is listed in dev logins. - Typecheck:
tscover the React component and type definitions. - Lint: icon sources against the construction rules.
- 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 onbuild/.
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).