# timmyy123/llm-hub architecture

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

- Interactive diagram: https://gitdiagram.com/timmyy123/llm-hub
- Repository: https://github.com/timmyy123/llm-hub

## Overview

LLM Hub is a cross-platform mobile app for private, primarily on-device AI chat and media tools. The main user journey is to download or import a model, select it, then chat; chat can draw on RAG memory, web search, and speech features. Android source exposes chat, inference, embedding/RAG, model management, agent, and generation modules; the README documents additional iOS and tool capabilities whose implementation is not sampled. Edges use README statements where code-level wiring was not shown, so they describe documented product flow rather than verified calls.

Main entry points: [`android/app/src/main/java/com/llmhub/llmhub/viewmodels/ChatViewModel.kt`](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/viewmodels/ChatViewModel.kt) (Chat workflow), [`android/app/src/main/java/com/llmhub/llmhub/inference/InferenceService.kt`](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/InferenceService.kt) (Inference service), [`android/app/src/main/java/com/llmhub/llmhub/agent/AgentViewModel.kt`](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/AgentViewModel.kt) (AI agent), [`android/app/src/main/java/com/llmhub/llmhub/screens/ChatScreen.kt`](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/screens/ChatScreen.kt) (Chat screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_navigation["App navigation"]
  node_chat["Chat screen<br/>[ChatScreen.kt]"]
  node_chatvm["Chat workflow<br/>[ChatViewModel.kt]"]
  node_chatdata["Chat history<br/>[ChatRepository.kt]"]
  node_database[("App database<br/>[LlmHubDatabase.kt]")]
end

subgraph group_models["Models and inference"]
  node_modelcatalog["Model catalog<br/>[ModelData.kt]"]
  node_modeldownload["Model downloads<br/>[ModelDownloader.kt]"]
  node_modelrepo["Model repository<br/>[ModelRepository.kt]"]
  node_inference["Inference service"]
  node_liteinfer["LiteRT inference"]
  node_llamainfer["Llama inference"]
  node_onnxinfer["ONNX inference"]
end

subgraph group_knowledge["Chat context"]
  node_rag["RAG retrieval<br/>[RagService.kt]"]
  node_embedding["Embeddings"]
  node_websearch["Web search"]
end

subgraph group_tools["AI tools"]
  node_agent["AI agent<br/>[AgentViewModel.kt]"]
  node_agenttools["Agent tools<br/>[AgentToolSet.kt]"]
  node_termux["Termux bridge"]
  node_imagegen["Image generation"]
  node_musicgen["Music generation"]
  node_otherfeatures["Other AI tools"]
end

subgraph group_platform["Platform runtimes"]
  node_iosrag["iOS RAG manager"]
  node_iosmusic["iOS music runtime"]
  node_ioslitert["LiteRT-LM engine<br/>[Engine.swift]"]
  node_iosruntime["iOS runtime SDK<br/>[rac_llm_service.h]"]
end

node_user(("Mobile user"))
node_externalmodels(("Model providers"))
node_termuxservice(("Termux service"))

node_user -->|"opens tools"| node_navigation
node_navigation -.->|"opens chat"| node_chat
node_user -->|"downloads or imports"| node_modeldownload
node_modeldownload -.->|"selects model"| node_modelcatalog
node_user -->|"starts chatting"| node_chat
node_chat -.->|"submits prompt"| node_chatvm
node_chatvm -.->|"requests response"| node_inference
node_chatvm -.->|"saves conversations"| node_chatdata
node_chatdata -.->|"persists history"| node_database
node_inference -.->|"uses backend"| node_liteinfer
node_inference -.->|"uses backend"| node_llamainfer
node_inference -.->|"uses backend"| node_onnxinfer
node_chatvm -->|"uses memory"| node_rag
node_rag -.->|"retrieves embeddings"| node_embedding
node_chatvm -->|"uses web search"| node_websearch
node_user -->|"runs agent"| node_agent
node_agent -->|"invokes tools"| node_agenttools
node_agent -->|"runs commands"| node_termux
node_termux -->|"sends intent"| node_termuxservice
node_user -->|"creates images"| node_imagegen
node_user -->|"generates music"| node_musicgen
node_user -->|"uses AI tools"| node_otherfeatures
node_user -.->|"uses RAG"| node_iosrag
node_user -->|"generates music"| node_iosmusic
node_user -.->|"runs local models"| node_ioslitert
node_user -->|"runs local models"| node_iosruntime
node_modelcatalog -->|"downloads models"| node_externalmodels

click node_navigation "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/navigation/LlmHubNavigation.kt"
click node_chat "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/screens/ChatScreen.kt"
click node_chatvm "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/viewmodels/ChatViewModel.kt"
click node_chatdata "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/repository/ChatRepository.kt"
click node_database "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/LlmHubDatabase.kt"
click node_modelcatalog "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelData.kt"
click node_modeldownload "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelDownloader.kt"
click node_modelrepo "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelRepository.kt"
click node_inference "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/InferenceService.kt"
click node_liteinfer "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/LiteRtLmInferenceService.kt"
click node_llamainfer "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/LlamaCppInferenceService.kt"
click node_onnxinfer "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/OnnxInferenceService.kt"
click node_rag "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/embedding/RagService.kt"
click node_embedding "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/embedding/EmbeddingService.kt"
click node_websearch "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/websearch/WebSearchService.kt"
click node_agent "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/AgentViewModel.kt"
click node_agenttools "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/AgentToolSet.kt"
click node_termux "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/TermuxCommandBridge.kt"
click node_imagegen "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/imagegen/ImageGeneratorHelper.kt"
click node_musicgen "https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/MusicGeneratorBackend.kt"
click node_otherfeatures "https://github.com/timmyy123/llm-hub/tree/main/android/app/src/main/java/com/llmhub/llmhub/screens"
click node_iosrag "https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/Sources/LLMHub/RagServiceManager.swift"
click node_iosmusic "https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/magenta-runtime/Sources/MagentaRuntime/MagentaRealtimeEngine.swift"
click node_ioslitert "https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/LiteRT-LM/swift/Engine.swift"
click node_iosruntime "https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/RunAnywhereBinaries/RACommons.xcframework/ios-arm64/Headers/rac/features/llm/rac_llm_service.h"

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_navigation,node_chat,node_chatvm,node_chatdata,node_database,node_user toneBlue
class node_modelcatalog,node_modeldownload,node_modelrepo,node_inference,node_liteinfer,node_llamainfer,node_onnxinfer toneAmber
class node_rag,node_embedding,node_websearch toneMint
class node_agent,node_agenttools,node_termux,node_imagegen,node_musicgen,node_otherfeatures toneRose
class node_iosrag,node_iosmusic,node_ioslitert,node_iosruntime,node_externalmodels,node_termuxservice toneIndigo
```

## Components

### App experience

- [App navigation](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/navigation/LlmHubNavigation.kt): `android/app/src/main/java/com/llmhub/llmhub/navigation/LlmHubNavigation.kt`
- [Chat screen](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/screens/ChatScreen.kt): `android/app/src/main/java/com/llmhub/llmhub/screens/ChatScreen.kt`
- [Chat workflow](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/viewmodels/ChatViewModel.kt): `android/app/src/main/java/com/llmhub/llmhub/viewmodels/ChatViewModel.kt`
- [Chat history](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/repository/ChatRepository.kt): `android/app/src/main/java/com/llmhub/llmhub/repository/ChatRepository.kt`
- [App database](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/LlmHubDatabase.kt): `android/app/src/main/java/com/llmhub/llmhub/data/LlmHubDatabase.kt`

### Models and inference

- [Model catalog](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelData.kt): `android/app/src/main/java/com/llmhub/llmhub/data/ModelData.kt`
- [Model downloads](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelDownloader.kt): `android/app/src/main/java/com/llmhub/llmhub/data/ModelDownloader.kt`
- [Model repository](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/ModelRepository.kt): `android/app/src/main/java/com/llmhub/llmhub/data/ModelRepository.kt`
- [Inference service](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/InferenceService.kt): `android/app/src/main/java/com/llmhub/llmhub/inference/InferenceService.kt`
- [LiteRT inference](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/LiteRtLmInferenceService.kt): `android/app/src/main/java/com/llmhub/llmhub/inference/LiteRtLmInferenceService.kt`
- [Llama inference](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/LlamaCppInferenceService.kt): `android/app/src/main/java/com/llmhub/llmhub/inference/LlamaCppInferenceService.kt`
- [ONNX inference](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/inference/OnnxInferenceService.kt): `android/app/src/main/java/com/llmhub/llmhub/inference/OnnxInferenceService.kt`

### Chat context

- [RAG retrieval](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/embedding/RagService.kt): `android/app/src/main/java/com/llmhub/llmhub/embedding/RagService.kt`
- [Embeddings](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/embedding/EmbeddingService.kt): `android/app/src/main/java/com/llmhub/llmhub/embedding/EmbeddingService.kt`
- [Web search](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/websearch/WebSearchService.kt): `android/app/src/main/java/com/llmhub/llmhub/websearch/WebSearchService.kt`

### AI tools

- [AI agent](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/AgentViewModel.kt): `android/app/src/main/java/com/llmhub/llmhub/agent/AgentViewModel.kt`
- [Agent tools](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/AgentToolSet.kt): `android/app/src/main/java/com/llmhub/llmhub/agent/AgentToolSet.kt`
- [Termux bridge](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/agent/TermuxCommandBridge.kt): `android/app/src/main/java/com/llmhub/llmhub/agent/TermuxCommandBridge.kt`
- [Image generation](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/imagegen/ImageGeneratorHelper.kt): `android/app/src/main/java/com/llmhub/llmhub/imagegen/ImageGeneratorHelper.kt`
- [Music generation](https://github.com/timmyy123/llm-hub/blob/main/android/app/src/main/java/com/llmhub/llmhub/data/MusicGeneratorBackend.kt): `android/app/src/main/java/com/llmhub/llmhub/data/MusicGeneratorBackend.kt`
- [Other AI tools](https://github.com/timmyy123/llm-hub/tree/main/android/app/src/main/java/com/llmhub/llmhub/screens): `android/app/src/main/java/com/llmhub/llmhub/screens`

### Platform runtimes

- [iOS RAG manager](https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/Sources/LLMHub/RagServiceManager.swift): `ios/LLMHub/Sources/LLMHub/RagServiceManager.swift`
- [iOS music runtime](https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/magenta-runtime/Sources/MagentaRuntime/MagentaRealtimeEngine.swift): `ios/LLMHub/LocalPackages/magenta-runtime/Sources/MagentaRuntime/MagentaRealtimeEngine.swift`
- [LiteRT-LM engine](https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/LiteRT-LM/swift/Engine.swift): `ios/LLMHub/LocalPackages/LiteRT-LM/swift/Engine.swift`
- [iOS runtime SDK](https://github.com/timmyy123/llm-hub/blob/main/ios/LLMHub/LocalPackages/RunAnywhereBinaries/RACommons.xcframework/ios-arm64/Headers/rac/features/llm/rac_llm_service.h): `ios/LLMHub/LocalPackages/RunAnywhereBinaries/RACommons.xcframework/ios-arm64/Headers/rac/features/llm/rac_llm_service.h`

### Other components

- **Mobile user**
- **Model providers**
- **Termux service**

## Connections

- Mobile user → App navigation: opens tools (evidence: `README.md`)
- App navigation → Chat screen: opens chat
- Mobile user → Model downloads: downloads or imports (evidence: `README.md`)
- Model downloads → Model catalog: selects model
- Mobile user → Chat screen: starts chatting (evidence: `README.md`)
- Chat screen → Chat workflow: submits prompt
- Chat workflow → Inference service: requests response
- Chat workflow → Chat history: saves conversations
- Chat history → App database: persists history
- Inference service → LiteRT inference: uses backend (evidence: `android/app/src/main/java/com/llmhub/llmhub/inference/LiteRtLmInferenceService.kt`)
- Inference service → Llama inference: uses backend (evidence: `android/app/src/main/java/com/llmhub/llmhub/inference/LlamaCppInferenceService.kt`)
- Inference service → ONNX inference: uses backend (evidence: `android/app/src/main/java/com/llmhub/llmhub/inference/OnnxInferenceService.kt`)
- Chat workflow → RAG retrieval: uses memory (evidence: `README.md`)
- RAG retrieval → Embeddings: retrieves embeddings (evidence: `android/app/src/main/java/com/llmhub/llmhub/embedding/RagService.kt`)
- Chat workflow → Web search: uses web search (evidence: `README.md`)
- Mobile user → AI agent: runs agent (evidence: `README.md`)
- AI agent → Agent tools: invokes tools (evidence: `README.md`)
- AI agent → Termux bridge: runs commands (evidence: `README.md`)
- Termux bridge → Termux service: sends intent (evidence: `README.md`)
- Mobile user → Image generation: creates images (evidence: `README.md`)
- Mobile user → Music generation: generates music (evidence: `README.md`)
- Mobile user → Other AI tools: uses AI tools (evidence: `README.md`)
- Mobile user → iOS RAG manager: uses RAG
- Mobile user → iOS music runtime: generates music (evidence: `README.md`)
- Mobile user → LiteRT-LM engine: runs local models
- Mobile user → iOS runtime SDK: runs local models (evidence: `README.md`)
- Model catalog → Model providers: downloads models (evidence: `README.md`)
