# richardgill/llm-ui architecture

> Architecture diagram of the GitHub repository richardgill/llm-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/richardgill/llm-ui
- Repository: https://github.com/richardgill/llm-ui

## Overview

##### Project type and purpose
- This is an open-source, full-stack monorepo for “llm-ui,” a React/TypeScript library plus ecosystem.
- It contains:
– Core library packages (code, csv, json, markdown, react, shared)
– A documentation/demo website (apps/www built with Astro + React)
– Example apps (Next.js & Vite starters under examples/)
– Codegen tooling (tooling/examples, tooling/gen, tooling/tsconfig)
– CI/CD and release pipelines (.github/workflows, Husky, lint-staged)

##### File structure
- **Root**
– pnpm-workspace.yaml glues everything together
– package.json defines root-level scripts & dependencies
– .github/workflows holds CI, canary release, and final release pipelines
– eslint, prettier, vitest, Husky integrate lint, format, tests, pre-commit hooks
- **packages/**
– Each subfolder is a library package (implements a block or hook)
– They share TS config and build tooling (tsup, vitest)
– packages/react ties everything together as React hooks/components for LLM UIs
- **apps/www/**
– Astro-based static site serving docs, demos, and a chat UI (pages/api endpoints)
– Uses workspace packages at design time for code samples & live components
– Bundled with Astro build, deployed via Vercel (vercel.json)
- **examples/**
– Minimal starter apps (Next.js & Vite) to show how to integrate llm-ui blocks
- **tooling/**
– Code generators for examples and new packages (template scaffolding)

##### README for additional insights
- Core features (streamed LLM output, custom components, markdown cleanup, Shiki syntax highlighting)
- Library is “headless”—styling is provided by consumer
- Documentation link points at the apps/www site

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Workspace
    subgraph "Monorepo Workspace"
        direction TB
        PNPM["pnpm-workspace.yaml"]:::workspace
        RootPkg["package.json"]:::workspace
    end

    %% Library Packages
    subgraph "Library Packages"
        direction TB
        PackageCode["packages/code"]:::library
        PackageCSV["packages/csv"]:::library
        PackageJSON["packages/json"]:::library
        PackageMD["packages/markdown"]:::library
        PackageShared["packages/shared"]:::library
        PackageReact["packages/react"]:::library
        PackageCLI["packages/create-llm-ui"]:::library
    end

    %% Documentation & Demo Site
    subgraph "Documentation & Demo Site"
        direction TB
        DocsSite["apps/www"]:::docs
        AstroConfig["astro.config.mjs"]:::docs
        DocsPages["src/pages"]:::docs
        DocsComponents["src/components"]:::docs
        DocsContent["src/content"]:::docs
        TailwindConfig["tailwind.config.cjs"]:::docs
        VercelConfig["vercel.json"]:::docs
    end

    %% Example Starter Applications
    subgraph "Example Starter Applications"
        direction TB
        subgraph "Code Examples"
            direction TB
            ExCodeNext["examples/code/nextjs"]:::example
            ExCodeVite["examples/code/vite"]:::example
        end
        subgraph "CSV Examples"
            direction TB
            ExCSVNext["examples/csv/nextjs"]:::example
            ExCSVVite["examples/csv/vite"]:::example
        end
        subgraph "JSON Examples"
            direction TB
            ExJSONNext["examples/json/nextjs"]:::example
            ExJSONVite["examples/json/vite"]:::example
        end
        subgraph "Markdown Examples"
            direction TB
            ExMDNext["examples/markdown/nextjs"]:::example
            ExMDVite["examples/markdown/vite"]:::example
        end
        subgraph "OpenAI Examples"
            direction TB
            ExOpenaiNext["examples/openai/nextjs"]:::example
            ExOpenaiVite["examples/openai/vite-and-express"]:::example
        end
        subgraph "Vercel AI Example"
            direction TB
            ExVercelAI["examples/vercel-ai/nextjs"]:::example
        end
    end

    %% Codegen Tooling
    subgraph "Codegen Tooling"
        direction TB
        ToolExamples["tooling/examples"]:::tooling
        ToolGen["tooling/gen"]:::tooling
        ToolTSConfig["tooling/tsconfig"]:::tooling
    end

    %% CI/CD Pipelines
    subgraph "CI/CD Pipelines"
        direction TB
        CI_CI[".github/workflows/ci.yml"]:::ci
        CI_Canary[".github/workflows/canary.yml"]:::ci
        CI_Release[".github/workflows/release.yml"]:::ci
    end

    %% External Services
    NPMRegistry[(npm Registry)]:::external
    Vercel[(Vercel)]:::external
    OpenAI[(OpenAI API)]:::external

    %% Relationships
    PNPM -->|workspace links| PackageCode
    PNPM --> PackageCSV
    PNPM --> PackageJSON
    PNPM --> PackageMD
    PNPM --> PackageShared
    PNPM --> PackageReact
    PNPM --> PackageCLI

    DocsSite -->|imports| PackageReact
    DocsSite -->|imports| PackageCode
    DocsSite -->|imports| PackageCSV
    DocsSite -->|imports| PackageJSON
    DocsSite -->|imports| PackageMD
    DocsSite -->|imports| PackageShared

    ExCodeNext -->|imports| PackageReact
    ExCodeVite -->|imports| PackageReact
    ExCSVNext -->|imports| PackageCSV
    ExCSVVite -->|imports| PackageCSV
    ExJSONNext -->|imports| PackageJSON
    ExJSONVite -->|imports| PackageJSON
    ExMDNext -->|imports| PackageMD
    ExMDVite -->|imports| PackageMD
    ExOpenaiNext -->|imports| PackageReact
    ExOpenaiVite -->|imports| PackageReact
    ExVercelAI -->|imports| PackageReact

    ToolExamples -->|scaffold templates| PackageCLI
    ToolGen --> PackageCLI
    ToolTSConfig -->|share TS configs| PackageCode

    CI_CI -->|runs| RootPkg
    CI_CI -->|builds| PackageCode
    CI_CI -->|tests| PackageCode
    CI_CI -->|builds docs| DocsSite
    CI_Canary -->|publishes prerelease| NPMRegistry
    CI_Release -->|publishes release| NPMRegistry

    CI_Release -->|triggers deployment| Vercel
    DocsSite -->|deploy build| Vercel

    DocsSite -->|calls API| OpenAI

    %% Click Events
    click PNPM "https://github.com/richardgill/llm-ui/blob/main/pnpm-workspace.yaml"
    click RootPkg "https://github.com/richardgill/llm-ui/blob/main/package.json"
    click CI_CI "https://github.com/richardgill/llm-ui/blob/main/.github/workflows/ci.yml"
    click CI_Canary "https://github.com/richardgill/llm-ui/blob/main/.github/workflows/canary.yml"
    click CI_Release "https://github.com/richardgill/llm-ui/blob/main/.github/workflows/release.yml"
    click PackageCode "https://github.com/richardgill/llm-ui/tree/main/packages/code"
    click PackageCSV "https://github.com/richardgill/llm-ui/tree/main/packages/csv"
    click PackageJSON "https://github.com/richardgill/llm-ui/tree/main/packages/json"
    click PackageMD "https://github.com/richardgill/llm-ui/tree/main/packages/markdown"
    click PackageShared "https://github.com/richardgill/llm-ui/tree/main/packages/shared"
    click PackageReact "https://github.com/richardgill/llm-ui/tree/main/packages/react"
    click PackageCLI "https://github.com/richardgill/llm-ui/tree/main/packages/create-llm-ui"
    click DocsSite "https://github.com/richardgill/llm-ui/tree/main/apps/www"
    click AstroConfig "https://github.com/richardgill/llm-ui/blob/main/apps/www/astro.config.mjs"
    click DocsPages "https://github.com/richardgill/llm-ui/tree/main/apps/www/src/pages"
    click DocsComponents "https://github.com/richardgill/llm-ui/tree/main/apps/www/src/components"
    click DocsContent "https://github.com/richardgill/llm-ui/tree/main/apps/www/src/content"
    click TailwindConfig "https://github.com/richardgill/llm-ui/blob/main/apps/www/tailwind.config.cjs"
    click VercelConfig "https://github.com/richardgill/llm-ui/blob/main/apps/www/vercel.json"
    click ExCodeNext "https://github.com/richardgill/llm-ui/tree/main/examples/code/nextjs"
    click ExCodeVite "https://github.com/richardgill/llm-ui/tree/main/examples/code/vite"
    click ExCSVNext "https://github.com/richardgill/llm-ui/tree/main/examples/csv/nextjs"
    click ExCSVVite "https://github.com/richardgill/llm-ui/tree/main/examples/csv/vite"
    click ExJSONNext "https://github.com/richardgill/llm-ui/tree/main/examples/json/nextjs"
    click ExJSONVite "https://github.com/richardgill/llm-ui/tree/main/examples/json/vite"
    click ExMDNext "https://github.com/richardgill/llm-ui/tree/main/examples/markdown/nextjs"
    click ExMDVite "https://github.com/richardgill/llm-ui/tree/main/examples/markdown/vite"
    click ExOpenaiNext "https://github.com/richardgill/llm-ui/tree/main/examples/openai/nextjs"
    click ExOpenaiVite "https://github.com/richardgill/llm-ui/tree/main/examples/openai/vite-and-express"
    click ExVercelAI "https://github.com/richardgill/llm-ui/tree/main/examples/vercel-ai/nextjs"
    click ToolExamples "https://github.com/richardgill/llm-ui/tree/main/tooling/examples"
    click ToolGen "https://github.com/richardgill/llm-ui/tree/main/tooling/gen"
    click ToolTSConfig "https://github.com/richardgill/llm-ui/tree/main/tooling/tsconfig"

    %% Styles
    classDef workspace fill:#E3F2FD,stroke:#1E88E5;
    classDef library fill:#BBDEFB,stroke:#0D47A1;
    classDef docs fill:#C8E6C9,stroke:#2E7D32;
    classDef example fill:#FFF9C4,stroke:#F9A825;
    classDef tooling fill:#FFE0B2,stroke:#EF6C00;
    classDef ci fill:#F0F0F0,stroke:#9E9E9E;
    classDef external fill:#EEEEEE,stroke:#616161;
```
