# wandb/openui architecture

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

- Interactive diagram: https://gitdiagram.com/wandb/openui
- Repository: https://github.com/wandb/openui

## Overview

OpenUI is a browser-based tool for generating UI from natural-language prompts, viewing the result live, refining it, and converting HTML to frontend formats. The main path runs from the user’s prompt through the frontend and server to a selected model provider, then returns generated content for HTML processing and preview. Separate capabilities include authentication, model discovery, version history, sharing, and evaluation. The graph reflects README-documented capabilities where implementation was not sampled; arrows are limited to relationships shown in excerpts, the source index, or README.

Main entry points: [`backend/openui/server.py`](https://github.com/wandb/openui/blob/main/backend/openui/server.py) (HTTP API server), [`backend/openui/openai.py`](https://github.com/wandb/openui/blob/main/backend/openui/openai.py) (OpenAI provider), [`frontend/src/components/HtmlAnnotator.tsx`](https://github.com/wandb/openui/blob/main/frontend/src/components/HtmlAnnotator.tsx) (HTML annotator), [`frontend/src/api/openai.ts`](https://github.com/wandb/openui/blob/main/frontend/src/api/openai.ts) (Frontend API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_prompt["Prompt and chat<br/>[Prompt.tsx]"]
  node_api["Frontend API<br/>[openai.ts]"]
  node_uiapi["OpenUI API client<br/>[openui.ts]"]
  node_context["Current UI state"]
  node_annotator["HTML annotator<br/>[HtmlAnnotator.tsx]"]
  node_viewer["Code viewer<br/>[CodeViewer.tsx]"]
  node_versions["Version preview<br/>[VersionPreview.tsx]"]
  node_history["History state<br/>[history.ts]"]
end

subgraph group_backend["Generation backend"]
  node_server["HTTP API server<br/>[server.py]"]
  node_dispatch["Model dispatch<br/>[server.py]"]
  node_openai["OpenAI provider<br/>[openai.py]"]
  node_ollama["Ollama provider<br/>[ollama.py]"]
  node_litellm["LiteLLM provider<br/>[litellm.py]"]
  node_model_catalog["Model discovery<br/>[models.py]"]
end

subgraph group_state["Identity and persistence"]
  node_session["Session service<br/>[session.py]"]
  node_db[("Application database<br/>[models.py]")]
  node_storage["Share storage<br/>[storage.py]"]
end

subgraph group_quality["Evaluation"]
  node_evaluation["Prompt evaluation"]
  node_prompt_search["Prompt search<br/>[promptsearch.py]"]
end

node_user(("OpenUI user"))
node_object_store[("S3-compatible store")]
node_model_service["Model services"]

node_user -->|"writes prompt"| node_prompt
node_prompt -->|"submits chat"| node_api
node_api -.->|"calls API"| node_server
node_server -->|"routes chat"| node_dispatch
node_dispatch -->|"streams response"| node_openai
node_dispatch -->|"calls chat"| node_ollama
node_dispatch -->|"calls provider"| node_litellm
node_openai -.->|"requests completion"| node_model_service
node_ollama -.->|"requests completion"| node_model_service
node_litellm -.->|"requests completion"| node_model_service
node_server -->|"loads models"| node_model_catalog
node_server -->|"reads session"| node_session
node_session -->|"reads and writes"| node_db
node_openai -->|"records usage"| node_db
node_server -->|"records votes"| node_db
node_server -->|"stores shared UI"| node_storage
node_storage -->|"uploads and downloads"| node_object_store
node_api -.->|"updates UI state"| node_context
node_context -->|"provides UI context"| node_annotator
node_context -->|"loads version state"| node_history
node_annotator -->|"uses viewer"| node_viewer
node_versions -->|"previews HTML"| node_annotator
node_user -->|"views generated UI"| node_viewer
node_user -.->|"reviews versions"| node_versions
node_user -->|"shares UI"| node_server
node_evaluation -->|"optimizes prompts"| node_prompt_search
node_prompt_search -->|"requests model output"| node_openai
node_user -->|"refines and converts"| node_annotator

click node_prompt "https://github.com/wandb/openui/blob/main/frontend/src/components/Prompt.tsx"
click node_api "https://github.com/wandb/openui/blob/main/frontend/src/api/openai.ts"
click node_uiapi "https://github.com/wandb/openui/blob/main/frontend/src/api/openui.ts"
click node_context "https://github.com/wandb/openui/blob/main/frontend/src/components/CurrentUiContext.tsx"
click node_annotator "https://github.com/wandb/openui/blob/main/frontend/src/components/HtmlAnnotator.tsx"
click node_viewer "https://github.com/wandb/openui/blob/main/frontend/src/components/CodeViewer.tsx"
click node_versions "https://github.com/wandb/openui/blob/main/frontend/src/components/VersionPreview.tsx"
click node_history "https://github.com/wandb/openui/blob/main/frontend/src/state/atoms/history.ts"
click node_server "https://github.com/wandb/openui/blob/main/backend/openui/server.py"
click node_dispatch "https://github.com/wandb/openui/blob/main/backend/openui/server.py"
click node_openai "https://github.com/wandb/openui/blob/main/backend/openui/openai.py"
click node_ollama "https://github.com/wandb/openui/blob/main/backend/openui/ollama.py"
click node_litellm "https://github.com/wandb/openui/blob/main/backend/openui/litellm.py"
click node_model_catalog "https://github.com/wandb/openui/blob/main/backend/openui/models.py"
click node_session "https://github.com/wandb/openui/blob/main/backend/openui/session.py"
click node_db "https://github.com/wandb/openui/blob/main/backend/openui/db/models.py"
click node_storage "https://github.com/wandb/openui/blob/main/backend/openui/util/storage.py"
click node_evaluation "https://github.com/wandb/openui/tree/main/backend/openui/eval"
click node_prompt_search "https://github.com/wandb/openui/blob/main/backend/openui/eval/promptsearch.py"

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_prompt,node_api,node_uiapi,node_context,node_annotator,node_viewer,node_versions,node_history,node_user toneBlue
class node_server,node_dispatch,node_openai,node_ollama,node_litellm,node_model_catalog,node_object_store toneAmber
class node_session,node_db,node_storage toneMint
class node_evaluation,node_prompt_search toneRose
class node_model_service toneIndigo
```

## Components

### Frontend experience

- [Prompt and chat](https://github.com/wandb/openui/blob/main/frontend/src/components/Prompt.tsx): `frontend/src/components/Prompt.tsx`
- [Frontend API](https://github.com/wandb/openui/blob/main/frontend/src/api/openai.ts): `frontend/src/api/openai.ts`
- [OpenUI API client](https://github.com/wandb/openui/blob/main/frontend/src/api/openui.ts): `frontend/src/api/openui.ts`
- [Current UI state](https://github.com/wandb/openui/blob/main/frontend/src/components/CurrentUiContext.tsx): `frontend/src/components/CurrentUiContext.tsx`
- [HTML annotator](https://github.com/wandb/openui/blob/main/frontend/src/components/HtmlAnnotator.tsx): `frontend/src/components/HtmlAnnotator.tsx`
- [Code viewer](https://github.com/wandb/openui/blob/main/frontend/src/components/CodeViewer.tsx): `frontend/src/components/CodeViewer.tsx`
- [Version preview](https://github.com/wandb/openui/blob/main/frontend/src/components/VersionPreview.tsx): `frontend/src/components/VersionPreview.tsx`
- [History state](https://github.com/wandb/openui/blob/main/frontend/src/state/atoms/history.ts): `frontend/src/state/atoms/history.ts`

### Generation backend

- [HTTP API server](https://github.com/wandb/openui/blob/main/backend/openui/server.py): `backend/openui/server.py`
- [Model dispatch](https://github.com/wandb/openui/blob/main/backend/openui/server.py): `backend/openui/server.py`
- [OpenAI provider](https://github.com/wandb/openui/blob/main/backend/openui/openai.py): `backend/openui/openai.py`
- [Ollama provider](https://github.com/wandb/openui/blob/main/backend/openui/ollama.py): `backend/openui/ollama.py`
- [LiteLLM provider](https://github.com/wandb/openui/blob/main/backend/openui/litellm.py): `backend/openui/litellm.py`
- [Model discovery](https://github.com/wandb/openui/blob/main/backend/openui/models.py): `backend/openui/models.py`

### Identity and persistence

- [Session service](https://github.com/wandb/openui/blob/main/backend/openui/session.py): `backend/openui/session.py`
- [Application database](https://github.com/wandb/openui/blob/main/backend/openui/db/models.py): `backend/openui/db/models.py`
- [Share storage](https://github.com/wandb/openui/blob/main/backend/openui/util/storage.py): `backend/openui/util/storage.py`

### Evaluation

- [Prompt evaluation](https://github.com/wandb/openui/tree/main/backend/openui/eval): `backend/openui/eval`
- [Prompt search](https://github.com/wandb/openui/blob/main/backend/openui/eval/promptsearch.py): `backend/openui/eval/promptsearch.py`

### Other components

- **OpenUI user**
- **S3-compatible store**
- **Model services**

## Connections

- OpenUI user → Prompt and chat: writes prompt
- Prompt and chat → Frontend API: submits chat
- Frontend API → HTTP API server: calls API
- HTTP API server → Model dispatch: routes chat (evidence: `backend/openui/server.py`)
- Model dispatch → OpenAI provider: streams response (evidence: `backend/openui/server.py`)
- Model dispatch → Ollama provider: calls chat (evidence: `backend/openui/server.py`)
- Model dispatch → LiteLLM provider: calls provider (evidence: `backend/openui/server.py`)
- OpenAI provider → Model services: requests completion
- Ollama provider → Model services: requests completion
- LiteLLM provider → Model services: requests completion
- HTTP API server → Model discovery: loads models (evidence: `backend/openui/server.py`)
- HTTP API server → Session service: reads session (evidence: `backend/openui/server.py`)
- Session service → Application database: reads and writes (evidence: `backend/openui/session.py`)
- OpenAI provider → Application database: records usage (evidence: `backend/openui/openai.py`)
- HTTP API server → Application database: records votes (evidence: `backend/openui/server.py`)
- HTTP API server → Share storage: stores shared UI (evidence: `backend/openui/server.py`)
- Share storage → S3-compatible store: uploads and downloads (evidence: `backend/openui/util/storage.py`)
- Frontend API → Current UI state: updates UI state
- Current UI state → HTML annotator: provides UI context (evidence: `frontend/src/components/HtmlAnnotator.tsx`)
- Current UI state → History state: loads version state (evidence: `frontend/src/components/CurrentUiContext.tsx`)
- HTML annotator → Code viewer: uses viewer (evidence: `frontend/src/components/HtmlAnnotator.tsx`)
- Version preview → HTML annotator: previews HTML (evidence: `frontend/src/components/VersionPreview.tsx`)
- OpenUI user → Code viewer: views generated UI
- OpenUI user → Version preview: reviews versions
- OpenUI user → HTTP API server: shares UI (evidence: `backend/openui/server.py`)
- Prompt evaluation → Prompt search: optimizes prompts (evidence: `backend/openui/eval/promptsearch.py`)
- Prompt search → OpenAI provider: requests model output (evidence: `backend/openui/eval/promptsearch.py`)
- OpenUI user → HTML annotator: refines and converts
