# songf0140/auto-memories-doll architecture

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

- Interactive diagram: https://gitdiagram.com/songf0140/auto-memories-doll
- Repository: https://github.com/songf0140/auto-memories-doll

## Overview

Auto-Memories-Doll is a local-first memory companion: it captures conversations, turns them into topic-organized Markdown knowledge, then retrieves relevant memories for later AI chats. The main loop runs from chat or external ingestion through retrieval/response or candidate creation, audit, and durable storage; derived indexes support recall. The README documents the larger audit and nightly-governance capabilities. Some of those implementations were not sampled, so those links are documented at subsystem level rather than asserting unverified internal calls.

Main entry points: [`src/features/chat/handler.ts`](https://github.com/songf0140/auto-memories-doll/blob/main/src/features/chat/handler.ts) (Chat handler), [`src/server/services/orchestrator.ts`](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/orchestrator.ts) (Write orchestrator), [`src/features/audit`](https://github.com/songf0140/auto-memories-doll/tree/main/src/features/audit) (Audit pipeline), [`src/app/(main)`](https://github.com/songf0140/auto-memories-doll/tree/main/src/app/(main)) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_web["Web interface"]
  node_chatui["Chat UI"]
  node_memoryui["Memory library"]
  node_auditui["Audit panel"]
end

subgraph group_conversation["Chat and capture"]
  node_chatapi["Chat API"]
  node_chatflow["Chat handler<br/>[handler.ts]"]
  node_ai["AI providers"]
  node_listen["Conversation intake<br/>[route.ts]"]
  node_capture["Ingest processing"]
end

subgraph group_knowledge["Memory and retrieval"]
  node_memory["Memory service<br/>[memory-service.ts]"]
  node_retrieval["Search and ranking"]
  node_graph["Knowledge graph"]
end

subgraph group_governance["Audit and governance"]
  node_audit["Audit pipeline"]
  node_orchestrator["Write orchestrator<br/>[orchestrator.ts]"]
  node_nightly["Nightly governance"]
end

subgraph group_platform["Storage and integrations"]
  node_markdown["Markdown knowledge"]
  node_sqlite[("SQLite state<br/>[database.ts]")]
  node_watcher["File watcher<br/>[file-watcher.ts]"]
  node_settings["Configuration<br/>[config-service.ts]"]
  node_mcp["MCP tools<br/>[manager.ts]"]
end

node_person(("User"))

node_person -->|"uses"| node_web
node_web -->|"renders"| node_chatui
node_chatui -->|"sends chat"| node_chatapi
node_chatapi -->|"dispatches"| node_chatflow
node_chatflow -->|"searches memories"| node_retrieval
node_chatflow -->|"requests response"| node_ai
node_ai -->|"streams response"| node_chatflow
node_person -->|"pushes conversations"| node_listen
node_listen -->|"processes input"| node_capture
node_capture -->|"stages candidates"| node_orchestrator
node_chatflow -->|"queues candidates"| node_orchestrator
node_orchestrator -->|"checks candidates"| node_audit
node_auditui -->|"reviews events"| node_audit
node_audit -->|"approves writes"| node_orchestrator
node_orchestrator -->|"writes notes"| node_markdown
node_orchestrator -->|"records queue"| node_sqlite
node_memory -->|"stores records"| node_sqlite
node_memory -->|"updates vectors"| node_retrieval
node_retrieval -->|"expands related"| node_graph
node_markdown -->|"triggers import"| node_watcher
node_watcher -->|"imports changes"| node_memory
node_nightly -->|"reports findings"| node_audit
node_nightly -->|"compiles summaries"| node_markdown
node_settings -->|"persists settings"| node_sqlite
node_chatflow -->|"invokes tools"| node_mcp
node_web -->|"browses memories"| node_memoryui

click node_web "https://github.com/songf0140/auto-memories-doll/tree/main/src/app/(main)"
click node_chatui "https://github.com/songf0140/auto-memories-doll/tree/main/src/components/chat"
click node_memoryui "https://github.com/songf0140/auto-memories-doll/tree/main/src/components/memory"
click node_auditui "https://github.com/songf0140/auto-memories-doll/tree/main/src/components/audit"
click node_chatapi "https://github.com/songf0140/auto-memories-doll/tree/main/src/app/api/chat"
click node_chatflow "https://github.com/songf0140/auto-memories-doll/blob/main/src/features/chat/handler.ts"
click node_ai "https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/ai"
click node_listen "https://github.com/songf0140/auto-memories-doll/blob/main/src/app/api/listen/route.ts"
click node_capture "https://github.com/songf0140/auto-memories-doll/tree/main/src/features/ingest"
click node_memory "https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/memory-service.ts"
click node_retrieval "https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/vector"
click node_graph "https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/graph"
click node_audit "https://github.com/songf0140/auto-memories-doll/tree/main/src/features/audit"
click node_orchestrator "https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/orchestrator.ts"
click node_nightly "https://github.com/songf0140/auto-memories-doll/blob/main/src/server/orchestrators/nightly-orchestrator.ts"
click node_markdown "https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/storage"
click node_sqlite "https://github.com/songf0140/auto-memories-doll/blob/main/src/lib/storage/database.ts"
click node_watcher "https://github.com/songf0140/auto-memories-doll/blob/main/src/server/watchers/file-watcher.ts"
click node_settings "https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/config-service.ts"
click node_mcp "https://github.com/songf0140/auto-memories-doll/blob/main/src/lib/mcp/manager.ts"

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_web,node_chatui,node_memoryui,node_auditui,node_person toneBlue
class node_chatapi,node_chatflow,node_ai,node_listen,node_capture toneAmber
class node_memory,node_retrieval,node_graph toneMint
class node_audit,node_orchestrator,node_nightly toneRose
class node_markdown,node_sqlite,node_watcher,node_settings,node_mcp toneIndigo
```

## Components

### User experience

- [Web interface](https://github.com/songf0140/auto-memories-doll/tree/main/src/app/(main)): `src/app/(main)`
- [Chat UI](https://github.com/songf0140/auto-memories-doll/tree/main/src/components/chat): `src/components/chat`
- [Memory library](https://github.com/songf0140/auto-memories-doll/tree/main/src/components/memory): `src/components/memory`
- [Audit panel](https://github.com/songf0140/auto-memories-doll/tree/main/src/components/audit): `src/components/audit`

### Chat and capture

- [Chat API](https://github.com/songf0140/auto-memories-doll/tree/main/src/app/api/chat): `src/app/api/chat`
- [Chat handler](https://github.com/songf0140/auto-memories-doll/blob/main/src/features/chat/handler.ts): `src/features/chat/handler.ts`
- [AI providers](https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/ai): `src/lib/ai`
- [Conversation intake](https://github.com/songf0140/auto-memories-doll/blob/main/src/app/api/listen/route.ts): `src/app/api/listen/route.ts`
- [Ingest processing](https://github.com/songf0140/auto-memories-doll/tree/main/src/features/ingest): `src/features/ingest`

### Memory and retrieval

- [Memory service](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/memory-service.ts): `src/server/services/memory-service.ts`
- [Search and ranking](https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/vector): `src/lib/vector`
- [Knowledge graph](https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/graph): `src/lib/graph`

### Audit and governance

- [Audit pipeline](https://github.com/songf0140/auto-memories-doll/tree/main/src/features/audit): `src/features/audit`
- [Write orchestrator](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/orchestrator.ts): `src/server/services/orchestrator.ts`
- [Nightly governance](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/orchestrators/nightly-orchestrator.ts): `src/server/orchestrators/nightly-orchestrator.ts`

### Storage and integrations

- [Markdown knowledge](https://github.com/songf0140/auto-memories-doll/tree/main/src/lib/storage): `src/lib/storage`
- [SQLite state](https://github.com/songf0140/auto-memories-doll/blob/main/src/lib/storage/database.ts): `src/lib/storage/database.ts`
- [File watcher](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/watchers/file-watcher.ts): `src/server/watchers/file-watcher.ts`
- [Configuration](https://github.com/songf0140/auto-memories-doll/blob/main/src/server/services/config-service.ts): `src/server/services/config-service.ts`
- [MCP tools](https://github.com/songf0140/auto-memories-doll/blob/main/src/lib/mcp/manager.ts): `src/lib/mcp/manager.ts`

### Other components

- **User**

## Connections

- User → Web interface: uses
- Web interface → Chat UI: renders
- Chat UI → Chat API: sends chat (evidence: `src/components/chat/useChatSession.ts`)
- Chat API → Chat handler: dispatches (evidence: `src/app/api/chat/route.ts`)
- Chat handler → Search and ranking: searches memories (evidence: `src/features/chat/handler.ts`)
- Chat handler → AI providers: requests response (evidence: `src/features/chat/handler.ts`)
- AI providers → Chat handler: streams response (evidence: `src/features/chat/handler.ts`)
- User → Conversation intake: pushes conversations
- Conversation intake → Ingest processing: processes input (evidence: `src/app/api/listen/route.ts`)
- Ingest processing → Write orchestrator: stages candidates
- Chat handler → Write orchestrator: queues candidates
- Write orchestrator → Audit pipeline: checks candidates
- Audit panel → Audit pipeline: reviews events
- Audit pipeline → Write orchestrator: approves writes
- Write orchestrator → Markdown knowledge: writes notes
- Write orchestrator → SQLite state: records queue
- Memory service → SQLite state: stores records (evidence: `src/server/services/memory-service.ts`)
- Memory service → Search and ranking: updates vectors (evidence: `src/server/services/memory-service.ts`)
- Search and ranking → Knowledge graph: expands related
- Markdown knowledge → File watcher: triggers import (evidence: `src/server/watchers/file-watcher.ts`)
- File watcher → Memory service: imports changes (evidence: `src/server/watchers/file-watcher.ts`)
- Nightly governance → Audit pipeline: reports findings
- Nightly governance → Markdown knowledge: compiles summaries
- Configuration → SQLite state: persists settings (evidence: `src/server/services/config-service.ts`)
- Chat handler → MCP tools: invokes tools (evidence: `src/features/chat/handler.ts`)
- Web interface → Memory library: browses memories
