# msl135/godmod3 architecture

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

- Interactive diagram: https://gitdiagram.com/msl135/godmod3
- Repository: https://github.com/msl135/godmod3

## Overview

G0DM0D3 is a privacy-oriented multi-model chat product: users configure a model or mode, submit a prompt, and receive a generated or raced response. Its main runtime is a browser chat UI with local state and OpenRouter access, alongside an optional self-hosted API for chat, evaluation, transformation, and research-data features. The graph preserves README capabilities and API subsystems; some route internals are unsampled, so uncertain links are omitted.

Main entry points: [`api/routes/chat.ts`](https://github.com/msl135/godmod3/blob/main/api/routes/chat.ts) (Chat endpoint), [`src/components/ChatInput.tsx`](https://github.com/msl135/godmod3/blob/main/src/components/ChatInput.tsx) (Chat input), [`api/server.ts`](https://github.com/msl135/godmod3/blob/main/api/server.ts) (API server), [`api/lib/ultraplinian.ts`](https://github.com/msl135/godmod3/blob/main/api/lib/ultraplinian.ts) (ULTRAPLINIAN engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser chat"]
  node_page["App shell<br/>[page.tsx]"]
  node_chatui["Chat interface<br/>[ChatArea.tsx]"]
  node_input["Chat input<br/>[ChatInput.tsx]"]
  node_settings["Settings<br/>[SettingsModal.tsx]"]
  node_state["Local chat state<br/>[index.ts]"]
  node_openrouter["OpenRouter client<br/>[openrouter.ts]"]
  node_telemetry["Browser telemetry<br/>[telemetry.ts]"]
end

subgraph group_engines["Prompt engines"]
  node_classify["Query classification<br/>[classify.ts]"]
  node_classifyllm["LLM classification<br/>[classify-llm.ts]"]
  node_autotune["AutoTune<br/>[autotune.ts]"]
  node_feedback["AutoTune learning"]
  node_parseltongue["Parseltongue<br/>[parseltongue.ts]"]
  node_stm["STM transforms<br/>[modules.ts]"]
  node_prompt["GODMODE prompt<br/>[godmode-prompt.ts]"]
end

subgraph group_api["Self-hosted API"]
  node_server["API server<br/>[server.ts]"]
  node_chatroute["Chat endpoint<br/>[chat.ts]"]
  node_ultraroute["ULTRAPLINIAN endpoint<br/>[ultraplinian.ts]"]
  node_ultraengine["ULTRAPLINIAN engine<br/>[ultraplinian.ts]"]
  node_consortium["Consortium mode<br/>[consortium.ts]"]
  node_tiers["Access tiers<br/>[tiers.ts]"]
end

subgraph group_research["Research data"]
  node_dataset[("Dataset collection<br/>[dataset.ts]")]
  node_publisher["HuggingFace publisher<br/>[hf-publisher.ts]"]
  node_metadata[("Request metadata<br/>[metadata.ts]")]
  node_researchroutes["Research API<br/>[research.ts]"]
  node_reader["Corpus reader<br/>[hf-reader.ts]"]
end

node_user(("User"))
node_provider["OpenRouter"]
node_apiuser(("API client"))
node_hf[("HuggingFace dataset")]

node_user -->|"uses"| node_page
node_page -->|"renders"| node_chatui
node_page -->|"renders"| node_settings
node_chatui -.->|"renders"| node_input
node_input -->|"reads and updates"| node_state
node_settings -->|"configures"| node_state
node_input -->|"classifies"| node_classify
node_classifyllm -->|"uses"| node_classify
node_input -->|"selects parameters"| node_autotune
node_autotune -->|"applies learned adjustments"| node_feedback
node_input -->|"transforms input"| node_parseltongue
node_input -->|"requests completion"| node_openrouter
node_openrouter -->|"sends model requests"| node_provider
node_user -->|"sends API requests"| node_apiuser
node_apiuser -->|"calls"| node_server
node_server -->|"mounts"| node_chatroute
node_server -->|"mounts"| node_ultraroute
node_server -->|"mounts"| node_consortium
node_server -->|"mounts"| node_researchroutes
node_chatroute -->|"uses"| node_autotune
node_chatroute -->|"uses"| node_parseltongue
node_chatroute -->|"uses"| node_stm
node_chatroute -->|"sends completions"| node_openrouter
node_chatroute -->|"invokes"| node_ultraengine
node_ultraroute -->|"invokes"| node_ultraengine
node_ultraengine -->|"uses prompt"| node_prompt
node_ultraengine -->|"races model calls"| node_provider
node_consortium -->|"uses"| node_ultraengine
node_server -->|"configures access"| node_tiers
node_chatroute -->|"records opted-in data"| node_dataset
node_chatroute -->|"records request metadata"| node_metadata
node_dataset -->|"registers data buffer"| node_publisher
node_metadata -->|"registers metadata buffer"| node_publisher
node_publisher -.->|"publishes batches"| node_hf
node_researchroutes -->|"queries corpus"| node_reader
node_researchroutes -->|"reads stats"| node_dataset
node_researchroutes -->|"reads stats"| node_metadata
node_reader -->|"reads published corpus"| node_hf
node_input -.->|"emits telemetry"| node_telemetry

click node_page "https://github.com/msl135/godmod3/blob/main/src/app/page.tsx"
click node_chatui "https://github.com/msl135/godmod3/blob/main/src/components/ChatArea.tsx"
click node_input "https://github.com/msl135/godmod3/blob/main/src/components/ChatInput.tsx"
click node_settings "https://github.com/msl135/godmod3/blob/main/src/components/SettingsModal.tsx"
click node_state "https://github.com/msl135/godmod3/blob/main/src/store/index.ts"
click node_openrouter "https://github.com/msl135/godmod3/blob/main/src/lib/openrouter.ts"
click node_classify "https://github.com/msl135/godmod3/blob/main/src/lib/classify.ts"
click node_classifyllm "https://github.com/msl135/godmod3/blob/main/src/lib/classify-llm.ts"
click node_autotune "https://github.com/msl135/godmod3/blob/main/src/lib/autotune.ts"
click node_feedback "https://github.com/msl135/godmod3/blob/main/src/lib/autotune-feedback.ts"
click node_parseltongue "https://github.com/msl135/godmod3/blob/main/src/lib/parseltongue.ts"
click node_stm "https://github.com/msl135/godmod3/blob/main/src/stm/modules.ts"
click node_prompt "https://github.com/msl135/godmod3/blob/main/src/lib/godmode-prompt.ts"
click node_server "https://github.com/msl135/godmod3/blob/main/api/server.ts"
click node_chatroute "https://github.com/msl135/godmod3/blob/main/api/routes/chat.ts"
click node_ultraroute "https://github.com/msl135/godmod3/blob/main/api/routes/ultraplinian.ts"
click node_ultraengine "https://github.com/msl135/godmod3/blob/main/api/lib/ultraplinian.ts"
click node_consortium "https://github.com/msl135/godmod3/blob/main/api/routes/consortium.ts"
click node_tiers "https://github.com/msl135/godmod3/blob/main/api/lib/tiers.ts"
click node_dataset "https://github.com/msl135/godmod3/blob/main/api/lib/dataset.ts"
click node_publisher "https://github.com/msl135/godmod3/blob/main/api/lib/hf-publisher.ts"
click node_metadata "https://github.com/msl135/godmod3/blob/main/api/lib/metadata.ts"
click node_researchroutes "https://github.com/msl135/godmod3/blob/main/api/routes/research.ts"
click node_reader "https://github.com/msl135/godmod3/blob/main/api/lib/hf-reader.ts"
click node_telemetry "https://github.com/msl135/godmod3/blob/main/src/lib/telemetry.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_page,node_chatui,node_input,node_settings,node_state,node_openrouter,node_telemetry,node_user,node_apiuser toneBlue
class node_classify,node_classifyllm,node_autotune,node_feedback,node_parseltongue,node_stm,node_prompt,node_hf toneAmber
class node_server,node_chatroute,node_ultraroute,node_ultraengine,node_consortium,node_tiers,node_provider toneMint
class node_dataset,node_publisher,node_metadata,node_researchroutes,node_reader toneRose
```

## Components

### Browser chat

- [App shell](https://github.com/msl135/godmod3/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Chat interface](https://github.com/msl135/godmod3/blob/main/src/components/ChatArea.tsx): `src/components/ChatArea.tsx`
- [Chat input](https://github.com/msl135/godmod3/blob/main/src/components/ChatInput.tsx): `src/components/ChatInput.tsx`
- [Settings](https://github.com/msl135/godmod3/blob/main/src/components/SettingsModal.tsx): `src/components/SettingsModal.tsx`
- [Local chat state](https://github.com/msl135/godmod3/blob/main/src/store/index.ts): `src/store/index.ts`
- [OpenRouter client](https://github.com/msl135/godmod3/blob/main/src/lib/openrouter.ts): `src/lib/openrouter.ts`
- [Browser telemetry](https://github.com/msl135/godmod3/blob/main/src/lib/telemetry.ts): `src/lib/telemetry.ts`

### Prompt engines

- [Query classification](https://github.com/msl135/godmod3/blob/main/src/lib/classify.ts): `src/lib/classify.ts`
- [LLM classification](https://github.com/msl135/godmod3/blob/main/src/lib/classify-llm.ts): `src/lib/classify-llm.ts`
- [AutoTune](https://github.com/msl135/godmod3/blob/main/src/lib/autotune.ts): `src/lib/autotune.ts`
- [AutoTune learning](https://github.com/msl135/godmod3/blob/main/src/lib/autotune-feedback.ts): `src/lib/autotune-feedback.ts`
- [Parseltongue](https://github.com/msl135/godmod3/blob/main/src/lib/parseltongue.ts): `src/lib/parseltongue.ts`
- [STM transforms](https://github.com/msl135/godmod3/blob/main/src/stm/modules.ts): `src/stm/modules.ts`
- [GODMODE prompt](https://github.com/msl135/godmod3/blob/main/src/lib/godmode-prompt.ts): `src/lib/godmode-prompt.ts`

### Self-hosted API

- [API server](https://github.com/msl135/godmod3/blob/main/api/server.ts): `api/server.ts`
- [Chat endpoint](https://github.com/msl135/godmod3/blob/main/api/routes/chat.ts): `api/routes/chat.ts`
- [ULTRAPLINIAN endpoint](https://github.com/msl135/godmod3/blob/main/api/routes/ultraplinian.ts): `api/routes/ultraplinian.ts`
- [ULTRAPLINIAN engine](https://github.com/msl135/godmod3/blob/main/api/lib/ultraplinian.ts): `api/lib/ultraplinian.ts`
- [Consortium mode](https://github.com/msl135/godmod3/blob/main/api/routes/consortium.ts): `api/routes/consortium.ts`
- [Access tiers](https://github.com/msl135/godmod3/blob/main/api/lib/tiers.ts): `api/lib/tiers.ts`

### Research data

- [Dataset collection](https://github.com/msl135/godmod3/blob/main/api/lib/dataset.ts): `api/lib/dataset.ts`
- [HuggingFace publisher](https://github.com/msl135/godmod3/blob/main/api/lib/hf-publisher.ts): `api/lib/hf-publisher.ts`
- [Request metadata](https://github.com/msl135/godmod3/blob/main/api/lib/metadata.ts): `api/lib/metadata.ts`
- [Research API](https://github.com/msl135/godmod3/blob/main/api/routes/research.ts): `api/routes/research.ts`
- [Corpus reader](https://github.com/msl135/godmod3/blob/main/api/lib/hf-reader.ts): `api/lib/hf-reader.ts`

### Other components

- **User**
- **OpenRouter**
- **API client**
- **HuggingFace dataset**

## Connections

- User → App shell: uses (evidence: `src/app/page.tsx`)
- App shell → Chat interface: renders (evidence: `src/app/page.tsx`)
- App shell → Settings: renders (evidence: `src/app/page.tsx`)
- Chat interface → Chat input: renders
- Chat input → Local chat state: reads and updates (evidence: `src/components/ChatInput.tsx`)
- Settings → Local chat state: configures (evidence: `src/components/SettingsModal.tsx`)
- Chat input → Query classification: classifies (evidence: `src/components/ChatInput.tsx`)
- LLM classification → Query classification: uses (evidence: `src/lib/classify-llm.ts`)
- Chat input → AutoTune: selects parameters (evidence: `src/components/ChatInput.tsx`)
- AutoTune → AutoTune learning: applies learned adjustments (evidence: `src/lib/autotune.ts`)
- Chat input → Parseltongue: transforms input (evidence: `src/components/ChatInput.tsx`)
- Chat input → OpenRouter client: requests completion (evidence: `src/components/ChatInput.tsx`)
- OpenRouter client → OpenRouter: sends model requests (evidence: `src/lib/openrouter.ts`)
- User → API client: sends API requests (evidence: `README.md`)
- API client → API server: calls (evidence: `README.md`)
- API server → Chat endpoint: mounts (evidence: `api/server.ts`)
- API server → ULTRAPLINIAN endpoint: mounts (evidence: `api/server.ts`)
- API server → Consortium mode: mounts (evidence: `api/server.ts`)
- API server → Research API: mounts (evidence: `api/server.ts`)
- Chat endpoint → AutoTune: uses (evidence: `api/routes/chat.ts`)
- Chat endpoint → Parseltongue: uses (evidence: `api/routes/chat.ts`)
- Chat endpoint → STM transforms: uses (evidence: `api/routes/chat.ts`)
- Chat endpoint → OpenRouter client: sends completions (evidence: `api/routes/chat.ts`)
- Chat endpoint → ULTRAPLINIAN engine: invokes (evidence: `api/routes/chat.ts`)
- ULTRAPLINIAN endpoint → ULTRAPLINIAN engine: invokes (evidence: `api/routes/ultraplinian.ts`)
- ULTRAPLINIAN engine → GODMODE prompt: uses prompt (evidence: `api/lib/ultraplinian.ts`)
- ULTRAPLINIAN engine → OpenRouter: races model calls (evidence: `api/lib/ultraplinian.ts`)
- Consortium mode → ULTRAPLINIAN engine: uses
- API server → Access tiers: configures access (evidence: `api/server.ts`)
- Chat endpoint → Dataset collection: records opted-in data (evidence: `api/routes/chat.ts`)
- Chat endpoint → Request metadata: records request metadata (evidence: `api/routes/chat.ts`)
- Dataset collection → HuggingFace publisher: registers data buffer (evidence: `api/lib/dataset.ts`)
- Request metadata → HuggingFace publisher: registers metadata buffer (evidence: `api/lib/metadata.ts`)
- HuggingFace publisher → HuggingFace dataset: publishes batches (evidence: `README.md`)
- Research API → Corpus reader: queries corpus (evidence: `api/routes/research.ts`)
- Research API → Dataset collection: reads stats (evidence: `api/routes/research.ts`)
- Research API → Request metadata: reads stats (evidence: `api/routes/research.ts`)
- Corpus reader → HuggingFace dataset: reads published corpus
- Chat input → Browser telemetry: emits telemetry (evidence: `src/components/ChatInput.tsx`)
