# southleft/ds-contracts-poc architecture

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

- Interactive diagram: https://gitdiagram.com/southleft/ds-contracts-poc
- Repository: https://github.com/southleft/ds-contracts-poc

## Overview

Design System Contracts connects React component libraries and Figma libraries through a shared, framework-neutral contract. The intended journeys are React observation → contract → editable Figma output, Figma import → contract → reusable React output, and comparison → policy-governed repair → independent verification. The README says these complete journeys are still being integrated; current local tools expose parts of them. The graph preserves those documented capabilities while limiting implementation-level links to relationships visible in the excerpts or SOURCE INDEX.

Main entry points: [`packages/schema/src/contract-schema.ts`](https://github.com/southleft/ds-contracts-poc/blob/main/packages/schema/src/contract-schema.ts) (Shared Contract), [`core/channel-diff.ts`](https://github.com/southleft/ds-contracts-poc/blob/main/core/channel-diff.ts) (Change Comparison), [`source-reference/service.ts`](https://github.com/southleft/ds-contracts-poc/blob/main/source-reference/service.ts) (React Observation), [`extract/figma/rest/map.ts`](https://github.com/southleft/ds-contracts-poc/blob/main/extract/figma/rest/map.ts) (Figma Import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Library Intake"]
  node_react_intake["React Observation<br/>[service.ts]"]
  node_figma_intake["Figma Import<br/>[map.ts]"]
  node_source_extract["Source Extraction"]
end

subgraph group_contract["Contract Engine"]
  node_shared_contract["Shared Contract<br/>[contract-schema.ts]"]
  node_native_observation["Native Observation"]
  node_token_mint["Token Minting<br/>[mint-tokens.ts]"]
  node_token_sets["Token Sets<br/>[token-set.ts]"]
end

subgraph group_outputs["Generation"]
  node_code_generation["React Generation<br/>[mint-code.ts]"]
  node_figma_generation["Figma Generation"]
end

subgraph group_governance["Compare And Repair"]
  node_comparison["Change Comparison<br/>[channel-diff.ts]"]
  node_repair["Authorized Repair"]
  node_verification["Independent Verification<br/>[apply-preview.ts]"]
end

subgraph group_tools["Local Tools"]
  node_playground["Local Playground<br/>[App.tsx]"]
  node_flow_engine["Guided Flow Engine<br/>[flow-engine.ts]"]
end

node_react_library(("React Library"))
node_figma_library(("Figma Library"))

node_react_library -->|"observe"| node_react_intake
node_react_intake -.->|"derive facts"| node_source_extract
node_source_extract -->|"describe"| node_shared_contract
node_figma_library -->|"read library"| node_figma_intake
node_figma_intake -->|"derive"| node_shared_contract
node_react_intake -.->|"observe native"| node_native_observation
node_native_observation -.->|"record facts"| node_shared_contract
node_shared_contract -->|"mint tokens"| node_token_mint
node_shared_contract -->|"compile tokens"| node_token_sets
node_shared_contract -->|"generate React"| node_code_generation
node_shared_contract -->|"generate Figma"| node_figma_generation
node_react_library -->|"compare changes"| node_comparison
node_figma_library -->|"compare changes"| node_comparison
node_shared_contract -->|"compare baseline"| node_comparison
node_comparison -->|"authorize repair"| node_repair
node_repair -->|"verify repair"| node_verification
node_playground -->|"runs"| node_flow_engine
node_flow_engine -->|"calls engine"| node_figma_generation

click node_react_intake "https://github.com/southleft/ds-contracts-poc/blob/main/source-reference/service.ts"
click node_figma_intake "https://github.com/southleft/ds-contracts-poc/blob/main/extract/figma/rest/map.ts"
click node_source_extract "https://github.com/southleft/ds-contracts-poc/blob/main/core/extract-react-tsx.ts"
click node_shared_contract "https://github.com/southleft/ds-contracts-poc/blob/main/packages/schema/src/contract-schema.ts"
click node_native_observation "https://github.com/southleft/ds-contracts-poc/blob/main/core/native-source-observation.ts"
click node_token_mint "https://github.com/southleft/ds-contracts-poc/blob/main/core/mint-tokens.ts"
click node_token_sets "https://github.com/southleft/ds-contracts-poc/blob/main/core/token-set.ts"
click node_code_generation "https://github.com/southleft/ds-contracts-poc/blob/main/core/mint-code.ts"
click node_figma_generation "https://github.com/southleft/ds-contracts-poc/blob/main/core/emit-figma-script.ts"
click node_comparison "https://github.com/southleft/ds-contracts-poc/blob/main/core/channel-diff.ts"
click node_repair "https://github.com/southleft/ds-contracts-poc/blob/main/source-reference/native-operation-jobs.ts"
click node_verification "https://github.com/southleft/ds-contracts-poc/blob/main/core/apply-preview.ts"
click node_playground "https://github.com/southleft/ds-contracts-poc/blob/main/playground/src/App.tsx"
click node_flow_engine "https://github.com/southleft/ds-contracts-poc/blob/main/playground/src/engine/flow-engine.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_react_intake,node_figma_intake,node_source_extract toneBlue
class node_shared_contract,node_native_observation,node_token_mint,node_token_sets toneAmber
class node_code_generation,node_figma_generation toneMint
class node_comparison,node_repair,node_verification toneRose
class node_playground,node_flow_engine,node_react_library,node_figma_library toneIndigo
```

## Components

### Library Intake

- [React Observation](https://github.com/southleft/ds-contracts-poc/blob/main/source-reference/service.ts): `source-reference/service.ts`
- [Figma Import](https://github.com/southleft/ds-contracts-poc/blob/main/extract/figma/rest/map.ts): `extract/figma/rest/map.ts`
- [Source Extraction](https://github.com/southleft/ds-contracts-poc/blob/main/core/extract-react-tsx.ts): `core/extract-react-tsx.ts`

### Contract Engine

- [Shared Contract](https://github.com/southleft/ds-contracts-poc/blob/main/packages/schema/src/contract-schema.ts): `packages/schema/src/contract-schema.ts`
- [Native Observation](https://github.com/southleft/ds-contracts-poc/blob/main/core/native-source-observation.ts): `core/native-source-observation.ts`
- [Token Minting](https://github.com/southleft/ds-contracts-poc/blob/main/core/mint-tokens.ts): `core/mint-tokens.ts`
- [Token Sets](https://github.com/southleft/ds-contracts-poc/blob/main/core/token-set.ts): `core/token-set.ts`

### Generation

- [React Generation](https://github.com/southleft/ds-contracts-poc/blob/main/core/mint-code.ts): `core/mint-code.ts`
- [Figma Generation](https://github.com/southleft/ds-contracts-poc/blob/main/core/emit-figma-script.ts): `core/emit-figma-script.ts`

### Compare And Repair

- [Change Comparison](https://github.com/southleft/ds-contracts-poc/blob/main/core/channel-diff.ts): `core/channel-diff.ts`
- [Authorized Repair](https://github.com/southleft/ds-contracts-poc/blob/main/source-reference/native-operation-jobs.ts): `source-reference/native-operation-jobs.ts`
- [Independent Verification](https://github.com/southleft/ds-contracts-poc/blob/main/core/apply-preview.ts): `core/apply-preview.ts`

### Local Tools

- [Local Playground](https://github.com/southleft/ds-contracts-poc/blob/main/playground/src/App.tsx): `playground/src/App.tsx`
- [Guided Flow Engine](https://github.com/southleft/ds-contracts-poc/blob/main/playground/src/engine/flow-engine.ts): `playground/src/engine/flow-engine.ts`

### Other components

- **React Library**
- **Figma Library**

## Connections

- React Library → React Observation: observe (evidence: `README.md`)
- React Observation → Source Extraction: derive facts
- Source Extraction → Shared Contract: describe (evidence: `README.md`)
- Figma Library → Figma Import: read library (evidence: `README.md`)
- Figma Import → Shared Contract: derive (evidence: `README.md`)
- React Observation → Native Observation: observe native (evidence: `source-reference/service.ts`)
- Native Observation → Shared Contract: record facts
- Shared Contract → Token Minting: mint tokens
- Shared Contract → Token Sets: compile tokens
- Shared Contract → React Generation: generate React (evidence: `README.md`)
- Shared Contract → Figma Generation: generate Figma (evidence: `README.md`)
- React Library → Change Comparison: compare changes (evidence: `README.md`)
- Figma Library → Change Comparison: compare changes (evidence: `README.md`)
- Shared Contract → Change Comparison: compare baseline (evidence: `README.md`)
- Change Comparison → Authorized Repair: authorize repair (evidence: `README.md`)
- Authorized Repair → Independent Verification: verify repair (evidence: `README.md`)
- Local Playground → Guided Flow Engine: runs (evidence: `playground/src/App.tsx`)
- Guided Flow Engine → Figma Generation: calls engine (evidence: `playground/src/engine/flow-engine.ts`)
