Skip to main content

Local-first AI codebase memory and graph intelligence system.

Project description

BrainGraph

Local-first codebase graph memory for AI-assisted development.

BrainGraph helps developers and AI coding tools understand a repository without reading everything blindly. It scans your project, builds a graph of files and relationships, stores compact memory, and returns focused context for tasks like auth flow tracing, routing analysis, dependency understanding, and system explanations.

What BrainGraph Does

  • Scans your repository locally
  • Detects functions, classes, imports, routes, components, and relationships
  • Builds a graph you can inspect and query
  • Writes summaries and diagnostics automatically
  • Gives AI tools smaller, better, more relevant context

Visual Overview

flowchart LR
    A[Project Folder] --> B[BrainGraph Scan]
    B --> C[Parser]
    C --> D[Graph]
    C --> E[Summaries]
    C --> F[Memory]
    D --> G[graph.json]
    D --> H[graph.html]
    E --> I[BRAIN_REPORT.md]
    F --> J[query / explain]
flowchart TD
    A[Task or AI prompt] --> B[braingraph query]
    B --> C[Relevant files]
    C --> D[Compact context]
    D --> E[Less token waste]
    D --> F[Better AI grounding]

Step-by-Step Setup Guide

1. Prerequisites

Make sure Python is available in your terminal:

python --version

BrainGraph is designed for Python 3.12+.

2. Install BrainGraph

Once BrainGraph is published, users should install it directly with pip:

python -m pip install braingraph

Optional vector backend:

python -m pip install "braingraph[vector]"

Verify installation:

braingraph --help
braingraph version

Upgrade later:

python -m pip install --upgrade braingraph

3. Platform-Specific Setup

BrainGraph works best when installed in the same environment your terminal or AI tool can access.

Windows

If python works in terminal, then:

python -m pip install braingraph

If python does not work

Try:

py -m pip install braingraph

4. Run BrainGraph on Your Codebase

If you are already inside your project folder:

braingraph .

Or explicitly initialize it:

braingraph init .

This generates:

braingraph-out/
├── graph.json
├── graph.html
├── BRAIN_REPORT.md
├── summaries/
├── memory.db
├── embeddings.db
├── cache/
└── integrations/

Run BrainGraph on another project location

braingraph "C:\Users\YourName\Desktop\MyProject"

Folder path with spaces

braingraph "C:\Users\YourName\Desktop\Client Project\Frontend App"

5. Make BrainGraph Always Available to AI

BrainGraph can generate project-local instruction files for coding assistants so they use BrainGraph first before broad repo reads.

Codex

braingraph codex install .

Claude Code

braingraph claude install .

Cursor

braingraph cursor install .

Gemini CLI

braingraph gemini install .

GitHub Copilot

braingraph copilot install .

Files BrainGraph creates for AI tools

  • .codex/braingraph.md
  • .claude/commands/brainGraph.md
  • .cursor/rules/braingraph.mdc
  • .gemini/commands/brainGraph.md
  • .github/instructions/braingraph.instructions.md

6. Ignore Unnecessary Files

BrainGraph already ignores common noise such as:

  • .git
  • node_modules
  • dist
  • build
  • cache folders
  • virtual environments
  • generated BrainGraph output

That keeps scans cleaner and retrieval more useful.

7. Query Your Graph

After scanning, ask BrainGraph for focused context.

Query relevant files

braingraph query "auth flow"

Explain a system

braingraph explain "routing system"

Show repository stats

braingraph stats

Run diagnostics

braingraph doctor

Export graph again

braingraph graph

Refresh after changes

braingraph update .

Watch a project for changes

braingraph watch . --seconds 30

8. Give Context to the Agent

This is the recommended workflow for AI tools.

Instead of:

Read the full repo and explain authentication

Use:

Run braingraph query "authentication flow" first, then use only the returned files.

