$ show garrytan/gbrain
GBrain is a personal knowledge management system designed as an AI agent memory layer. It provides a persistent knowledge base that runs as a 24/7 daemon for continuous ingestion, enrichment, and consolidation of information from various sources. The system features a CLI-first architecture with MCP (Model Context Protocol) support for AI agent integration, a web admin interface, and extensibility through skill packs. It uses a hybrid storage approach with PGLite for local/single-user deployments and Postgres+pgvector for shared/scale deployments, incorporating vector search, full-text search, and a self-wiring knowledge graph with typed edges. The system includes evaluation frameworks (BrainBench, takes-quality assessment), an advisor system for health recommendations, and automated maintenance cycles.
The LLM identified 5 files worth highlighting for reuse:
A versioned schema pack system that enables extensible skill definitions with manifest validation, agent-authored schema mutations, and runtime-resolvable active packs with fallback tiers. Demonstrates non-obvious skill in handling schema evolution while maintaining backward compatibility through primitive-based defaults and migration pathways.
A Postgres-native job queue system with lease pressure auditing, budget tracking, and worker isolation. Shows sophisticated distributed systems concepts including staggered job scheduling (deterministic minute offsets), exponential/fixed backoff strategies with jitter, and process isolation options for job handlers. The component is self-contained and could be extracted for use in other projects requiring reliable background job processing.
An audit writer pattern that implements ISO-week rotated JSONL logging with best-effort write semantics. The component demonstrates clean engineering through its simplicity, reliability (non-blocking writes), and reusability across different audit types (connection, pool recovery, self-upgrade). It could be easily extracted and applied to other projects needing structured audit trails.
The BrainEngine interface abstraction with separate PGLite and Postgres implementations. Demonstrates excellent separation of concerns by defining a clean interface for data operations while allowing different storage backends to implement it. The pattern shows non-obvious skill in handling the nuances between embedded (PGLite) and server (Postgres) databases while maintaining a consistent API for upper layers.
A unified AI provider gateway that abstracts multiple AI providers (Anthropic, OpenAI, local LLMs, etc.) through a recipe pattern. Shows sophisticated design in handling provider-specific configurations while maintaining a consistent interface for text generation, embedding, and reranking operations. The component includes built-in retry logic, budget tracking, and fail-open behavior for resilience.