# om280/prompthub architecture

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

- Interactive diagram: https://gitdiagram.com/om280/prompthub
- Repository: https://github.com/om280/prompthub

## Overview

PromptHub is a web app that turns an idea into a prompt tailored to a selected AI model: users choose a model and complexity, answer relevant clarification questions, generate and refine a prompt, then copy or export it. The graph follows the documented frontend-to-API workflow and the evidenced backend dispatch to the prompt engine and provider abstraction. Some UI handlers and engine internals are unsampled, so those relationships rely on README documentation; provider-specific integrations are represented as optional where appropriate.

Main entry points: [`src/App.tsx`](https://github.com/om280/prompthub/blob/main/src/App.tsx) (App workflow), [`server/src/promptEngine/index.js`](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/index.js) (Stage orchestrator), [`server/src/providers/index.js`](https://github.com/om280/prompthub/blob/main/server/src/providers/index.js) (Provider selection), [`server/src/routes/api.js`](https://github.com/om280/prompthub/blob/main/server/src/routes/api.js) (API endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_app["App workflow<br/>[App.tsx]"]
  node_home["Idea and model<br/>[HomeView.tsx]"]
  node_questions["Clarification<br/>[QuestionsView.tsx]"]
  node_questionfield["Question controls<br/>[QuestionField.tsx]"]
  node_workspace["Prompt workspace<br/>[Workspace.tsx]"]
  node_qualitypanel["Quality analysis<br/>[QualityPanel.tsx]"]
  node_sidebar["History and templates<br/>[Sidebar.tsx]"]
  node_templates["Prompt templates<br/>[templates.ts]"]
  node_settings["Provider settings<br/>[SettingsDrawer.tsx]"]
end

subgraph group_api["API boundary"]
  node_apiclient["API client<br/>[api.ts]"]
  node_server["HTTP server<br/>[index.js]"]
  node_routes["API endpoints<br/>[api.js]"]
  node_validation["Request validation<br/>[validate.js]"]
  node_ratelimit["Rate limiting<br/>[rateLimit.js]"]
end

subgraph group_engine["Prompt engine"]
  node_engine["Stage orchestrator<br/>[index.js]"]
  node_analysis["Intent and questions<br/>[analyzer.js]"]
  node_taxonomy["Domain taxonomy<br/>[taxonomy.js]"]
  node_composer["Prompt composition<br/>[composer.js]"]
  node_prompts["AI request prompts<br/>[prompts.js]"]
  node_profiles["Model guidance<br/>[modelProfiles.js]"]
  node_improver["Improvement analysis<br/>[improver.js]"]
  node_quality["Prompt quality<br/>[quality.js]"]
end

subgraph group_providers["AI providers"]
  node_providerregistry["Provider selection<br/>[index.js]"]
  node_openai["OpenAI adapter<br/>[openai.js]"]
  node_anthropic["Anthropic adapter<br/>[anthropic.js]"]
  node_gemini["Gemini adapter<br/>[gemini.js]"]
  node_groq["Groq adapter<br/>[groq.js]"]
  node_local["Local engine<br/>[local.js]"]
end

subgraph group_state["Client state"]
  node_browserstorage[("Browser history<br/>[storage.ts]")]
end

node_user(("Prompt creator"))
node_aiservices{{"AI provider services"}}

node_user -->|"enters idea"| node_home
node_home -->|"sets choices"| node_app
node_app -->|"requests stages"| node_apiclient
node_apiclient -->|"calls API"| node_routes
node_app -->|"shows questions"| node_questions
node_questions -->|"renders controls"| node_questionfield
node_app -->|"shows result"| node_workspace
node_workspace -->|"renders analysis"| node_qualitypanel
node_app -->|"opens history"| node_sidebar
node_sidebar -->|"lists templates"| node_templates
node_app -->|"loads history"| node_browserstorage
node_app -->|"saves history"| node_browserstorage
node_app -->|"opens settings"| node_settings
node_server -->|"mounts API"| node_routes
node_routes -->|"validates requests"| node_validation
node_routes -->|"limits requests"| node_ratelimit
node_routes -->|"dispatches stages"| node_engine
node_engine -->|"analyzes intent"| node_analysis
node_analysis -->|"checks domain slots"| node_taxonomy
node_engine -->|"composes prompt"| node_composer
node_engine -->|"analyzes improvements"| node_improver
node_engine -->|"estimates quality"| node_quality
node_engine -->|"builds AI requests"| node_prompts
node_prompts -->|"uses guidance"| node_profiles
node_composer -->|"formats for model"| node_profiles
node_engine -->|"requests completion"| node_providerregistry
node_providerregistry -->|"selects adapter"| node_openai
node_providerregistry -->|"selects adapter"| node_anthropic
node_providerregistry -->|"selects adapter"| node_gemini
node_providerregistry -->|"selects adapter"| node_groq
node_providerregistry -->|"falls back"| node_local
node_openai -.->|"sends completion"| node_aiservices
node_anthropic -.->|"sends completion"| node_aiservices
node_gemini -.->|"sends completion"| node_aiservices
node_groq -.->|"sends completion"| node_aiservices
node_settings -->|"loads model details"| node_apiclient

click node_app "https://github.com/om280/prompthub/blob/main/src/App.tsx"
click node_home "https://github.com/om280/prompthub/blob/main/src/components/HomeView.tsx"
click node_questions "https://github.com/om280/prompthub/blob/main/src/components/QuestionsView.tsx"
click node_questionfield "https://github.com/om280/prompthub/blob/main/src/components/QuestionField.tsx"
click node_workspace "https://github.com/om280/prompthub/blob/main/src/components/Workspace.tsx"
click node_qualitypanel "https://github.com/om280/prompthub/blob/main/src/components/QualityPanel.tsx"
click node_sidebar "https://github.com/om280/prompthub/blob/main/src/components/Sidebar.tsx"
click node_templates "https://github.com/om280/prompthub/blob/main/src/data/templates.ts"
click node_settings "https://github.com/om280/prompthub/blob/main/src/components/SettingsDrawer.tsx"
click node_browserstorage "https://github.com/om280/prompthub/blob/main/src/lib/storage.ts"
click node_apiclient "https://github.com/om280/prompthub/blob/main/src/lib/api.ts"
click node_server "https://github.com/om280/prompthub/blob/main/server/src/index.js"
click node_routes "https://github.com/om280/prompthub/blob/main/server/src/routes/api.js"
click node_validation "https://github.com/om280/prompthub/blob/main/server/src/middleware/validate.js"
click node_ratelimit "https://github.com/om280/prompthub/blob/main/server/src/middleware/rateLimit.js"
click node_engine "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/index.js"
click node_analysis "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/analyzer.js"
click node_taxonomy "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/taxonomy.js"
click node_composer "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/composer.js"
click node_prompts "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/prompts.js"
click node_profiles "https://github.com/om280/prompthub/blob/main/server/src/modelProfiles.js"
click node_improver "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/improver.js"
click node_quality "https://github.com/om280/prompthub/blob/main/server/src/promptEngine/quality.js"
click node_providerregistry "https://github.com/om280/prompthub/blob/main/server/src/providers/index.js"
click node_openai "https://github.com/om280/prompthub/blob/main/server/src/providers/openai.js"
click node_anthropic "https://github.com/om280/prompthub/blob/main/server/src/providers/anthropic.js"
click node_gemini "https://github.com/om280/prompthub/blob/main/server/src/providers/gemini.js"
click node_groq "https://github.com/om280/prompthub/blob/main/server/src/providers/groq.js"
click node_local "https://github.com/om280/prompthub/blob/main/server/src/providers/local.js"

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_app,node_home,node_questions,node_questionfield,node_workspace,node_qualitypanel,node_sidebar,node_templates,node_settings toneBlue
class node_apiclient,node_server,node_routes,node_validation,node_ratelimit toneAmber
class node_engine,node_analysis,node_taxonomy,node_composer,node_prompts,node_profiles,node_improver,node_quality toneMint
class node_providerregistry,node_openai,node_anthropic,node_gemini,node_groq,node_local toneRose
class node_browserstorage,node_user,node_aiservices toneIndigo
```

## Components

### Web experience

- [App workflow](https://github.com/om280/prompthub/blob/main/src/App.tsx): `src/App.tsx`
- [Idea and model](https://github.com/om280/prompthub/blob/main/src/components/HomeView.tsx): `src/components/HomeView.tsx`
- [Clarification](https://github.com/om280/prompthub/blob/main/src/components/QuestionsView.tsx): `src/components/QuestionsView.tsx`
- [Question controls](https://github.com/om280/prompthub/blob/main/src/components/QuestionField.tsx): `src/components/QuestionField.tsx`
- [Prompt workspace](https://github.com/om280/prompthub/blob/main/src/components/Workspace.tsx): `src/components/Workspace.tsx`
- [Quality analysis](https://github.com/om280/prompthub/blob/main/src/components/QualityPanel.tsx): `src/components/QualityPanel.tsx`
- [History and templates](https://github.com/om280/prompthub/blob/main/src/components/Sidebar.tsx): `src/components/Sidebar.tsx`
- [Prompt templates](https://github.com/om280/prompthub/blob/main/src/data/templates.ts): `src/data/templates.ts`
- [Provider settings](https://github.com/om280/prompthub/blob/main/src/components/SettingsDrawer.tsx): `src/components/SettingsDrawer.tsx`

### API boundary

- [API client](https://github.com/om280/prompthub/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [HTTP server](https://github.com/om280/prompthub/blob/main/server/src/index.js): `server/src/index.js`
- [API endpoints](https://github.com/om280/prompthub/blob/main/server/src/routes/api.js): `server/src/routes/api.js`
- [Request validation](https://github.com/om280/prompthub/blob/main/server/src/middleware/validate.js): `server/src/middleware/validate.js`
- [Rate limiting](https://github.com/om280/prompthub/blob/main/server/src/middleware/rateLimit.js): `server/src/middleware/rateLimit.js`

### Prompt engine

- [Stage orchestrator](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/index.js): `server/src/promptEngine/index.js`
- [Intent and questions](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/analyzer.js): `server/src/promptEngine/analyzer.js`
- [Domain taxonomy](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/taxonomy.js): `server/src/promptEngine/taxonomy.js`
- [Prompt composition](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/composer.js): `server/src/promptEngine/composer.js`
- [AI request prompts](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/prompts.js): `server/src/promptEngine/prompts.js`
- [Model guidance](https://github.com/om280/prompthub/blob/main/server/src/modelProfiles.js): `server/src/modelProfiles.js`
- [Improvement analysis](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/improver.js): `server/src/promptEngine/improver.js`
- [Prompt quality](https://github.com/om280/prompthub/blob/main/server/src/promptEngine/quality.js): `server/src/promptEngine/quality.js`

### AI providers

- [Provider selection](https://github.com/om280/prompthub/blob/main/server/src/providers/index.js): `server/src/providers/index.js`
- [OpenAI adapter](https://github.com/om280/prompthub/blob/main/server/src/providers/openai.js): `server/src/providers/openai.js`
- [Anthropic adapter](https://github.com/om280/prompthub/blob/main/server/src/providers/anthropic.js): `server/src/providers/anthropic.js`
- [Gemini adapter](https://github.com/om280/prompthub/blob/main/server/src/providers/gemini.js): `server/src/providers/gemini.js`
- [Groq adapter](https://github.com/om280/prompthub/blob/main/server/src/providers/groq.js): `server/src/providers/groq.js`
- [Local engine](https://github.com/om280/prompthub/blob/main/server/src/providers/local.js): `server/src/providers/local.js`

### Client state

- [Browser history](https://github.com/om280/prompthub/blob/main/src/lib/storage.ts): `src/lib/storage.ts`

### Other components

- **Prompt creator**
- **AI provider services**

## Connections

- Prompt creator → Idea and model: enters idea
- Idea and model → App workflow: sets choices (evidence: `src/components/HomeView.tsx`)
- App workflow → API client: requests stages (evidence: `src/App.tsx`)
- API client → API endpoints: calls API
- App workflow → Clarification: shows questions (evidence: `src/App.tsx`)
- Clarification → Question controls: renders controls (evidence: `src/components/QuestionsView.tsx`)
- App workflow → Prompt workspace: shows result (evidence: `src/App.tsx`)
- Prompt workspace → Quality analysis: renders analysis (evidence: `src/components/Workspace.tsx`)
- App workflow → History and templates: opens history (evidence: `src/App.tsx`)
- History and templates → Prompt templates: lists templates (evidence: `src/components/Sidebar.tsx`)
- App workflow → Browser history: loads history (evidence: `src/App.tsx`)
- App workflow → Browser history: saves history (evidence: `src/App.tsx`)
- App workflow → Provider settings: opens settings (evidence: `src/App.tsx`)
- HTTP server → API endpoints: mounts API (evidence: `server/src/index.js`)
- API endpoints → Request validation: validates requests (evidence: `server/src/routes/api.js`)
- API endpoints → Rate limiting: limits requests (evidence: `server/src/routes/api.js`)
- API endpoints → Stage orchestrator: dispatches stages (evidence: `server/src/routes/api.js`)
- Stage orchestrator → Intent and questions: analyzes intent (evidence: `server/src/promptEngine/index.js`)
- Intent and questions → Domain taxonomy: checks domain slots (evidence: `server/src/promptEngine/analyzer.js`)
- Stage orchestrator → Prompt composition: composes prompt (evidence: `server/src/promptEngine/index.js`)
- Stage orchestrator → Improvement analysis: analyzes improvements (evidence: `server/src/promptEngine/index.js`)
- Stage orchestrator → Prompt quality: estimates quality (evidence: `server/src/promptEngine/index.js`)
- Stage orchestrator → AI request prompts: builds AI requests (evidence: `server/src/promptEngine/index.js`)
- AI request prompts → Model guidance: uses guidance (evidence: `server/src/promptEngine/prompts.js`)
- Prompt composition → Model guidance: formats for model (evidence: `server/src/promptEngine/composer.js`)
- Stage orchestrator → Provider selection: requests completion (evidence: `server/src/promptEngine/index.js`)
- Provider selection → OpenAI adapter: selects adapter (evidence: `server/src/providers/index.js`)
- Provider selection → Anthropic adapter: selects adapter (evidence: `server/src/providers/index.js`)
- Provider selection → Gemini adapter: selects adapter (evidence: `server/src/providers/index.js`)
- Provider selection → Groq adapter: selects adapter (evidence: `server/src/providers/index.js`)
- Provider selection → Local engine: falls back (evidence: `server/src/providers/index.js`)
- OpenAI adapter → AI provider services: sends completion
- Anthropic adapter → AI provider services: sends completion
- Gemini adapter → AI provider services: sends completion
- Groq adapter → AI provider services: sends completion
- Provider settings → API client: loads model details (evidence: `src/components/SettingsDrawer.tsx`)
