KeepMind is an Electron app split into three processes plus spawned helpers.
React 18 + TypeScript SPA, bundled by Vite via electron-vite.
components/BrainCore.tsx— procedural neural canvas (~420 neurons in two hemispheres, static edges + traveling pulses). Pure Canvas2D, sprite-based glow for performance.components/Wizard.tsx— 4-step onboarding (GitHub OAuth → AI → connectors).components/Chat.tsx— agent rail + streaming chat (typing effect driven bybrain:deltaIPC events).components/Dashboard.tsx— neural stage + insights/summaries/memory.components/Connectors.tsx/Settings.tsx/Agents.tsx.browserShim.ts— demo stub when the renderer runs in a plain browser (nowindow.sb), so the UI is previewable atlocalhost:5173.
All renderer↔main calls go through window.sb (contextBridge in
src/preload/index.ts). No nodeIntegration.
store.ts— JSON config inuserData/second-brain/config.json(providers, GitHub tokens, MCP server list, agent personas).services/llm.ts— multi-provider chat: Anthropic, OpenAI-compatible (OpenAI, Ollama, llama-server), Gemini. Tool-calling loop lives inbrain.ts.services/local-llm.ts— downloads the pinnedllama.cpprelease binary and GGUF models from HuggingFace intouserData/local-llm/, spawnsllama-serveron127.0.0.1:8765with an OpenAI-compatible/v1API.services/github.ts— OAuth device flow + repo creation + file push via the Contents API (memory/**prefix).services/mcp.ts— minimal MCP client (JSON-RPC 2.0 over stdio, newline- delimited) +McpManagerthat resolves bundled vs npx/custom servers.services/brain.ts—Memory(markdown store, mirrored to GitHub) andBrain(system-context builder, tool definitions incl. routed MCP tools, agentic loop, insights, daily summary).mcp/whatsapp-server.ts— standalone MCP stdio server using Baileys; emits QR as a data-URL file polled by the renderer; buffers incoming messages forwhatsapp_messages.
- Local memory:
userData/second-brain/memory/{inbox,insights,summaries,agents}/ - Config:
userData/second-brain/config.json - WhatsApp session:
userData/mcp-sessions/whatsapp/(Baileys auth state) - Local LLM:
userData/local-llm/{bin,models}/
Everything memory-related is mirrored to the user's private GitHub repo under
memory/ so it survives reinstalls and is usable by external AIs.
- Renderer →
brain:chat(agentId, message)IPC. Brain.chatbuilds system context (persona + connected sources + memory digest + recent insights) and tool definitions (save/get memory + all running MCP tools, namespacedmcp_<server>_<tool>).- Agentic loop (max 6 rounds): LLM → tool calls → execute (memory FS or
McpManager.callTool) → append results → repeat. - Final answer type-written to renderer via
brain:deltaevents. - Exchange appended to
memory/inbox/YYYY-MM-DD.md; optional GitHub push.
contextIsolation: true,nodeIntegration: false, CSP on the renderer.- GitHub OAuth uses the device flow — tokens stay in
userData, never in the repo. - WhatsApp Baileys session is local-only; messages are buffered in memory.
- Postgres MCP server is read-only upstream.
- The bundled prompt for external AIs explicitly forbids saving secrets.