# kuluruvineeth/chathub architecture

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

- Interactive diagram: https://gitdiagram.com/kuluruvineeth/chathub
- Repository: https://github.com/kuluruvineeth/chathub

## Overview

ChatHub is a browser-keyed, multi-provider AI chat application. Users enter through the home page, get a session, choose an assistant/model and optional tools, submit prompts or attachments, then view and manage responses in a persistent conversation. The README also documents prompt and assistant libraries, voice transcription, web search, image generation, memory, and model tuning. Edges below are limited to calls visible in excerpts or explicit README claims; unsampled integrations are represented without invented call chains.

Main entry points: [`src/hooks/use-tools.tsx`](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-tools.tsx) (Callable tools), [`src/components/chat-input.tsx`](https://github.com/kuluruvineeth/chathub/blob/main/src/components/chat-input.tsx) (Chat composer), [`src/context/chat.tsx`](https://github.com/kuluruvineeth/chathub/blob/main/src/context/chat.tsx) (Chat orchestration), [`src/context/sessions.tsx`](https://github.com/kuluruvineeth/chathub/blob/main/src/context/sessions.tsx) (Session context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Chat workflow"]
  node_home["Session entry<br/>[page.tsx]"]
  node_chatinput["Chat composer<br/>[chat-input.tsx]"]
  node_chatstate["Chat orchestration<br/>[chat.tsx]"]
  node_messages["Message display<br/>[ai-message.tsx]"]
  node_sessionstate["Session context<br/>[sessions.tsx]"]
  node_voice["Voice input"]
  node_editor["Markdown editor and attachments<br/>[use-mdx.tsx]"]
end

subgraph group_configuration["Assistants and settings"]
  node_assistants["Custom assistants"]
  node_assistantstate["Assistant settings<br/>[assistant.tsx]"]
  node_preferences["Preferences and models<br/>[preferences.tsx]"]
  node_modelcatalog["Model selection<br/>[use-model-list.tsx]"]
  node_settings["Model and tool settings<br/>[index.tsx]"]
  node_promptlibrary["Prompt library<br/>[prompt-library.tsx]"]
end

subgraph group_services["AI and tools"]
  node_chatrequest["Model request"]
  node_provider{{"Model providers"}}
  node_tools["Callable tools<br/>[use-tools.tsx]"]
  node_searchtools["Web search tools<br/>[duckduckgo.ts]"]
  node_googlesearch["Google search<br/>[google.ts]"]
  node_calculator["Calculator<br/>[calculator.ts]"]
  node_imagegen["Image generation<br/>[dalle.ts]"]
  node_memorytool["Memory tool<br/>[memory.ts]"]
  node_transcription["Speech transcription API<br/>[route.ts]"]
  node_searchapi["Search API<br/>[route.ts]"]
  node_extractapi["Page extraction<br/>[route.ts]"]
  node_anthropicapi["Anthropic compatibility route<br/>[route.ts]"]
end

subgraph group_persistence["Persistence and content"]
  node_sessionhook["Session operations"]
  node_browserdb[("Browser sessions and keys")]
  node_promptdata["Prompt definitions<br/>[prompts.ts]"]
  node_botapi["Assistant catalog API<br/>[route.ts]"]
  node_promptapi["Prompt catalog API<br/>[route.ts]"]
  node_supabase[("Supabase catalogs<br/>[supabase.ts]")]
end

node_user(("Chat user"))

node_user -->|"opens app"| node_home
node_home -->|"creates session"| node_sessionstate
node_sessionstate -->|"delegates"| node_sessionhook
node_sessionhook -->|"reads and writes"| node_browserdb
node_user -->|"enters prompt"| node_chatinput
node_chatinput -->|"runs model"| node_chatstate
node_chatinput -->|"selects assistant"| node_assistantstate
node_chatinput -->|"records speech"| node_voice
node_voice -.->|"transcribes audio"| node_transcription
node_chatinput -.->|"edits prompt"| node_editor
node_chatstate -.->|"orchestrates request"| node_chatrequest
node_chatrequest -->|"resolves model"| node_modelcatalog
node_chatrequest -.->|"invokes model"| node_provider
node_provider -.->|"returns response"| node_messages
node_chatstate -.->|"dispatches tools"| node_tools
node_tools -.->|"uses search"| node_searchtools
node_tools -.->|"uses search"| node_googlesearch
node_tools -.->|"calculates"| node_calculator
node_tools -.->|"generates image"| node_imagegen
node_tools -.->|"updates memory"| node_memorytool
node_messages -->|"removes message"| node_sessionstate
node_sessionstate -->|"updates sessions"| node_sessionhook
node_user -.->|"configures assistant"| node_assistants
node_assistants -.->|"sets assistant"| node_assistantstate
node_user -.->|"tunes models"| node_settings
node_settings -->|"updates preferences"| node_preferences
node_preferences -.->|"stores keys locally"| node_browserdb
node_promptlibrary -.->|"uses prompts"| node_promptdata
node_promptapi -->|"imports roles"| node_promptdata
node_promptapi -->|"reads prompts"| node_supabase
node_botapi -->|"reads assistants"| node_supabase
node_chatstate -.->|"requests search"| node_searchapi
node_chatstate -.->|"extracts page"| node_extractapi
node_provider -.->|"supports compatibility"| node_anthropicapi

click node_home "https://github.com/kuluruvineeth/chathub/blob/main/src/app/page.tsx"
click node_chatinput "https://github.com/kuluruvineeth/chathub/blob/main/src/components/chat-input.tsx"
click node_chatstate "https://github.com/kuluruvineeth/chathub/blob/main/src/context/chat.tsx"
click node_chatrequest "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-chat-session.tsx"
click node_messages "https://github.com/kuluruvineeth/chathub/blob/main/src/components/messages/ai-message.tsx"
click node_sessionstate "https://github.com/kuluruvineeth/chathub/blob/main/src/context/sessions.tsx"
click node_sessionhook "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-chat-session.tsx"
click node_assistants "https://github.com/kuluruvineeth/chathub/blob/main/src/components/assistants/create-assistant.tsx"
click node_assistantstate "https://github.com/kuluruvineeth/chathub/blob/main/src/context/assistant.tsx"
click node_preferences "https://github.com/kuluruvineeth/chathub/blob/main/src/context/preferences.tsx"
click node_modelcatalog "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-model-list.tsx"
click node_settings "https://github.com/kuluruvineeth/chathub/blob/main/src/components/settings/models/index.tsx"
click node_promptlibrary "https://github.com/kuluruvineeth/chathub/blob/main/src/components/prompts/prompt-library.tsx"
click node_promptdata "https://github.com/kuluruvineeth/chathub/blob/main/src/lib/prompts.ts"
click node_botapi "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/bots/route.ts"
click node_promptapi "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/prompts/route.ts"
click node_supabase "https://github.com/kuluruvineeth/chathub/blob/main/src/lib/supabase.ts"
click node_tools "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-tools.tsx"
click node_searchtools "https://github.com/kuluruvineeth/chathub/blob/main/src/tools/duckduckgo.ts"
click node_googlesearch "https://github.com/kuluruvineeth/chathub/blob/main/src/tools/google.ts"
click node_calculator "https://github.com/kuluruvineeth/chathub/blob/main/src/tools/calculator.ts"
click node_imagegen "https://github.com/kuluruvineeth/chathub/blob/main/src/tools/dalle.ts"
click node_memorytool "https://github.com/kuluruvineeth/chathub/blob/main/src/tools/memory.ts"
click node_voice "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-record-voice.tsx"
click node_transcription "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/speechToText/route.ts"
click node_searchapi "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/search/route.ts"
click node_extractapi "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/extract/route.ts"
click node_anthropicapi "https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/anthropic/v1/messages/route.ts"
click node_editor "https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-mdx.tsx"

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_home,node_chatinput,node_chatstate,node_messages,node_sessionstate,node_voice,node_editor,node_user toneBlue
class node_assistants,node_assistantstate,node_preferences,node_modelcatalog,node_settings,node_promptlibrary toneAmber
class node_chatrequest,node_provider,node_tools,node_searchtools,node_googlesearch,node_calculator,node_imagegen,node_memorytool,node_transcription,node_searchapi,node_extractapi,node_anthropicapi toneMint
class node_sessionhook,node_browserdb,node_promptdata,node_botapi,node_promptapi,node_supabase toneRose
```

## Components

### Chat workflow

- [Session entry](https://github.com/kuluruvineeth/chathub/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Chat composer](https://github.com/kuluruvineeth/chathub/blob/main/src/components/chat-input.tsx): `src/components/chat-input.tsx`
- [Chat orchestration](https://github.com/kuluruvineeth/chathub/blob/main/src/context/chat.tsx): `src/context/chat.tsx`
- [Message display](https://github.com/kuluruvineeth/chathub/blob/main/src/components/messages/ai-message.tsx): `src/components/messages/ai-message.tsx`
- [Session context](https://github.com/kuluruvineeth/chathub/blob/main/src/context/sessions.tsx): `src/context/sessions.tsx`
- [Voice input](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-record-voice.tsx): `src/hooks/use-record-voice.tsx`
- [Markdown editor and attachments](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-mdx.tsx): `src/hooks/use-mdx.tsx`

### Assistants and settings

- [Custom assistants](https://github.com/kuluruvineeth/chathub/blob/main/src/components/assistants/create-assistant.tsx): `src/components/assistants/create-assistant.tsx`
- [Assistant settings](https://github.com/kuluruvineeth/chathub/blob/main/src/context/assistant.tsx): `src/context/assistant.tsx`
- [Preferences and models](https://github.com/kuluruvineeth/chathub/blob/main/src/context/preferences.tsx): `src/context/preferences.tsx`
- [Model selection](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-model-list.tsx): `src/hooks/use-model-list.tsx`
- [Model and tool settings](https://github.com/kuluruvineeth/chathub/blob/main/src/components/settings/models/index.tsx): `src/components/settings/models/index.tsx`
- [Prompt library](https://github.com/kuluruvineeth/chathub/blob/main/src/components/prompts/prompt-library.tsx): `src/components/prompts/prompt-library.tsx`

### AI and tools

- [Model request](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-chat-session.tsx): `src/hooks/use-chat-session.tsx`
- **Model providers**
- [Callable tools](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-tools.tsx): `src/hooks/use-tools.tsx`
- [Web search tools](https://github.com/kuluruvineeth/chathub/blob/main/src/tools/duckduckgo.ts): `src/tools/duckduckgo.ts`
- [Google search](https://github.com/kuluruvineeth/chathub/blob/main/src/tools/google.ts): `src/tools/google.ts`
- [Calculator](https://github.com/kuluruvineeth/chathub/blob/main/src/tools/calculator.ts): `src/tools/calculator.ts`
- [Image generation](https://github.com/kuluruvineeth/chathub/blob/main/src/tools/dalle.ts): `src/tools/dalle.ts`
- [Memory tool](https://github.com/kuluruvineeth/chathub/blob/main/src/tools/memory.ts): `src/tools/memory.ts`
- [Speech transcription API](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/speechToText/route.ts): `src/app/api/speechToText/route.ts`
- [Search API](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/search/route.ts): `src/app/api/search/route.ts`
- [Page extraction](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/extract/route.ts): `src/app/api/extract/route.ts`
- [Anthropic compatibility route](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/anthropic/v1/messages/route.ts): `src/app/api/anthropic/v1/messages/route.ts`

### Persistence and content

- [Session operations](https://github.com/kuluruvineeth/chathub/blob/main/src/hooks/use-chat-session.tsx): `src/hooks/use-chat-session.tsx`
- **Browser sessions and keys**
- [Prompt definitions](https://github.com/kuluruvineeth/chathub/blob/main/src/lib/prompts.ts): `src/lib/prompts.ts`
- [Assistant catalog API](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/bots/route.ts): `src/app/api/bots/route.ts`
- [Prompt catalog API](https://github.com/kuluruvineeth/chathub/blob/main/src/app/api/prompts/route.ts): `src/app/api/prompts/route.ts`
- [Supabase catalogs](https://github.com/kuluruvineeth/chathub/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Chat user**

## Connections

- Chat user → Session entry: opens app (evidence: `src/app/page.tsx`)
- Session entry → Session context: creates session (evidence: `src/app/page.tsx`)
- Session context → Session operations: delegates (evidence: `src/context/sessions.tsx`)
- Session operations → Browser sessions and keys: reads and writes (evidence: `src/hooks/use-chat-session.tsx`)
- Chat user → Chat composer: enters prompt (evidence: `src/components/chat-input.tsx`)
- Chat composer → Chat orchestration: runs model (evidence: `src/components/chat-input.tsx`)
- Chat composer → Assistant settings: selects assistant (evidence: `src/components/chat-input.tsx`)
- Chat composer → Voice input: records speech (evidence: `src/components/chat-input.tsx`)
- Voice input → Speech transcription API: transcribes audio
- Chat composer → Markdown editor and attachments: edits prompt
- Chat orchestration → Model request: orchestrates request
- Model request → Model selection: resolves model (evidence: `src/hooks/use-chat-session.tsx`)
- Model request → Model providers: invokes model
- Model providers → Message display: returns response
- Chat orchestration → Callable tools: dispatches tools
- Callable tools → Web search tools: uses search
- Callable tools → Google search: uses search
- Callable tools → Calculator: calculates
- Callable tools → Image generation: generates image
- Callable tools → Memory tool: updates memory
- Message display → Session context: removes message (evidence: `src/components/messages/ai-message.tsx`)
- Session context → Session operations: updates sessions (evidence: `src/context/sessions.tsx`)
- Chat user → Custom assistants: configures assistant
- Custom assistants → Assistant settings: sets assistant
- Chat user → Model and tool settings: tunes models
- Model and tool settings → Preferences and models: updates preferences
- Preferences and models → Browser sessions and keys: stores keys locally
- Prompt library → Prompt definitions: uses prompts
- Prompt catalog API → Prompt definitions: imports roles (evidence: `src/app/api/prompts/route.ts`)
- Prompt catalog API → Supabase catalogs: reads prompts (evidence: `src/app/api/prompts/route.ts`)
- Assistant catalog API → Supabase catalogs: reads assistants (evidence: `src/app/api/bots/route.ts`)
- Chat orchestration → Search API: requests search
- Chat orchestration → Page extraction: extracts page
- Model providers → Anthropic compatibility route: supports compatibility
