# supertypeai/foundations architecture

> Architecture diagram of the GitHub repository supertypeai/foundations, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/supertypeai/foundations
- Repository: https://github.com/supertypeai/foundations

## Overview

Foundations is a reusable React/Tailwind design system for typography, content blocks, and long-form essays, with supporting content metadata and consumer diagnostics. The principal workflow is a consuming app composing typography and blocks into pages or essays, styled by the package’s shared tokens and theme. The README documents additional SEO, Open Graph, MDX, lint, contrast, and CLI capabilities. Some of those implementations are unsampled; their presence is documented, but uncertain internal connections are omitted.

Main entry points: [`src/typography/paragraph.tsx`](https://github.com/supertypeai/foundations/blob/main/src/typography/paragraph.tsx) (Typography), [`src/cn.ts`](https://github.com/supertypeai/foundations/blob/main/src/cn.ts) (Class utilities), [`src/blocks/tabs.tsx`](https://github.com/supertypeai/foundations/blob/main/src/blocks/tabs.tsx) (Tabs), [`src/essay/essay.tsx`](https://github.com/supertypeai/foundations/blob/main/src/essay/essay.tsx) (Essay shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Shared foundations"]
  node_class_utils["Class utilities<br/>[cn.ts]"]
  node_tone["Tone system<br/>[tone.ts]"]
  node_links["Link resolution<br/>[href.ts]"]
  node_css_system["Tokens and themes"]
end

subgraph group_components["UI components"]
  node_typography["Typography<br/>[paragraph.tsx]"]
  node_typography_headers["Headings<br/>[header.tsx]"]
  node_blocks["Content blocks"]
  node_tabs["Tabs<br/>[tabs.tsx]"]
end

subgraph group_essay["Essay experience"]
  node_essay_shell["Essay shell<br/>[essay.tsx]"]
  node_essay_layout["Essay layout<br/>[layout.tsx]"]
  node_essay_reading["Reading tools<br/>[reading.tsx]"]
  node_essay_scroll["Scroll tracking<br/>[scroll.ts]"]
  node_essay_toc["TOC and reading time<br/>[toc.ts]"]
end

subgraph group_content["Content and metadata"]
  node_mdx["MDX components<br/>[mdx.tsx]"]
  node_rehype["Rehype plugin<br/>[rehype.ts]"]
  node_seo["SEO metadata<br/>[seo.ts]"]
  node_og["Open Graph cards<br/>[og.tsx]"]
  node_contrast["Contrast checks<br/>[contrast.ts]"]
  node_eslint["Lint rules<br/>[eslint.ts]"]
end

subgraph group_tooling["Consumer tooling"]
  node_cli["Foundations CLI<br/>[foundations.mjs]"]
end

node_consumer(("Consuming app"))

node_consumer -->|"composes"| node_typography
node_consumer -->|"composes"| node_blocks
node_consumer -->|"builds essays"| node_essay_shell
node_consumer -->|"imports styles"| node_css_system
node_typography -->|"merges classes"| node_class_utils
node_typography -->|"applies tone"| node_tone
node_typography -->|"resolves links"| node_links
node_typography -.->|"shares primitives"| node_typography_headers
node_blocks -.->|"uses classes"| node_class_utils
node_tabs -->|"merges classes"| node_class_utils
node_tabs -->|"applies tone"| node_tone
node_tabs -.->|"specializes blocks"| node_blocks
node_essay_shell -->|"merges classes"| node_class_utils
node_essay_layout -->|"uses TOC"| node_essay_toc
node_essay_reading -->|"uses tracking"| node_essay_scroll
node_essay_reading -->|"uses TOC"| node_essay_toc
node_essay_shell -.->|"pairs with layout"| node_essay_layout
node_mdx -->|"merges classes"| node_class_utils
node_consumer -->|"renders content"| node_mdx
node_consumer -.->|"configures plugin"| node_rehype
node_consumer -.->|"adds metadata"| node_seo
node_consumer -.->|"generates cards"| node_og
node_consumer -.->|"checks contrast"| node_contrast
node_consumer -.->|"uses lint rules"| node_eslint
node_consumer -->|"runs diagnostics"| node_cli
node_cli -->|"checks app wiring"| node_consumer
node_contrast -->|"reads tones"| node_tone

click node_typography "https://github.com/supertypeai/foundations/blob/main/src/typography/paragraph.tsx"
click node_typography_headers "https://github.com/supertypeai/foundations/blob/main/src/typography/header.tsx"
click node_blocks "https://github.com/supertypeai/foundations/tree/main/src/blocks"
click node_tabs "https://github.com/supertypeai/foundations/blob/main/src/blocks/tabs.tsx"
click node_essay_shell "https://github.com/supertypeai/foundations/blob/main/src/essay/essay.tsx"
click node_essay_layout "https://github.com/supertypeai/foundations/blob/main/src/essay/layout.tsx"
click node_essay_reading "https://github.com/supertypeai/foundations/blob/main/src/essay/reading.tsx"
click node_essay_scroll "https://github.com/supertypeai/foundations/blob/main/src/essay/scroll.ts"
click node_essay_toc "https://github.com/supertypeai/foundations/blob/main/src/essay/toc.ts"
click node_class_utils "https://github.com/supertypeai/foundations/blob/main/src/cn.ts"
click node_tone "https://github.com/supertypeai/foundations/blob/main/src/tone.ts"
click node_links "https://github.com/supertypeai/foundations/blob/main/src/href.ts"
click node_mdx "https://github.com/supertypeai/foundations/blob/main/src/mdx.tsx"
click node_rehype "https://github.com/supertypeai/foundations/blob/main/src/rehype.ts"
click node_seo "https://github.com/supertypeai/foundations/blob/main/src/seo.ts"
click node_og "https://github.com/supertypeai/foundations/blob/main/src/og.tsx"
click node_contrast "https://github.com/supertypeai/foundations/blob/main/src/contrast.ts"
click node_eslint "https://github.com/supertypeai/foundations/blob/main/src/eslint.ts"
click node_cli "https://github.com/supertypeai/foundations/blob/main/bin/foundations.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_class_utils,node_tone,node_links,node_css_system toneBlue
class node_typography,node_typography_headers,node_blocks,node_tabs toneAmber
class node_essay_shell,node_essay_layout,node_essay_reading,node_essay_scroll,node_essay_toc toneMint
class node_mdx,node_rehype,node_seo,node_og,node_contrast,node_eslint toneRose
class node_cli,node_consumer toneIndigo
```

## Components

### Shared foundations

- [Class utilities](https://github.com/supertypeai/foundations/blob/main/src/cn.ts): `src/cn.ts`
- [Tone system](https://github.com/supertypeai/foundations/blob/main/src/tone.ts): `src/tone.ts`
- [Link resolution](https://github.com/supertypeai/foundations/blob/main/src/href.ts): `src/href.ts`
- **Tokens and themes**

### UI components

- [Typography](https://github.com/supertypeai/foundations/blob/main/src/typography/paragraph.tsx): `src/typography/paragraph.tsx`
- [Headings](https://github.com/supertypeai/foundations/blob/main/src/typography/header.tsx): `src/typography/header.tsx`
- [Content blocks](https://github.com/supertypeai/foundations/tree/main/src/blocks): `src/blocks`
- [Tabs](https://github.com/supertypeai/foundations/blob/main/src/blocks/tabs.tsx): `src/blocks/tabs.tsx`

### Essay experience

- [Essay shell](https://github.com/supertypeai/foundations/blob/main/src/essay/essay.tsx): `src/essay/essay.tsx`
- [Essay layout](https://github.com/supertypeai/foundations/blob/main/src/essay/layout.tsx): `src/essay/layout.tsx`
- [Reading tools](https://github.com/supertypeai/foundations/blob/main/src/essay/reading.tsx): `src/essay/reading.tsx`
- [Scroll tracking](https://github.com/supertypeai/foundations/blob/main/src/essay/scroll.ts): `src/essay/scroll.ts`
- [TOC and reading time](https://github.com/supertypeai/foundations/blob/main/src/essay/toc.ts): `src/essay/toc.ts`

### Content and metadata

- [MDX components](https://github.com/supertypeai/foundations/blob/main/src/mdx.tsx): `src/mdx.tsx`
- [Rehype plugin](https://github.com/supertypeai/foundations/blob/main/src/rehype.ts): `src/rehype.ts`
- [SEO metadata](https://github.com/supertypeai/foundations/blob/main/src/seo.ts): `src/seo.ts`
- [Open Graph cards](https://github.com/supertypeai/foundations/blob/main/src/og.tsx): `src/og.tsx`
- [Contrast checks](https://github.com/supertypeai/foundations/blob/main/src/contrast.ts): `src/contrast.ts`
- [Lint rules](https://github.com/supertypeai/foundations/blob/main/src/eslint.ts): `src/eslint.ts`

### Consumer tooling

- [Foundations CLI](https://github.com/supertypeai/foundations/blob/main/bin/foundations.mjs): `bin/foundations.mjs`

### Other components

- **Consuming app**

## Connections

- Consuming app → Typography: composes (evidence: `README.md`)
- Consuming app → Content blocks: composes (evidence: `README.md`)
- Consuming app → Essay shell: builds essays (evidence: `README.md`)
- Consuming app → Tokens and themes: imports styles (evidence: `README.md`)
- Typography → Class utilities: merges classes (evidence: `src/typography/paragraph.tsx`)
- Typography → Tone system: applies tone (evidence: `src/typography/paragraph.tsx`)
- Typography → Link resolution: resolves links (evidence: `src/typography/paragraph.tsx`)
- Typography → Headings: shares primitives
- Content blocks → Class utilities: uses classes (evidence: `src/blocks/tabs.tsx`)
- Tabs → Class utilities: merges classes (evidence: `src/blocks/tabs.tsx`)
- Tabs → Tone system: applies tone (evidence: `src/blocks/tabs.tsx`)
- Tabs → Content blocks: specializes blocks (evidence: `src/blocks/tabs.tsx`)
- Essay shell → Class utilities: merges classes (evidence: `src/essay/essay.tsx`)
- Essay layout → TOC and reading time: uses TOC (evidence: `src/essay/layout.tsx`)
- Reading tools → Scroll tracking: uses tracking (evidence: `src/essay/reading.tsx`)
- Reading tools → TOC and reading time: uses TOC (evidence: `src/essay/reading.tsx`)
- Essay shell → Essay layout: pairs with layout
- MDX components → Class utilities: merges classes (evidence: `src/mdx.tsx`)
- Consuming app → MDX components: renders content (evidence: `README.md`)
- Consuming app → Rehype plugin: configures plugin
- Consuming app → SEO metadata: adds metadata
- Consuming app → Open Graph cards: generates cards
- Consuming app → Contrast checks: checks contrast
- Consuming app → Lint rules: uses lint rules
- Consuming app → Foundations CLI: runs diagnostics (evidence: `README.md`)
- Foundations CLI → Consuming app: checks app wiring (evidence: `README.md`)
- Contrast checks → Tone system: reads tones (evidence: `src/contrast.ts`)
