# kevinhermawan/ollamac architecture

> Architecture diagram of the GitHub repository kevinhermawan/ollamac, 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/kevinhermawan/ollamac
- Repository: https://github.com/kevinhermawan/ollamac

## Overview

Ollamac is a native macOS chat client for a locally available Ollama server. Users select or create a chat, choose a model, submit prompts, and receive streamed responses; chats and messages are represented in SwiftData. Settings and per-chat preferences configure the Ollama host and system prompt, while assistant-message rendering supports Markdown and optional syntax highlighting. The graph follows relationships shown in excerpts and the SOURCE INDEX; unsampled implementations are represented only where their paths and connections are documented there.

Main entry points: [`Ollamac/Views/Chats/ChatView.swift`](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/ChatView.swift) (Chat screen), [`Ollamac/ViewModels/MessageViewModel.swift`](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/MessageViewModel.swift) (Message generation), [`Ollamac/Views/Sidebar/SidebarView.swift`](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarView.swift) (Chat sidebar), [`Ollamac/ViewModels/ChatViewModel.swift`](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/ChatViewModel.swift) (Chat management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App and Navigation"]
  node_app["App bootstrap<br/>[OllamacApp.swift]"]
  node_appview["App shell<br/>[AppView.swift]"]
  node_sidebar["Chat sidebar<br/>[SidebarView.swift]"]
  node_sidebaritem["Sidebar item"]
  node_sidebarmenu["Sidebar actions"]
end

subgraph group_chat["Chat and Ollama"]
  node_chatview["Chat screen<br/>[ChatView.swift]"]
  node_chatvm["Chat management"]
  node_messagevm["Message generation"]
  node_ollama{{"Ollama server"}}
  node_chatmodel[("Chat record<br/>[Chat.swift]")]
  node_messagemodel[("Message record<br/>[Message.swift]")]
end

subgraph group_preferences["Preferences"]
  node_chatprefs["Chat preferences"]
  node_hostsheet["Host editor"]
  node_promptsheet["System prompt editor"]
  node_settings["Settings hub<br/>[SettingsView.swift]"]
  node_general["General settings<br/>[GeneralView.swift]"]
  node_experimental["Experimental settings"]
end

subgraph group_rendering["Message Rendering"]
  node_assistantview["Assistant message"]
  node_userview["User message"]
  node_codeblock["Code block"]
  node_highlighter["Syntax highlighter"]
end

node_user(("Mac user"))

node_user -->|"uses"| node_appview
node_app -->|"presents"| node_appview
node_app -->|"initializes"| node_chatvm
node_app -->|"initializes"| node_messagevm
node_app -->|"initializes"| node_highlighter
node_appview -->|"shows"| node_sidebar
node_appview -->|"shows"| node_chatview
node_sidebar -->|"uses"| node_chatvm
node_sidebar -->|"uses"| node_messagevm
node_sidebar -->|"renders"| node_sidebaritem
node_sidebar -->|"uses"| node_sidebarmenu
node_sidebarmenu -->|"updates"| node_chatvm
node_chatview -->|"uses"| node_chatvm
node_chatview -->|"uses"| node_messagevm
node_chatview -->|"presents"| node_chatprefs
node_chatview -->|"renders"| node_userview
node_chatview -->|"renders"| node_assistantview
node_chatvm -->|"manages"| node_chatmodel
node_messagevm -->|"loads and saves"| node_messagemodel
node_messagevm -->|"updates"| node_chatmodel
node_messagemodel -->|"belongs to"| node_chatmodel
node_chatview -->|"fetches models"| node_ollama
node_messagevm -->|"streams chat"| node_ollama
node_chatprefs -->|"opens"| node_hostsheet
node_chatprefs -->|"opens"| node_promptsheet
node_settings -->|"shows"| node_general
node_settings -->|"shows"| node_experimental
node_general -->|"opens"| node_hostsheet
node_general -->|"opens"| node_promptsheet
node_hostsheet -->|"checks reachability"| node_ollama
node_assistantview -->|"uses"| node_highlighter
node_assistantview -.->|"renders"| node_codeblock
node_codeblock -->|"reads state"| node_highlighter
node_userview -.->|"shares message controls"| node_assistantview

click node_app "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/App/OllamacApp.swift"
click node_appview "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/AppView.swift"
click node_sidebar "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarView.swift"
click node_sidebaritem "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarListItemView.swift"
click node_sidebarmenu "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarContextMenu.swift"
click node_chatview "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/ChatView.swift"
click node_chatvm "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/ChatViewModel.swift"
click node_messagevm "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/MessageViewModel.swift"
click node_chatmodel "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Models/Chat.swift"
click node_messagemodel "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Models/Message.swift"
click node_chatprefs "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/ChatPreferencesView.swift"
click node_hostsheet "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Sheets/UpdateOllamaHostSheet.swift"
click node_promptsheet "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Sheets/UpdateSystemPromptSheet.swift"
click node_settings "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/SettingsView.swift"
click node_general "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/GeneralView.swift"
click node_experimental "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/ExperimentalView.swift"
click node_assistantview "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/Subviews/AssistantMessageView.swift"
click node_userview "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/Subviews/UserMessageView.swift"
click node_codeblock "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Utils/CodeBlockView.swift"
click node_highlighter "https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Utils/CodeHighlighter.swift"

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_appview,node_sidebar,node_sidebaritem,node_sidebarmenu,node_user toneBlue
class node_chatview,node_chatvm,node_messagevm,node_ollama,node_chatmodel,node_messagemodel toneAmber
class node_chatprefs,node_hostsheet,node_promptsheet,node_settings,node_general,node_experimental toneMint
class node_assistantview,node_userview,node_codeblock,node_highlighter toneRose
```

## Components

### App and Navigation

- [App bootstrap](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/App/OllamacApp.swift): `Ollamac/App/OllamacApp.swift`
- [App shell](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/AppView.swift): `Ollamac/Views/AppView.swift`
- [Chat sidebar](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarView.swift): `Ollamac/Views/Sidebar/SidebarView.swift`
- [Sidebar item](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarListItemView.swift): `Ollamac/Views/Sidebar/SidebarListItemView.swift`
- [Sidebar actions](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Sidebar/SidebarContextMenu.swift): `Ollamac/Views/Sidebar/SidebarContextMenu.swift`

### Chat and Ollama

- [Chat screen](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/ChatView.swift): `Ollamac/Views/Chats/ChatView.swift`
- [Chat management](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/ChatViewModel.swift): `Ollamac/ViewModels/ChatViewModel.swift`
- [Message generation](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/ViewModels/MessageViewModel.swift): `Ollamac/ViewModels/MessageViewModel.swift`
- **Ollama server**
- [Chat record](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Models/Chat.swift): `Ollamac/Models/Chat.swift`
- [Message record](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Models/Message.swift): `Ollamac/Models/Message.swift`

### Preferences

- [Chat preferences](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/ChatPreferencesView.swift): `Ollamac/Views/Chats/ChatPreferencesView.swift`
- [Host editor](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Sheets/UpdateOllamaHostSheet.swift): `Ollamac/Sheets/UpdateOllamaHostSheet.swift`
- [System prompt editor](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Sheets/UpdateSystemPromptSheet.swift): `Ollamac/Sheets/UpdateSystemPromptSheet.swift`
- [Settings hub](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/SettingsView.swift): `Ollamac/Views/Settings/SettingsView.swift`
- [General settings](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/GeneralView.swift): `Ollamac/Views/Settings/GeneralView.swift`
- [Experimental settings](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Settings/ExperimentalView.swift): `Ollamac/Views/Settings/ExperimentalView.swift`

### Message Rendering

- [Assistant message](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/Subviews/AssistantMessageView.swift): `Ollamac/Views/Chats/Subviews/AssistantMessageView.swift`
- [User message](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Views/Chats/Subviews/UserMessageView.swift): `Ollamac/Views/Chats/Subviews/UserMessageView.swift`
- [Code block](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Utils/CodeBlockView.swift): `Ollamac/Utils/CodeBlockView.swift`
- [Syntax highlighter](https://github.com/kevinhermawan/ollamac/blob/main/Ollamac/Utils/CodeHighlighter.swift): `Ollamac/Utils/CodeHighlighter.swift`

### Other components

- **Mac user**

## Connections

- Mac user → App shell: uses (evidence: `Ollamac/Views/AppView.swift`)
- App bootstrap → App shell: presents (evidence: `Ollamac/App/OllamacApp.swift`)
- App bootstrap → Chat management: initializes (evidence: `Ollamac/App/OllamacApp.swift`)
- App bootstrap → Message generation: initializes (evidence: `Ollamac/App/OllamacApp.swift`)
- App bootstrap → Syntax highlighter: initializes (evidence: `Ollamac/App/OllamacApp.swift`)
- App shell → Chat sidebar: shows (evidence: `Ollamac/Views/AppView.swift`)
- App shell → Chat screen: shows (evidence: `Ollamac/Views/AppView.swift`)
- Chat sidebar → Chat management: uses (evidence: `Ollamac/Views/Sidebar/SidebarView.swift`)
- Chat sidebar → Message generation: uses (evidence: `Ollamac/Views/Sidebar/SidebarView.swift`)
- Chat sidebar → Sidebar item: renders (evidence: `Ollamac/Views/Sidebar/SidebarView.swift`)
- Chat sidebar → Sidebar actions: uses (evidence: `Ollamac/Views/Sidebar/SidebarView.swift`)
- Sidebar actions → Chat management: updates (evidence: `Ollamac/Views/Sidebar/SidebarContextMenu.swift`)
- Chat screen → Chat management: uses (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Chat screen → Message generation: uses (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Chat screen → Chat preferences: presents (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Chat screen → User message: renders (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Chat screen → Assistant message: renders (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Chat management → Chat record: manages (evidence: `Ollamac/ViewModels/ChatViewModel.swift`)
- Message generation → Message record: loads and saves (evidence: `Ollamac/ViewModels/MessageViewModel.swift`)
- Message generation → Chat record: updates (evidence: `Ollamac/ViewModels/MessageViewModel.swift`)
- Message record → Chat record: belongs to (evidence: `Ollamac/Models/Message.swift`)
- Chat screen → Ollama server: fetches models (evidence: `Ollamac/Views/Chats/ChatView.swift`)
- Message generation → Ollama server: streams chat (evidence: `Ollamac/ViewModels/MessageViewModel.swift`)
- Chat preferences → Host editor: opens (evidence: `Ollamac/Views/Chats/ChatPreferencesView.swift`)
- Chat preferences → System prompt editor: opens (evidence: `Ollamac/Views/Chats/ChatPreferencesView.swift`)
- Settings hub → General settings: shows (evidence: `Ollamac/Views/Settings/SettingsView.swift`)
- Settings hub → Experimental settings: shows (evidence: `Ollamac/Views/Settings/SettingsView.swift`)
- General settings → Host editor: opens (evidence: `Ollamac/Views/Settings/GeneralView.swift`)
- General settings → System prompt editor: opens (evidence: `Ollamac/Views/Settings/GeneralView.swift`)
- Host editor → Ollama server: checks reachability (evidence: `Ollamac/Sheets/UpdateOllamaHostSheet.swift`)
- Assistant message → Syntax highlighter: uses (evidence: `Ollamac/Views/Chats/Subviews/AssistantMessageView.swift`)
- Assistant message → Code block: renders
- Code block → Syntax highlighter: reads state (evidence: `Ollamac/Utils/CodeBlockView.swift`)
- User message → Assistant message: shares message controls
