How byteclub-labs/gbrain works
GBrain is an agent-oriented knowledge brain: sources become stored, chunked memory; agents retrieve it through search and graph capabilities, with synthesis and gap analysis documented as the user-facing result. It also supports context injection, autonomous enrichment/consolidation, MCP access, and an admin UI. The README documents several of these product behaviors, but their full implementation paths were not sampled; edges based on that documentation cite the README. Unverified internal links are omitted.
Main entry points: engine.ts Brain engine API · sql-ranking.ts Search ranking · ingestion Source ingestion · recursive.ts Chunking
Components 21
Access interfaces
- CLI
src/cli.ts - MCP server
src/mcp/server.ts - Admin console
admin/src/App.tsx
Memory ingestion
- Source ingestion
src/core/ingestion - Chunking
src/core/chunkers/recursive.ts - Contextual retrieval prep
src/core/contextual-retrieval-service.ts - Entity links
src/core/link-extraction.ts
Retrieval and answers
- Search ranking
src/core/search/sql-ranking.ts - Embedding search
src/core/search/embedding-column.ts - Contextual recall
src/core/context/retrieval-reflex.ts - Synthesis and gap analysis
src/core
Memory and storage
- Brain engine API
src/core/engine.ts - PGLite store
src/core/pglite-engine.ts - Postgres store
src/core/postgres-engine.ts - Knowledge graph
src/core/link-extraction.ts - Fenced memory
src/core/takes-fence.ts
Autonomous operations
- AI gateway
src/core/ai/gateway.ts - Dream cycle
src/core/cycle.ts - Context engine
src/core/context-engine.ts - Schema migrations
src/core/migrate.ts
Other components
- User or agent
Connections 26
- User or agent → CLI: runs commands
- User or agent → MCP server: calls tools
- User or agent → Admin console: manages brain
- User or agent → Source ingestion: provides sources
- Source ingestion → Chunking: chunks pages
- Source ingestion → Entity links: extracts edges
README.md - Source ingestion → Brain engine API: writes pages
- Chunking → Brain engine API: stores chunks
- Contextual retrieval prep → AI gateway: generates synopses
src/core/contextual-retrieval-service.ts - Contextual retrieval prep → Chunking: processes chunks
- User or agent → Search ranking: asks questions
README.md - Search ranking → Embedding search: uses vectors
- Search ranking → Brain engine API: queries memory
- Search ranking → Knowledge graph: traverses links
README.md - Search ranking → Synthesis and gap analysis: synthesizes evidence
README.md - Synthesis and gap analysis → User or agent: returns cited answer
README.md - MCP server → Brain engine API: dispatches operations
src/mcp/server.ts - Brain engine API → PGLite store: implemented by
src/core/pglite-engine.ts - Brain engine API → Postgres store: implemented by
src/core/postgres-engine.ts - Postgres store → Schema migrations: runs migrations
src/core/postgres-engine.ts - PGLite store → Schema migrations: uses migrations
src/core/pglite-engine.ts - Dream cycle → Brain engine API: consolidates memory
- Dream cycle → AI gateway: uses models
- Context engine → Contextual recall: builds recall
src/core/context-engine.ts - Contextual recall → Brain engine API: resolves entities
src/core/context/reflex.ts - Brain engine API → Fenced memory: indexes memory