# hasansarwer/salt-theme-gen architecture

> Architecture diagram of the GitHub repository hasansarwer/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/hasansarwer/salt-theme-gen
- Repository: https://github.com/hasansarwer/salt-theme-gen

## Overview

salt-theme-gen is a dependency-free TypeScript design-system theme generator. A consumer supplies a color or nature preset, optional harmony and scale choices; the public API generates light and dark themes with semantic colors, interaction states, elevation, and accessibility reports. Consumers can also adjust, compare, or validate themes. The graph follows documented behavior and sampled imports; unsampled implementation details are omitted where relationships cannot be verified.

Main entry points: [`src/generate-theme.ts`](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/generate-theme.ts) (Theme generator), [`src/adjust-theme.ts`](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/adjust-theme.ts) (Theme adjustment), [`src/index.ts`](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/index.ts) (Exports), [`src/on-colors.ts`](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/on-colors.ts) (On-colors and contrast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_public_api["Exports<br/>[index.ts]"]
end

subgraph group_generation["Theme Generation"]
  node_generator["Theme generator<br/>[generate-theme.ts]"]
  node_nature["Nature presets<br/>[nature-presets.ts]"]
  node_spacing["Spacing presets<br/>[spacing-presets.ts]"]
  node_radius["Radius presets<br/>[radius-presets.ts]"]
  node_font_size["Font-size presets"]
  node_theme["Generated themes<br/>[types.ts]"]
end

subgraph group_derivation["Color Derivation"]
  node_color_math["Color math<br/>[color-math.ts]"]
  node_color_derivation["Color derivation<br/>[butterfly.ts]"]
  node_on_colors["On-colors and contrast<br/>[on-colors.ts]"]
  node_state_colors["Interaction states<br/>[state-colors.ts]"]
end

subgraph group_utilities["Theme Utilities"]
  node_adjustment["Theme adjustment<br/>[adjust-theme.ts]"]
  node_diff["Theme diff<br/>[diff-theme.ts]"]
  node_validation["Theme validation<br/>[validate.ts]"]
end

node_consumer(("Theme consumer"))

node_consumer -->|"uses"| node_public_api
node_public_api -->|"exports"| node_generator
node_public_api -->|"exports"| node_adjustment
node_public_api -->|"exports"| node_diff
node_public_api -->|"exports"| node_validation
node_generator -->|"resolves preset"| node_nature
node_generator -->|"resolves scale"| node_spacing
node_generator -->|"resolves scale"| node_radius
node_generator -->|"resolves scale"| node_font_size
node_generator -->|"parses colors"| node_color_math
node_generator -->|"derives colors"| node_color_derivation
node_generator -->|"derives states"| node_state_colors
node_generator -->|"builds report"| node_on_colors
node_generator -->|"returns"| node_theme
node_color_derivation -->|"uses"| node_color_math
node_color_derivation -->|"derives foregrounds"| node_on_colors
node_on_colors -->|"measures contrast"| node_color_math
node_state_colors -->|"derives states"| node_color_math
node_state_colors -->|"corrects contrast"| node_on_colors
node_consumer -->|"adjusts theme"| node_adjustment
node_adjustment -->|"recalculates contrast"| node_on_colors
node_adjustment -->|"recalculates elevation"| node_color_derivation
node_adjustment -->|"recalculates states"| node_state_colors
node_adjustment -->|"returns adjusted"| node_theme
node_consumer -->|"compares themes"| node_diff
node_diff -->|"compares fields"| node_theme
node_consumer -->|"parses JSON"| node_validation

click node_public_api "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/index.ts"
click node_generator "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/generate-theme.ts"
click node_nature "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/nature-presets.ts"
click node_spacing "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/spacing-presets.ts"
click node_radius "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/radius-presets.ts"
click node_font_size "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/font-size-presets.ts"
click node_color_math "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/color-math.ts"
click node_color_derivation "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/butterfly.ts"
click node_on_colors "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/on-colors.ts"
click node_state_colors "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/state-colors.ts"
click node_theme "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/types.ts"
click node_adjustment "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/adjust-theme.ts"
click node_diff "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/diff-theme.ts"
click node_validation "https://github.com/hasansarwer/salt-theme-gen/blob/main/src/validate.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_public_api toneBlue
class node_generator,node_nature,node_spacing,node_radius,node_font_size,node_theme toneAmber
class node_color_math,node_color_derivation,node_on_colors,node_state_colors toneMint
class node_adjustment,node_diff,node_validation toneRose
class node_consumer toneIndigo
```

## Components

### Public API

- [Exports](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/index.ts): `src/index.ts`

### Theme Generation

- [Theme generator](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/generate-theme.ts): `src/generate-theme.ts`
- [Nature presets](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/nature-presets.ts): `src/presets/nature-presets.ts`
- [Spacing presets](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/spacing-presets.ts): `src/presets/spacing-presets.ts`
- [Radius presets](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/radius-presets.ts): `src/presets/radius-presets.ts`
- [Font-size presets](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/presets/font-size-presets.ts): `src/presets/font-size-presets.ts`
- [Generated themes](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/types.ts): `src/types.ts`

### Color Derivation

- [Color math](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/color-math.ts): `src/color-math.ts`
- [Color derivation](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/butterfly.ts): `src/butterfly.ts`
- [On-colors and contrast](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/on-colors.ts): `src/on-colors.ts`
- [Interaction states](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/state-colors.ts): `src/state-colors.ts`

### Theme Utilities

- [Theme adjustment](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/adjust-theme.ts): `src/adjust-theme.ts`
- [Theme diff](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/diff-theme.ts): `src/diff-theme.ts`
- [Theme validation](https://github.com/hasansarwer/salt-theme-gen/blob/main/src/validate.ts): `src/validate.ts`

### Other components

- **Theme consumer**

## Connections

- Theme consumer → Exports: uses (evidence: `README.md`)
- Exports → Theme generator: exports (evidence: `src/index.ts`)
- Exports → Theme adjustment: exports (evidence: `src/index.ts`)
- Exports → Theme diff: exports (evidence: `src/index.ts`)
- Exports → Theme validation: exports (evidence: `src/index.ts`)
- Theme generator → Nature presets: resolves preset (evidence: `src/generate-theme.ts`)
- Theme generator → Spacing presets: resolves scale (evidence: `src/generate-theme.ts`)
- Theme generator → Radius presets: resolves scale (evidence: `src/generate-theme.ts`)
- Theme generator → Font-size presets: resolves scale (evidence: `src/generate-theme.ts`)
- Theme generator → Color math: parses colors (evidence: `src/generate-theme.ts`)
- Theme generator → Color derivation: derives colors (evidence: `src/generate-theme.ts`)
- Theme generator → Interaction states: derives states (evidence: `src/generate-theme.ts`)
- Theme generator → On-colors and contrast: builds report (evidence: `src/generate-theme.ts`)
- Theme generator → Generated themes: returns (evidence: `src/generate-theme.ts`)
- Color derivation → Color math: uses (evidence: `src/butterfly.ts`)
- Color derivation → On-colors and contrast: derives foregrounds (evidence: `src/butterfly.ts`)
- On-colors and contrast → Color math: measures contrast (evidence: `src/on-colors.ts`)
- Interaction states → Color math: derives states (evidence: `src/state-colors.ts`)
- Interaction states → On-colors and contrast: corrects contrast (evidence: `src/state-colors.ts`)
- Theme consumer → Theme adjustment: adjusts theme (evidence: `README.md`)
- Theme adjustment → On-colors and contrast: recalculates contrast (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Color derivation: recalculates elevation (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Interaction states: recalculates states (evidence: `src/adjust-theme.ts`)
- Theme adjustment → Generated themes: returns adjusted (evidence: `README.md`)
- Theme consumer → Theme diff: compares themes (evidence: `README.md`)
- Theme diff → Generated themes: compares fields (evidence: `src/diff-theme.ts`)
- Theme consumer → Theme validation: parses JSON (evidence: `README.md`)
