How baekenough/second-brain works
second-brain is a private, LLM-curated search and knowledge system. Its main workflow collects material from connected sources or mobile uploads, extracts and chunks content, stores it for hybrid retrieval, then serves curated answers through HTTP or MCP. Background workers add summaries, entities, and other derived knowledge; evaluation and tuning support search quality over time. The graph emphasizes those product stages and major documented capabilities. Some subsystem connections rely on README descriptions because their implementation was not sampled; those edges cite the README rather than implying source-level inspection.
Main entry points: postgres.go Postgres Knowledge Store · search.go Hybrid Search · ingest_file.go Upload Handlers · main.go HTTP API Server
Components 20
Collection and Ingest
- Collector Daemon
cmd/collector/main.go - Source Collectors
internal/collector - Upload Handlers
internal/api/ingest_file.go - Format Extractors
internal/collector/extractor
Knowledge Processing
- Rune Chunker
internal/chunker/chunker.go - Postgres Knowledge Store
internal/store/postgres.go - Enrichment Workers
internal/worker/note_enrichment_worker.go - Classification Worker
internal/worker/classification_worker.go - Entity Extraction Worker
internal/worker/extraction_worker.go - Action Queries
internal/store/actions_query.go
Search and Access
- Hybrid Search
internal/search/search.go - LLM Client
internal/llm/client.go - HTTP API Server
cmd/server/main.go - MCP Server
cmd/mcp/main.go
User Interfaces
- Android Capture
mobile/second-brain-push/app/src/main/java/com/baekenough/secondbrain/sync/SyncWorker.kt - Web Application
web/src/app/ask/page.tsx
Quality and Operations
- Nightly Evaluation
cmd/eval/main.go - Ask Evaluation
internal/askeval/llm.go
Other components
- AI Agent
- Connected Sources
Connections 26
- Connected Sources → Collector Daemon: supplies content
README.md - Android Capture → Upload Handlers: uploads recordings
README.md - Collector Daemon → Source Collectors: runs collection
cmd/collector/main.go - Collector Daemon → Enrichment Workers: starts workers
cmd/collector/main.go - Source Collectors → Postgres Knowledge Store: stores documents
README.md - Upload Handlers → Format Extractors: extracts files
internal/api/ingest_file.go - Upload Handlers → Rune Chunker: chunks uploads
internal/api/ingest_file.go - Upload Handlers → Postgres Knowledge Store: upserts documents
internal/api/ingest_file.go - Format Extractors → Rune Chunker: provides text
README.md - Rune Chunker → Postgres Knowledge Store: stores chunks
README.md - Enrichment Workers → Postgres Knowledge Store: persists enrichment
internal/worker/note_enrichment_worker.go - Enrichment Workers → LLM Client: requests enrichment
internal/worker/note_enrichment_worker.go - Classification Worker → Postgres Knowledge Store: updates classification
- Entity Extraction Worker → LLM Client: extracts entities
internal/worker/extraction_worker.go - Entity Extraction Worker → Postgres Knowledge Store: persists entities
- HTTP API Server → Hybrid Search: serves search
README.md - MCP Server → Hybrid Search: offers search tools
README.md - Hybrid Search → Postgres Knowledge Store: retrieves knowledge
README.md - Hybrid Search → LLM Client: curates results
README.md - AI Agent → HTTP API Server: uses REST
README.md - AI Agent → MCP Server: uses MCP
README.md - Web Application → HTTP API Server: calls endpoints
- HTTP API Server → Action Queries: queries actions
- Nightly Evaluation → Hybrid Search: evaluates retrieval
cmd/eval/main.go - Nightly Evaluation → Postgres Knowledge Store: records metrics
cmd/eval/main.go - Ask Evaluation → LLM Client: runs ask evaluation
internal/askeval/llm.go