# caiqueescaler86/secondbrain architecture

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

- Interactive diagram: https://gitdiagram.com/caiqueescaler86/secondbrain
- Repository: https://github.com/caiqueescaler86/secondbrain

## Overview

SecondBrain is a local productivity assistant that connects PowerShell workflows to authenticated Copilot and Joule desktops, captures WhatsApp history for local LLM analysis, and presents tasks in a cockpit. Its voice listener turns microphone input into structured tasks. The main flows are documented in the README and sampled source; the backend serving the cockpit APIs is not present in the tree, so it is shown as an external service. Meeting-related scripts are visible in the tree, but their behavior and connections are not established by the available evidence.

Main entry points: [`voice/voice_listen.py`](https://github.com/caiqueescaler86/secondbrain/blob/master/voice/voice_listen.py) (Voice listener), [`whatsapp-collector.ps1`](https://github.com/caiqueescaler86/secondbrain/blob/master/whatsapp-collector.ps1) (Chat collector), [`cockpit/app.js`](https://github.com/caiqueescaler86/secondbrain/blob/master/cockpit/app.js) (Cockpit dashboard), [`analyze-whatsapp.ps1`](https://github.com/caiqueescaler86/secondbrain/blob/master/analyze-whatsapp.ps1) (Conversation analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_adapters["Desktop adapters"]
  node_copilot_adapter["Copilot adapter"]
  node_joule_adapter["Joule adapter<br/>[joule-terminal.ps1]"]
  node_copilot_cdp["Copilot CDP"]
  node_joule_cdp["Joule CDP"]
  node_copilot_desktop["Copilot desktop"]
  node_joule_desktop["Joule desktop"]
end

subgraph group_whatsapp["WhatsApp workflow"]
  node_whatsapp_collector["Chat collector"]
  node_firefox_whatsapp["Firefox / WhatsApp Web"]
  node_whatsapp_store[("Message and sync files")]
  node_whatsapp_analysis["Conversation analysis"]
end

subgraph group_tasks["Task cockpit"]
  node_cockpit_ui["Cockpit dashboard<br/>[app.js]"]
  node_task_api["Task API"]
end

subgraph group_voice["Voice capture"]
  node_voice_listener["Voice listener<br/>[voice_listen.py]"]
  node_whisper["Local Whisper"]
  node_wakeword["Wake-word detection"]
end

node_user(("User"))
node_llama["Local llama.cpp"]
node_microphone(("Microphone"))

node_user -->|"asks"| node_copilot_adapter
node_copilot_adapter -->|"controls via"| node_copilot_cdp
node_copilot_cdp -->|"drives renderer"| node_copilot_desktop
node_user -->|"asks"| node_joule_adapter
node_joule_adapter -->|"uses"| node_joule_cdp
node_joule_cdp -.->|"connects to"| node_joule_desktop
node_user -->|"starts sync"| node_whatsapp_collector
node_whatsapp_collector -->|"collects chats"| node_firefox_whatsapp
node_whatsapp_collector -->|"writes messages and state"| node_whatsapp_store
node_whatsapp_analysis -->|"reads messages"| node_whatsapp_store
node_whatsapp_analysis -->|"requests analysis"| node_llama
node_user -->|"asks analysis"| node_whatsapp_analysis
node_user -->|"uses"| node_cockpit_ui
node_cockpit_ui -->|"loads and updates tasks"| node_task_api
node_cockpit_ui -->|"requests local answers"| node_llama
node_user -->|"triggers capture"| node_voice_listener
node_microphone -->|"provides audio"| node_voice_listener
node_voice_listener -->|"transcribes audio"| node_whisper
node_voice_listener -->|"extracts task fields"| node_llama
node_voice_listener -->|"creates task"| node_task_api
node_voice_listener -->|"loads model"| node_wakeword

click node_copilot_adapter "https://github.com/caiqueescaler86/secondbrain/blob/master/copilot-terminal.ps1"
click node_joule_adapter "https://github.com/caiqueescaler86/secondbrain/blob/master/joule-terminal.ps1"
click node_whatsapp_collector "https://github.com/caiqueescaler86/secondbrain/blob/master/whatsapp-collector.ps1"
click node_whatsapp_analysis "https://github.com/caiqueescaler86/secondbrain/blob/master/analyze-whatsapp.ps1"
click node_cockpit_ui "https://github.com/caiqueescaler86/secondbrain/blob/master/cockpit/app.js"
click node_voice_listener "https://github.com/caiqueescaler86/secondbrain/blob/master/voice/voice_listen.py"
click node_wakeword "https://github.com/caiqueescaler86/secondbrain/blob/master/voice/models/hey_secondbrain.onnx"

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_copilot_adapter,node_joule_adapter,node_copilot_cdp,node_joule_cdp,node_copilot_desktop,node_joule_desktop,node_user toneBlue
class node_whatsapp_collector,node_firefox_whatsapp,node_whatsapp_store,node_whatsapp_analysis toneAmber
class node_cockpit_ui,node_task_api toneMint
class node_voice_listener,node_whisper,node_wakeword toneRose
class node_llama,node_microphone toneIndigo
```

## Components

### Desktop adapters

- [Copilot adapter](https://github.com/caiqueescaler86/secondbrain/blob/master/copilot-terminal.ps1): `copilot-terminal.ps1`
- [Joule adapter](https://github.com/caiqueescaler86/secondbrain/blob/master/joule-terminal.ps1): `joule-terminal.ps1`
- **Copilot CDP**
- **Joule CDP**
- **Copilot desktop**
- **Joule desktop**

### WhatsApp workflow

- [Chat collector](https://github.com/caiqueescaler86/secondbrain/blob/master/whatsapp-collector.ps1): `whatsapp-collector.ps1`
- **Firefox / WhatsApp Web**
- **Message and sync files**
- [Conversation analysis](https://github.com/caiqueescaler86/secondbrain/blob/master/analyze-whatsapp.ps1): `analyze-whatsapp.ps1`

### Task cockpit

- [Cockpit dashboard](https://github.com/caiqueescaler86/secondbrain/blob/master/cockpit/app.js): `cockpit/app.js`
- **Task API**

### Voice capture

- [Voice listener](https://github.com/caiqueescaler86/secondbrain/blob/master/voice/voice_listen.py): `voice/voice_listen.py`
- **Local Whisper**
- [Wake-word detection](https://github.com/caiqueescaler86/secondbrain/blob/master/voice/models/hey_secondbrain.onnx): `voice/models/hey_secondbrain.onnx`

### Other components

- **User**
- **Local llama.cpp**
- **Microphone**

## Connections

- User → Copilot adapter: asks (evidence: `README.md`)
- Copilot adapter → Copilot CDP: controls via (evidence: `README.md`)
- Copilot CDP → Copilot desktop: drives renderer (evidence: `README.md`)
- User → Joule adapter: asks (evidence: `README.md`)
- Joule adapter → Joule CDP: uses (evidence: `README.md`)
- Joule CDP → Joule desktop: connects to
- User → Chat collector: starts sync (evidence: `README.md`)
- Chat collector → Firefox / WhatsApp Web: collects chats (evidence: `README.md`)
- Chat collector → Message and sync files: writes messages and state (evidence: `README.md`)
- Conversation analysis → Message and sync files: reads messages (evidence: `README.md`)
- Conversation analysis → Local llama.cpp: requests analysis (evidence: `README.md`)
- User → Conversation analysis: asks analysis (evidence: `README.md`)
- User → Cockpit dashboard: uses (evidence: `cockpit/app.js`)
- Cockpit dashboard → Task API: loads and updates tasks (evidence: `cockpit/app.js`)
- Cockpit dashboard → Local llama.cpp: requests local answers (evidence: `cockpit/app.js`)
- User → Voice listener: triggers capture (evidence: `voice/voice_listen.py`)
- Microphone → Voice listener: provides audio (evidence: `voice/voice_listen.py`)
- Voice listener → Local Whisper: transcribes audio (evidence: `voice/voice_listen.py`)
- Voice listener → Local llama.cpp: extracts task fields (evidence: `voice/voice_listen.py`)
- Voice listener → Task API: creates task (evidence: `voice/voice_listen.py`)
- Voice listener → Wake-word detection: loads model (evidence: `voice/voice_listen.py`)
