# esaltws/salt-theme-gen architecture

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

- Interactive diagram: https://gitdiagram.com/esaltws/salt-theme-gen
- Repository: https://github.com/esaltws/salt-theme-gen

## Overview

salt-theme-gen is a dependency-free TypeScript design-token generator. Consumers provide a primary color or curated preset, then `generateTheme` builds light and dark themes with semantic colors, palettes, states, elevations, scale tokens, and WCAG/APCA reports. Separate public functions adjust and compare themes, validate deserialized themes, simulate color-vision deficiencies, and export CSS, Tailwind, or DTCG formats. The graph follows documented and excerpted calls; links to unsampled but documented capabilities are cited to the README.

Main entry points: [`src/generate-theme.ts`](https://github.com/esaltws/salt-theme-gen/blob/main/src/generate-theme.ts) (Theme generator), [`src/color-math.ts`](https://github.com/esaltws/salt-theme-gen/blob/main/src/color-math.ts) (OKLCH color math), [`src/adjust-theme.ts`](https://github.com/esaltws/salt-theme-gen/blob/main/src/adjust-theme.ts) (Theme adjustment), [`src/on-colors.ts`](https://github.com/esaltws/salt-theme-gen/blob/main/src/on-colors.ts) (Contrast reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Theme generation"]
  node_api["Public API<br/>[index.ts]"]
  node_theme["Theme generator<br/>[generate-theme.ts]"]
  node_presets["Color presets<br/>[nature-presets.ts]"]
  node_adjust["Theme adjustment<br/>[adjust-theme.ts]"]
  node_diff["Theme comparison<br/>[diff-theme.ts]"]
  node_validate["Theme validation<br/>[validate.ts]"]
  node_theme_result["Generated theme<br/>[generate-theme.ts]"]
end

subgraph group_color["Color and accessibility"]
  node_derive["Semantic colors<br/>[butterfly.ts]"]
  node_math["OKLCH color math<br/>[color-math.ts]"]
  node_contrast["Contrast reports<br/>[on-colors.ts]"]
  node_states["Interactive states<br/>[state-colors.ts]"]
  node_simulation["Color-vision simulation<br/>[color-blindness.ts]"]
end

subgraph group_tokens["Token scales"]
  node_scales["Scale presets"]
  node_palettes["Tonal palettes<br/>[palettes.ts]"]
end

subgraph group_outputs["Exports and utilities"]
  node_css["CSS variables<br/>[css-variables.ts]"]
  node_tailwind["Tailwind config<br/>[tailwind.ts]"]
  node_dtcg["DTCG tokens<br/>[dtcg.ts]"]
end

node_consumer(("Library consumer"))

node_consumer -->|"imports"| node_api
node_api -->|"exports"| node_theme
node_theme -->|"reads preset"| node_presets
node_theme -->|"reads scales"| node_scales
node_theme -->|"parses colors"| node_math
node_theme -->|"derives colors"| node_derive
node_derive -->|"uses color math"| node_math
node_derive -->|"checks contrast"| node_contrast
node_theme -->|"builds palettes"| node_palettes
node_palettes -->|"uses color math"| node_math
node_theme -->|"derives states"| node_states
node_states -->|"uses color math"| node_math
node_states -->|"corrects contrast"| node_contrast
node_theme -->|"builds reports"| node_contrast
node_theme -->|"returns theme"| node_theme_result
node_consumer -->|"adjusts theme"| node_adjust
node_consumer -->|"compares themes"| node_diff
node_consumer -->|"parses theme"| node_validate
node_consumer -->|"simulates colors"| node_simulation
node_consumer -->|"exports CSS"| node_css
node_consumer -->|"exports config"| node_tailwind
node_consumer -->|"exports tokens"| node_dtcg
node_adjust -->|"uses color math"| node_math
node_adjust -->|"checks contrast"| node_contrast
node_adjust -->|"rebuilds states"| node_states
node_adjust -->|"rebuilds palettes"| node_palettes
node_simulation -->|"uses color math"| node_math
node_simulation -->|"recomputes reports"| node_contrast

click node_api "https://github.com/esaltws/salt-theme-gen/blob/main/src/index.ts"
click node_theme "https://github.com/esaltws/salt-theme-gen/blob/main/src/generate-theme.ts"
click node_presets "https://github.com/esaltws/salt-theme-gen/blob/main/src/presets/nature-presets.ts"
click node_scales "https://github.com/esaltws/salt-theme-gen/tree/main/src/presets"
click node_derive "https://github.com/esaltws/salt-theme-gen/blob/main/src/butterfly.ts"
click node_math "https://github.com/esaltws/salt-theme-gen/blob/main/src/color-math.ts"
click node_contrast "https://github.com/esaltws/salt-theme-gen/blob/main/src/on-colors.ts"
click node_states "https://github.com/esaltws/salt-theme-gen/blob/main/src/state-colors.ts"
click node_palettes "https://github.com/esaltws/salt-theme-gen/blob/main/src/palettes.ts"
click node_adjust "https://github.com/esaltws/salt-theme-gen/blob/main/src/adjust-theme.ts"
click node_diff "https://github.com/esaltws/salt-theme-gen/blob/main/src/diff-theme.ts"
click node_validate "https://github.com/esaltws/salt-theme-gen/blob/main/src/validate.ts"
click node_simulation "https://github.com/esaltws/salt-theme-gen/blob/main/src/color-blindness.ts"
click node_css "https://github.com/esaltws/salt-theme-gen/blob/main/src/css-variables.ts"
click node_tailwind "https://github.com/esaltws/salt-theme-gen/blob/main/src/tailwind.ts"
click node_dtcg "https://github.com/esaltws/salt-theme-gen/blob/main/src/dtcg.ts"
click node_theme_result "https://github.com/esaltws/salt-theme-gen/blob/main/src/generate-theme.ts"

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_api,node_theme,node_presets,node_adjust,node_diff,node_validate,node_theme_result toneBlue
class node_derive,node_math,node_contrast,node_states,node_simulation toneAmber
class node_scales,node_palettes toneMint
class node_css,node_tailwind,node_dtcg toneRose
class node_consumer toneIndigo
```

## Components

### Theme generation

- [Public API](https://github.com/esaltws/salt-theme-gen/blob/main/src/index.ts): `src/index.ts`
- [Theme generator](https://github.com/esaltws/salt-theme-gen/blob/main/src/generate-theme.ts): `src/generate-theme.ts`
- [Color presets](https://github.com/esaltws/salt-theme-gen/blob/main/src/presets/nature-presets.ts): `src/presets/nature-presets.ts`
- [Theme adjustment](https://github.com/esaltws/salt-theme-gen/blob/main/src/adjust-theme.ts): `src/adjust-theme.ts`
- [Theme comparison](https://github.com/esaltws/salt-theme-gen/blob/main/src/diff-theme.ts): `src/diff-theme.ts`
- [Theme validation](https://github.com/esaltws/salt-theme-gen/blob/main/src/validate.ts): `src/validate.ts`
- [Generated theme](https://github.com/esaltws/salt-theme-gen/blob/main/src/generate-theme.ts): `src/generate-theme.ts`

### Color and accessibility

- [Semantic colors](https://github.com/esaltws/salt-theme-gen/blob/main/src/butterfly.ts): `src/butterfly.ts`
- [OKLCH color math](https://github.com/esaltws/salt-theme-gen/blob/main/src/color-math.ts): `src/color-math.ts`
- [Contrast reports](https://github.com/esaltws/salt-theme-gen/blob/main/src/on-colors.ts): `src/on-colors.ts`
- [Interactive states](https://github.com/esaltws/salt-theme-gen/blob/main/src/state-colors.ts): `src/state-colors.ts`
- [Color-vision simulation](https://github.com/esaltws/salt-theme-gen/blob/main/src/color-blindness.ts): `src/color-blindness.ts`

### Token scales

- [Scale presets](https://github.com/esaltws/salt-theme-gen/tree/main/src/presets): `src/presets`
- [Tonal palettes](https://github.com/esaltws/salt-theme-gen/blob/main/src/palettes.ts): `src/palettes.ts`

### Exports and utilities

- [CSS variables](https://github.com/esaltws/salt-theme-gen/blob/main/src/css-variables.ts): `src/css-variables.ts`
- [Tailwind config](https://github.com/esaltws/salt-theme-gen/blob/main/src/tailwind.ts): `src/tailwind.ts`
- [DTCG tokens](https://github.com/esaltws/salt-theme-gen/blob/main/src/dtcg.ts): `src/dtcg.ts`

### Other components

- **Library consumer**

## Connections

- Library consumer → Public API: imports (evidence: `src/index.ts`)
- Public API → Theme generator: exports (evidence: `src/index.ts`)
- Theme generator → Color presets: reads preset (evidence: `src/generate-theme.ts`)
- Theme generator → Scale presets: reads scales (evidence: `src/generate-theme.ts`)
- Theme generator → OKLCH color math: parses colors (evidence: `src/generate-theme.ts`)
- Theme generator → Semantic colors: derives colors (evidence: `src/generate-theme.ts`)
- Semantic colors → OKLCH color math: uses color math (evidence: `src/butterfly.ts`)
- Semantic colors → Contrast reports: checks contrast (evidence: `src/butterfly.ts`)
- Theme generator → Tonal palettes: builds palettes (evidence: `src/generate-theme.ts`)
- Tonal palettes → OKLCH color math: uses color math (evidence: `src/palettes.ts`)
- Theme generator → Interactive states: derives states (evidence: `src/generate-theme.ts`)
- Interactive states → OKLCH color math: uses color math (evidence: `src/state-colors.ts`)
- Interactive states → Contrast reports: corrects contrast (evidence: `src/state-colors.ts`)
- Theme generator → Contrast reports: builds reports (evidence: `src/generate-theme.ts`)
- Theme generator → Generated theme: returns theme (evidence: `src/generate-theme.ts`)
- Library consumer → Theme adjustment: adjusts theme (evidence: `README.md`)
- Library consumer → Theme comparison: compares themes (evidence: `README.md`)
- Library consumer → Theme validation: parses theme (evidence: `README.md`)
- Library consumer → Color-vision simulation: simulates colors (evidence: `README.md`)
- Library consumer → CSS variables: exports CSS (evidence: `README.md`)
- Library consumer → Tailwind config: exports config (evidence: `README.md`)
- Library consumer → DTCG tokens: exports tokens (evidence: `README.md`)
- Theme adjustment → OKLCH color math: uses color math (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Contrast reports: checks contrast (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Interactive states: rebuilds states (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Tonal palettes: rebuilds palettes (evidence: `src/adjust-theme.ts`)
- Color-vision simulation → OKLCH color math: uses color math (evidence: `src/color-blindness.ts`)
- Color-vision simulation → Contrast reports: recomputes reports (evidence: `README.md`)