Good BrainGraph-first AI workflow

  1. Run braingraph query "<task>"
  2. Read only the returned files
  3. Use braingraph explain "<system>" for compact understanding
  4. Use braingraph path "<file A>" "<file B>" for relationship tracing
  5. Re-run braingraph update . after major refactors

Example prompts for AI workflows

Run braingraph query "login flow" and explain the returned files.
Use braingraph explain "routing system" before reading controllers manually.
Run braingraph path "login.tsx" "auth.py" and explain how they are connected.

9. How to Give Project Location Explicitly

Some commands accept a project argument directly, and some use --project.

Direct project path commands

braingraph "C:\Projects\MyApp"
braingraph init "C:\Projects\MyApp"
braingraph update "C:\Projects\MyApp"
braingraph watch "C:\Projects\MyApp" --seconds 20

Use --project for query/explain/stats/doctor/graph

braingraph query "payment flow" --project "C:\Projects\MyApp"
braingraph explain "order pipeline" --project "C:\Projects\MyApp"
braingraph stats --project "C:\Projects\MyApp"
braingraph doctor --project "C:\Projects\MyApp"

10. What BrainGraph Detects

BrainGraph currently focuses on practical repo understanding:

  • Python functions and classes
  • JavaScript and TypeScript functions
  • React-style components
  • imports and dependency-like links
  • route-like patterns
  • duplicate files by content
  • circular imports
  • weak or dead files
  • syntax issues in broken files

11. Reference Commands

braingraph install
braingraph init .
braingraph .
braingraph version
braingraph query "show auth flow"
braingraph explain "routing system"
braingraph path "login.tsx" "auth.py"
braingraph stats
braingraph graph
braingraph doctor
braingraph update .
braingraph watch . --seconds 10
braingraph clear --yes

12. Typical End-to-End Flow

python -m pip install braingraph
braingraph "C:\Users\YourName\Desktop\MyProject"
braingraph query "auth flow" --project "C:\Users\YourName\Desktop\MyProject"
braingraph explain "routing system" --project "C:\Users\YourName\Desktop\MyProject"
braingraph doctor --project "C:\Users\YourName\Desktop\MyProject"

13. Why This Helps in Real AI Work

Without BrainGraph:

  • AI reads too many files
  • token usage increases
  • context gets noisy
  • architecture understanding becomes slower

With BrainGraph:

  • context is filtered
  • relevant files are surfaced faster
  • prompts stay smaller
  • AI gets better structure before reasoning

14. Notes for Contributors

This section is only for contributors, not end users.

Run tests

python -m pytest -q

Local editable install

python -m venv .venv
.venv\Scripts\activate
python -m pip install -e .
python -m pip install -e ".[dev]"

15. Credits

Built and prepared by Mohd.Kaif with team ClarusCodix.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

braingraph-0.1.1.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

braingraph-0.1.1-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file braingraph-0.1.1.tar.gz.

File metadata

  • Download URL: braingraph-0.1.1.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for braingraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cbcd124fe470fc706e8c1af7dc5fb2a0bc501d0dd3ec6af0914dc887776c9a7f
MD5 eb3ce8443f5581c9fcc339b14829e0e2
BLAKE2b-256 77fd364f9c8d045a77ad8a423794dd9f61a067205c618cf3ce91ed888c4d447f

See more details on using hashes here.

Provenance

The following attestation bundles were made for braingraph-0.1.1.tar.gz:

Publisher: python-publish.yml on Dislike12/BrainGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file braingraph-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: braingraph-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for braingraph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63b7b5fdacf39788e5f6a543ab8d9627b908c878b6c3c5f53af96741bcb038d7
MD5 b84ae77bf6e00fcaea20510401038b2d
BLAKE2b-256 08291d9da3951ebfa0b1ff00578056faff72af19744ffad9160bca96d1ac8acc

See more details on using hashes here.

Provenance

The following attestation bundles were made for braingraph-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on Dislike12/BrainGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page