# jrxid09-design/damar architecture

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

- Interactive diagram: https://gitdiagram.com/jrxid09-design/damar
- Repository: https://github.com/jrxid09-design/damar

## Overview

Damar is a local-first AI runtime and assistant, exposed through desktop, CLI, and API clients. A user request enters the shared runtime, gains memory and mind context, and is handled by an AI provider with tools available for actions; the response returns through the initiating channel. The graph also preserves major documented capabilities such as autonomy, integrations, voice, vision, and trading. Edges use README statements or SOURCE INDEX references; unsampled subsystems are represented only at their documented boundaries.

Main entry points: [`src/services/aiRuntimeService.js`](https://github.com/jrxid09-design/damar/blob/develop/src/services/aiRuntimeService.js) (AI Runtime), [`src/services/agentHub.js`](https://github.com/jrxid09-design/damar/blob/develop/src/services/agentHub.js) (Agent Hub), [`src/server.js`](https://github.com/jrxid09-design/damar/blob/develop/src/server.js) (Daemon API), [`src/ai/context/Pipeline.js`](https://github.com/jrxid09-design/damar/blob/develop/src/ai/context/Pipeline.js) (Context Assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_console["Desktop Console<br/>[app.js]"]
  node_cli["CLI<br/>[commands.js]"]
  node_daemon["Daemon API<br/>[server.js]"]
end

subgraph group_runtime["Conversation Runtime"]
  node_channels["Channel Manager<br/>[channels.js]"]
  node_agenthub["Agent Hub<br/>[agentHub.js]"]
  node_context["Context Assembly<br/>[Pipeline.js]"]
  node_ai_runtime["AI Runtime"]
end

subgraph group_intelligence["AI and Autonomy"]
  node_providers["Model Providers"]
  node_tool_selection["Tool Selection<br/>[Pipeline.js]"]
  node_authorization["Tool Authorization<br/>[Authorization.js]"]
  node_autonomy["Autonomous Goals<br/>[GoalEngine.js]"]
end

subgraph group_state["Persistent State"]
  node_memory["Long-Term Memory<br/>[MemoryService.js]"]
  node_memory_db[("Memory Database<br/>[index.js]")]
  node_mind["Consciousness and Mind<br/>[index.js]"]
end

subgraph group_capabilities["Assistant Capabilities"]
  node_integrations["Messaging and Integrations"]
  node_voice["Voice Runtime<br/>[voice.js]"]
  node_vision["Vision Services"]
  node_trading["Trading and Profit<br/>[ProfitEngine.js]"]
  node_mata_dewa["Mata Dewa<br/>[service.js]"]
end

node_user(("User"))
node_provider_service{{"External AI Provider"}}

node_user -->|"uses"| node_console
node_user -->|"uses"| node_cli
node_user -->|"uses"| node_daemon
node_console -.->|"requests"| node_daemon
node_cli -.->|"requests"| node_daemon
node_daemon -.->|"routes requests"| node_channels
node_channels -.->|"dispatches"| node_agenthub
node_agenthub -->|"assembles context"| node_context
node_agenthub -->|"requests completion"| node_ai_runtime
node_context -->|"recalls context"| node_memory
node_context -->|"adds mind state"| node_mind
node_ai_runtime -->|"runs inference"| node_providers
node_providers -.->|"calls provider"| node_provider_service
node_ai_runtime -->|"selects tools"| node_tool_selection
node_tool_selection -->|"checks eligibility"| node_authorization
node_autonomy -->|"authorizes tools"| node_tool_selection
node_memory -->|"reads and writes"| node_memory_db
node_integrations -->|"provides agent connectors"| node_agenthub
node_user -->|"speaks to"| node_voice
node_voice -->|"uses shared core"| node_ai_runtime
node_vision -.->|"feeds chat"| node_ai_runtime
node_user -->|"requests trading skills"| node_trading
node_user -->|"uses Console map"| node_mata_dewa

click node_console "https://github.com/jrxid09-design/damar/blob/develop/apps/console/renderer/app.js"
click node_cli "https://github.com/jrxid09-design/damar/blob/develop/src/cli/commands.js"
click node_daemon "https://github.com/jrxid09-design/damar/blob/develop/src/server.js"
click node_channels "https://github.com/jrxid09-design/damar/blob/develop/src/manager/channels.js"
click node_agenthub "https://github.com/jrxid09-design/damar/blob/develop/src/services/agentHub.js"
click node_context "https://github.com/jrxid09-design/damar/blob/develop/src/ai/context/Pipeline.js"
click node_ai_runtime "https://github.com/jrxid09-design/damar/blob/develop/src/services/aiRuntimeService.js"
click node_providers "https://github.com/jrxid09-design/damar/blob/develop/src/ai/providers/AIProviderFactory.js"
click node_tool_selection "https://github.com/jrxid09-design/damar/blob/develop/src/ai/tools/Pipeline.js"
click node_authorization "https://github.com/jrxid09-design/damar/blob/develop/src/ai/tools/Authorization.js"
click node_autonomy "https://github.com/jrxid09-design/damar/blob/develop/src/autonomy/GoalEngine.js"
click node_memory "https://github.com/jrxid09-design/damar/blob/develop/src/memory/services/MemoryService.js"
click node_memory_db "https://github.com/jrxid09-design/damar/blob/develop/src/memory/db/index.js"
click node_mind "https://github.com/jrxid09-design/damar/blob/develop/src/consciousness/index.js"
click node_integrations "https://github.com/jrxid09-design/damar/blob/develop/src/integrations/IntegrationManager.js"
click node_voice "https://github.com/jrxid09-design/damar/blob/develop/apps/console/renderer/lib/voice.js"
click node_vision "https://github.com/jrxid09-design/damar/blob/develop/src/controllers/visionController.js"
click node_trading "https://github.com/jrxid09-design/damar/blob/develop/src/money/ProfitEngine.js"
click node_mata_dewa "https://github.com/jrxid09-design/damar/blob/develop/src/mataDewa/service.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_console,node_cli,node_daemon,node_user toneBlue
class node_channels,node_agenthub,node_context,node_ai_runtime toneAmber
class node_providers,node_tool_selection,node_authorization,node_autonomy toneMint
class node_memory,node_memory_db,node_mind toneRose
class node_integrations,node_voice,node_vision,node_trading,node_mata_dewa,node_provider_service toneIndigo
```

## Components

### User Interfaces

- [Desktop Console](https://github.com/jrxid09-design/damar/blob/develop/apps/console/renderer/app.js): `apps/console/renderer/app.js`
- [CLI](https://github.com/jrxid09-design/damar/blob/develop/src/cli/commands.js): `src/cli/commands.js`
- [Daemon API](https://github.com/jrxid09-design/damar/blob/develop/src/server.js): `src/server.js`

### Conversation Runtime

- [Channel Manager](https://github.com/jrxid09-design/damar/blob/develop/src/manager/channels.js): `src/manager/channels.js`
- [Agent Hub](https://github.com/jrxid09-design/damar/blob/develop/src/services/agentHub.js): `src/services/agentHub.js`
- [Context Assembly](https://github.com/jrxid09-design/damar/blob/develop/src/ai/context/Pipeline.js): `src/ai/context/Pipeline.js`
- [AI Runtime](https://github.com/jrxid09-design/damar/blob/develop/src/services/aiRuntimeService.js): `src/services/aiRuntimeService.js`

### AI and Autonomy

- [Model Providers](https://github.com/jrxid09-design/damar/blob/develop/src/ai/providers/AIProviderFactory.js): `src/ai/providers/AIProviderFactory.js`
- [Tool Selection](https://github.com/jrxid09-design/damar/blob/develop/src/ai/tools/Pipeline.js): `src/ai/tools/Pipeline.js`
- [Tool Authorization](https://github.com/jrxid09-design/damar/blob/develop/src/ai/tools/Authorization.js): `src/ai/tools/Authorization.js`
- [Autonomous Goals](https://github.com/jrxid09-design/damar/blob/develop/src/autonomy/GoalEngine.js): `src/autonomy/GoalEngine.js`

### Persistent State

- [Long-Term Memory](https://github.com/jrxid09-design/damar/blob/develop/src/memory/services/MemoryService.js): `src/memory/services/MemoryService.js`
- [Memory Database](https://github.com/jrxid09-design/damar/blob/develop/src/memory/db/index.js): `src/memory/db/index.js`
- [Consciousness and Mind](https://github.com/jrxid09-design/damar/blob/develop/src/consciousness/index.js): `src/consciousness/index.js`

### Assistant Capabilities

- [Messaging and Integrations](https://github.com/jrxid09-design/damar/blob/develop/src/integrations/IntegrationManager.js): `src/integrations/IntegrationManager.js`
- [Voice Runtime](https://github.com/jrxid09-design/damar/blob/develop/apps/console/renderer/lib/voice.js): `apps/console/renderer/lib/voice.js`
- [Vision Services](https://github.com/jrxid09-design/damar/blob/develop/src/controllers/visionController.js): `src/controllers/visionController.js`
- [Trading and Profit](https://github.com/jrxid09-design/damar/blob/develop/src/money/ProfitEngine.js): `src/money/ProfitEngine.js`
- [Mata Dewa](https://github.com/jrxid09-design/damar/blob/develop/src/mataDewa/service.js): `src/mataDewa/service.js`

### Other components

- **User**
- **External AI Provider**

## Connections

- User → Desktop Console: uses (evidence: `README.md`)
- User → CLI: uses (evidence: `README.md`)
- User → Daemon API: uses (evidence: `README.md`)
- Desktop Console → Daemon API: requests
- CLI → Daemon API: requests
- Daemon API → Channel Manager: routes requests
- Channel Manager → Agent Hub: dispatches
- Agent Hub → Context Assembly: assembles context (evidence: `src/services/agentHub.js`)
- Agent Hub → AI Runtime: requests completion (evidence: `src/services/agentHub.js`)
- Context Assembly → Long-Term Memory: recalls context (evidence: `src/ai/context/Pipeline.js`)
- Context Assembly → Consciousness and Mind: adds mind state (evidence: `src/ai/context/Pipeline.js`)
- AI Runtime → Model Providers: runs inference (evidence: `src/services/aiRuntimeService.js`)
- Model Providers → External AI Provider: calls provider (evidence: `README.md`)
- AI Runtime → Tool Selection: selects tools (evidence: `src/services/aiRuntimeService.js`)
- Tool Selection → Tool Authorization: checks eligibility (evidence: `src/ai/tools/Pipeline.js`)
- Autonomous Goals → Tool Selection: authorizes tools (evidence: `src/autonomy/GoalEngine.js`)
- Long-Term Memory → Memory Database: reads and writes (evidence: `src/memory/services/MemoryService.js`)
- Messaging and Integrations → Agent Hub: provides agent connectors (evidence: `src/services/agentHub.js`)
- User → Voice Runtime: speaks to (evidence: `README.md`)
- Voice Runtime → AI Runtime: uses shared core (evidence: `README.md`)
- Vision Services → AI Runtime: feeds chat (evidence: `README.md`)
- User → Trading and Profit: requests trading skills (evidence: `README.md`)
- User → Mata Dewa: uses Console map (evidence: `README.md`)
