# affifuddin-hazam/ghost-infer architecture

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

- Interactive diagram: https://gitdiagram.com/affifuddin-hazam/ghost-infer
- Repository: https://github.com/affifuddin-hazam/ghost-infer

## Overview

ghost-infer combines a local NVIDIA-GPU inference engine, an OpenAI-compatible server, and a native desktop client. A user can chat through the desktop app or another API client; requests reach the server, which runs model inference and, for agent chats, coordinates file and command tools before streaming results. The desktop app also supports voice calls and model management. The graph preserves documented inference optimizations and agent integrations; some server internals are unsampled, so only documented or indexed relationships are shown.

Main entry points: [`src/server/agent.rs`](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/agent.rs) (Agent loop), [`src/server.rs`](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server.rs) (HTTP server), [`app/src/main.rs`](https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/main.rs) (Desktop app), [`src/model.rs`](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/model.rs) (Transformer model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_desktop["Desktop app<br/>[main.rs]"]
  node_ui["Chat interface<br/>[view.rs]"]
  node_local_api["App API client<br/>[api.rs]"]
end

subgraph group_server["Local server"]
  node_http["HTTP server<br/>[server.rs]"]
  node_downloads["Model downloads<br/>[download.rs]"]
end

subgraph group_agent["Agent capabilities"]
  node_agent_loop["Agent loop<br/>[agent.rs]"]
  node_tool_runner["File and command tools<br/>[tools.rs]"]
  node_mcp["MCP integrations<br/>[mcp.rs]"]
  node_plugins["Plugins<br/>[plugins.rs]"]
  node_skills["Skills<br/>[skills.rs]"]
  node_scheduling["Background jobs<br/>[schedule.rs]"]
end

subgraph group_inference["Inference engine"]
  node_gguf["GGUF reader<br/>[gguf.rs]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.rs]"]
  node_model["Transformer model<br/>[model.rs]"]
  node_quant["Quantized kernels<br/>[quant.rs]"]
  node_cuda["CUDA runtime<br/>[cuda.rs]"]
  node_speculative["Speculative decoding<br/>[lookup.rs]"]
end

subgraph group_voice["Voice"]
  node_speech["Speech API<br/>[speech.rs]"]
  node_maya["Maya calls<br/>[maya.rs]"]
  node_speech_models["Speech models<br/>[csm.rs]"]
  node_whisper["Speech recognition<br/>[whisper.rs]"]
end

node_person(("User"))
node_external_client(("API clients"))

node_person -->|"uses"| node_desktop
node_desktop -->|"renders"| node_ui
node_desktop -->|"requests"| node_local_api
node_local_api -->|"calls local API"| node_http
node_external_client -->|"sends API requests"| node_http
node_http -->|"dispatches chats"| node_agent_loop
node_agent_loop -->|"generates replies"| node_model
node_agent_loop -->|"runs tools"| node_tool_runner
node_agent_loop -->|"dispatches MCP tools"| node_mcp
node_agent_loop -->|"manages plugins"| node_plugins
node_agent_loop -->|"uses skills"| node_skills
node_agent_loop -->|"delegates jobs"| node_scheduling
node_http -->|"loads models"| node_gguf
node_http -->|"tokenizes requests"| node_tokenizer
node_http -->|"runs inference"| node_cuda
node_model -->|"reads model data"| node_gguf
node_model -->|"uses kernels"| node_quant
node_quant -.->|"executes GPU work"| node_cuda
node_model -.->|"uses lookup guesses"| node_speculative
node_http -.->|"serves model downloads"| node_downloads
node_http -->|"routes speech requests"| node_speech
node_speech -->|"synthesizes speech"| node_speech_models
node_speech -->|"transcribes audio"| node_whisper
node_maya -->|"uses persona"| node_agent_loop
node_desktop -.->|"starts voice calls"| node_maya

click node_desktop "https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/main.rs"
click node_ui "https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/view.rs"
click node_local_api "https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/api.rs"
click node_http "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server.rs"
click node_agent_loop "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/agent.rs"
click node_tool_runner "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/tools.rs"
click node_mcp "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/mcp.rs"
click node_plugins "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/plugins.rs"
click node_skills "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/skills.rs"
click node_scheduling "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/schedule.rs"
click node_gguf "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/gguf.rs"
click node_tokenizer "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/tokenizer.rs"
click node_model "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/model.rs"
click node_quant "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/quant.rs"
click node_cuda "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/cuda.rs"
click node_speculative "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/lookup.rs"
click node_speech "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/speech.rs"
click node_maya "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/maya.rs"
click node_speech_models "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/csm.rs"
click node_whisper "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/whisper.rs"
click node_downloads "https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/download.rs"

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_desktop,node_ui,node_local_api,node_person,node_external_client toneBlue
class node_http,node_downloads toneAmber
class node_agent_loop,node_tool_runner,node_mcp,node_plugins,node_skills,node_scheduling toneMint
class node_gguf,node_tokenizer,node_model,node_quant,node_cuda,node_speculative toneRose
class node_speech,node_maya,node_speech_models,node_whisper toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/main.rs): `app/src/main.rs`
- [Chat interface](https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/view.rs): `app/src/view.rs`
- [App API client](https://github.com/affifuddin-hazam/ghost-infer/blob/main/app/src/api.rs): `app/src/api.rs`

### Local server

- [HTTP server](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server.rs): `src/server.rs`
- [Model downloads](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/download.rs): `src/server/download.rs`

### Agent capabilities

- [Agent loop](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/agent.rs): `src/server/agent.rs`
- [File and command tools](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/tools.rs): `src/tools.rs`
- [MCP integrations](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/mcp.rs): `src/server/mcp.rs`
- [Plugins](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/plugins.rs): `src/server/plugins.rs`
- [Skills](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/skills.rs): `src/server/skills.rs`
- [Background jobs](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/schedule.rs): `src/server/schedule.rs`

### Inference engine

- [GGUF reader](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/gguf.rs): `src/gguf.rs`
- [Tokenizer](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/tokenizer.rs): `src/tokenizer.rs`
- [Transformer model](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/model.rs): `src/model.rs`
- [Quantized kernels](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/quant.rs): `src/quant.rs`
- [CUDA runtime](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/cuda.rs): `src/cuda.rs`
- [Speculative decoding](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/lookup.rs): `src/lookup.rs`

### Voice

- [Speech API](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/speech.rs): `src/server/speech.rs`
- [Maya calls](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/server/maya.rs): `src/server/maya.rs`
- [Speech models](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/csm.rs): `src/csm.rs`
- [Speech recognition](https://github.com/affifuddin-hazam/ghost-infer/blob/main/src/whisper.rs): `src/whisper.rs`

### Other components

- **User**
- **API clients**

## Connections

- User → Desktop app: uses
- Desktop app → Chat interface: renders (evidence: `app/src/main.rs`)
- Desktop app → App API client: requests (evidence: `app/src/main.rs`)
- App API client → HTTP server: calls local API
- API clients → HTTP server: sends API requests
- HTTP server → Agent loop: dispatches chats (evidence: `src/server.rs`)
- Agent loop → Transformer model: generates replies (evidence: `src/server/agent.rs`)
- Agent loop → File and command tools: runs tools (evidence: `src/server/agent.rs`)
- Agent loop → MCP integrations: dispatches MCP tools (evidence: `src/server/agent.rs`)
- Agent loop → Plugins: manages plugins (evidence: `src/server/agent.rs`)
- Agent loop → Skills: uses skills (evidence: `src/server/agent.rs`)
- Agent loop → Background jobs: delegates jobs (evidence: `src/server/agent.rs`)
- HTTP server → GGUF reader: loads models (evidence: `src/server.rs`)
- HTTP server → Tokenizer: tokenizes requests (evidence: `src/server.rs`)
- HTTP server → CUDA runtime: runs inference (evidence: `src/server.rs`)
- Transformer model → GGUF reader: reads model data (evidence: `src/model.rs`)
- Transformer model → Quantized kernels: uses kernels (evidence: `src/model.rs`)
- Quantized kernels → CUDA runtime: executes GPU work
- Transformer model → Speculative decoding: uses lookup guesses
- HTTP server → Model downloads: serves model downloads (evidence: `src/server.rs`)
- HTTP server → Speech API: routes speech requests (evidence: `src/server.rs`)
- Speech API → Speech models: synthesizes speech (evidence: `src/server/speech.rs`)
- Speech API → Speech recognition: transcribes audio (evidence: `src/server/speech.rs`)
- Maya calls → Agent loop: uses persona (evidence: `src/server/maya.rs`)
- Desktop app → Maya calls: starts voice calls
