Skip to content

imashu-del/Devbrain

Repository files navigation

🧠 DevBrain: The Persistent Memory Layer for Software Development

Built for the Cognee 2026 Hackathon β€” Targeting the "Best Use of Open Source" Track


⚑ What is DevBrain?

DevBrain is a sovereign, persistent memory layer for developers.

Today's AI coding assistants have a "Vegas Hangover" problem: What happens in the chat tab, stays in the chat tab. Every time you open a new chat window or restart your IDE, the AI forgets all of your architectural decisions, structural dependencies, and coding patterns.

DevBrain solves this by decoupling your project's memory from the AI compute layer. It uses a background harvester and manual capture tools to build a local Knowledge Graph of your entire codebase using the Cognee framework. Any AI assistant (like Cursor, Claude, or Antigravity) can plug into DevBrain to instantly recall the exact architectural context of your project before it writes a single line of code.


πŸŽ›οΈ The Hybrid Architecture Paradigm Shift

DevBrain has evolved into a premium developer engine that gives engineers complete control over both their storage topology and their model intelligence layer.

graph TD
    A[devbrain.py CLI] --> B(harvester.py Watcher)
    A --> C(dashboard/ Next.js UI)
    B -- Git Diffs --> D[devbrain_core.py Memory Engine]
    C -- API Calls --> D
    E[MCP IDE Plugin Cursor/Claude] -- Tool Calls --> D
    
    D -- cognee.remember --> F[(Local Kuzu Graph DB)]
    D -- cognee.recall --> F
    
    F -- Context --> G{LLM Reasoning Layer}
    G -- Offline --> H[Ollama: smollm3]
    G -- High-Velocity --> I[Groq: qwen3.6-27b]
Loading

1. Storage Topology Router (DEVBRAIN_MODE)

  • local (Default): Guarantees privacy-first isolation for secure internal repos. Operates 100% locally on embedded SQLite, LanceDB, and Kuzu Graph databases.

2. Cognitive Processor Layer (DEVBRAIN_LLM_PROVIDER)

Developers can explicitly choose their intelligence tier while keeping Cognee storage local:

  • openai-compatible: High-velocity cloud-hybrid tier. Routes reasoning to Groq's OpenAI-compatible API, while keeping graph storage local.
  • ollama: Sovereign local tier. Runs 100% offline through Ollama with alibayram/smollm3 for absolute privacy.

🧠 How We Used Cognee (The Core Memory Lifecycle)

DevBrain's entire intelligence is powered by Cognee, which acts as the orchestration layer for building the local knowledge graph. We utilized Cognee's exact four primitives to manage the memory lifecycle:

1. cognee.remember()

  • Role: Ingestion Engine.
  • How DevBrain Uses It: When the background Harvester detects a git diff, or when a developer explicitly captures an architectural note via the CLI (devbrain note), DevBrain passes the raw text to cognee.remember(). Cognee automatically extracts the semantic meaning and injects the nodes into the vector space and Kuzu graph.

2. cognee.recall()

  • Role: Retrieval Engine.
  • How DevBrain Uses It: When a user queries the DevBrain Assistant in the Dashboard, or when an AI agent requests context via MCP, DevBrain calls cognee.recall(query_text). Cognee traverses the Kuzu graph to retrieve relevant structural decisions, which DevBrain formats into a Markdown manifest to guide the LLM's response.

3. cognee.improve()

  • Role: Graph Defragmenter.
  • How DevBrain Uses It: Over time, memory can become tangled. DevBrain exposes an optimize CLI command and API route that triggers cognee.improve(). This prunes stale nodes, re-evaluates schema connections, and re-balances graph weights to maintain a clean repository ontology.

4. cognee.forget()

  • Role: Surgical Purge.
  • How DevBrain Uses It: If a developer creates a prototype branch and wants to wipe the slate clean, DevBrain's "Wipe Matrix" UI button triggers cognee.forget(dataset_name). This safely clears out all experimental nodes from the LanceDB vector store and Kuzu graph without corrupting the local project setup.

πŸ”Œ Supported Integrations

DevBrain exposes your memory graph universally, supporting developers no matter what tools they use:

  1. MCP (Model Context Protocol) Server: Run devbrain mcp to connect DevBrain directly to Cursor, Claude Code, or Antigravity IDE. The AI tools can actively search the graph and write their own decisions into memory.
  2. The Context Compiler: Run devbrain export to compile the entire graph into a Markdown manifest. DevBrain automatically copies it to your clipboard so you can paste it into ChatGPT or Claude web.

πŸš€ Quick Start (Local Setup)

1. Install DevBrain Globally

Ensure you have Python 3.10+ and Node.js installed. Instead of just installing requirements, you can install DevBrain as a global CLI tool so it's accessible from any directory:

pip install -e .

This automatically installs all dependencies and registers the devbrain command globally on your system.

2. Configure Environment Variables

Create a .env file in the project root. For absolute privacy, use the Ollama offline tier:

DEVBRAIN_MODE="local"
DEVBRAIN_LLM_PROVIDER="ollama"
DEVBRAIN_MODEL_NAME="alibayram/smollm3"
DEVBRAIN_BASE_URL="http://localhost:11434"

3. Initialize Cognee DB

Verify the database migrations and schema run successfully:

devbrain init

4. Launch the Developer Cockpit

Open the interactive Next.js visual dashboard:

devbrain dashboard

Next.js will automatically launch on http://localhost:3000.


πŸ› οΈ Production Safeguards & Monkey Patching

During development, we encountered limitations with small context windows in offline LLMs (e.g., smollm3). We proactively patched the devbrain_core.py to intercept InstructorRetryException loops, implementing a regex-salvage mechanism that extracts valid JSON payloads directly from error logs to prevent 8-minute hallucination loops on low-spec hardware.


πŸ€– Hackathon AI Usage Declaration

In compliance with the Cognee Hackathon rules, I am formally declaring the use of AI assistants in the creation of DevBrain:

  • Gemini: Used for high-level project strategy, architectural brainstorming, and refining the core value proposition of decoupling memory from compute.
  • Antigravity IDE: Used as the primary AI pair-programmer for hands-on development, debugging edge cases, patching backend routing logic, and generating UI layout structures.

Both tools were utilized to accelerate development while the core logic and integration with the Cognee framework were meticulously designed and verified by the developer.

About

🧠 DevBrain β€” The persistent memory layer for software development, powered by Cognee and Open source models

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors