Skip to content

spencrmartin/brian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

85 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Brian - Your Personal Knowledge Base

A play on "brain" - Brian is your intelligent knowledge repository with vector-based similarity search, beautiful graph visualization, and seamless Goose integration. Because I cannot spell 9/10 times and I make this mistake all the time now you can too!

Screenshot 2026-01-20 at 3 10 36 PM

✨ Features

Core Knowledge Management

  • πŸ“š Knowledge Items: Store links, notes, code snippets, and papers
  • πŸ” Smart Search: Full-text search with FTS5 + TF-IDF vector similarity
  • 🏷️ Tagging System: Organize items with tags for easy filtering
  • πŸ”— Link Previews: Automatic metadata extraction from URLs
  • πŸ“„ Google Docs Support: Seamless integration with Google Drive documents

Multi-Project Knowledge Bases

  • πŸ—‚οΈ Multiple Projects: Organize knowledge into separate project spaces
  • 🎨 Custom Project Icons: Choose from 25+ Lucide icons for each project
  • 🌈 Project Colors: Color-code your knowledge bases
  • 🌐 All Projects View: See everything across all knowledge bases at once

Graph Visualization

  • πŸ•ΈοΈ Force-Directed Graph: Interactive D3.js visualization showing connections
  • 🎨 Theme Highlighting: Hover over tags to see themed connections with colored drop shadows
  • πŸ” Semantic Zoom: Smooth transitions between project, region, and item views
  • 🌌 Knowledge Universe: Zoom out to see all projects as "galaxies" in a unified space
  • πŸ“ Knowledge Regions: Group related items with visual boundaries

Hierarchical Zoom (Knowledge Universe)

  • πŸ”­ Multi-Scale View: Seamlessly zoom from individual items to entire knowledge universe
  • πŸͺ Project Hulls: Visual boundaries around project clusters when zoomed out
  • ✨ Semantic Rendering: Labels, nodes, and links adapt based on zoom level
  • πŸ“Š Zoom Indicator: Real-time display of zoom level and current semantic view

AI Integration

  • πŸ€– Goose Integration: Use Brian directly from Goose AI assistant via MCP
  • 🧭 Region Profiles: Configure AI behavior per knowledge region
  • πŸ’‘ Smart Context: Get relevant knowledge context for any topic

πŸš€ Quick Start

Prerequisites

One-Command Installation

# Clone the repository
git clone https://github.com/yourusername/brian.git
cd brian

# Run the setup script
./setup.sh

That's it! The setup script will:

  • βœ… Install all Python dependencies
  • βœ… Install all frontend dependencies
  • βœ… Create the Brian data directory
  • βœ… Configure the Goose extension automatically
  • βœ… Create convenient start/stop scripts

Start Brian

./start.sh

This starts both the backend (port 8080) and frontend (port 5173) servers.

Open your browser to: http://localhost:5173

Stop Brian

./stop.sh

πŸ“– Usage

Adding Knowledge Items

Via Web UI:

  1. Open http://localhost:5173
  2. Click the "+" button
  3. Choose item type (link, note, snippet, paper)
  4. Fill in the details and add tags
  5. Save!

Via Goose:

You: Add this link to Brian: https://example.com with tags "ai, research"
Goose: βœ“ Added to your knowledge base!

Managing Projects

Creating a Project:

  1. Click the Project Selector at the top center
  2. Click "New Project"
  3. Enter name, description, choose an icon and color
  4. Click Create

Switching Projects:

  • Click the Project Selector and choose a project
  • Select "All Projects" to view everything across all knowledge bases

Editing Projects:

  • Hover over a project in the selector and click the edit (pencil) icon
  • Change the name, description, icon, or color

Graph Visualization

The graph view shows connections between items based on content similarity:

  • Node Colors: Blue (links), Green (notes), Amber (snippets), Purple (papers)
  • Line Thickness: Indicates similarity strength
  • Theme Highlighting: Hover over tags to see themed connections
  • Node Details: Click any node to see full details in a bottom sheet
  • Zoom & Pan: Scroll to zoom, drag to pan
  • Drag Nodes: Reposition nodes by dragging

Knowledge Universe (Hierarchical Zoom)

When viewing "All Projects", you can explore your entire knowledge universe:

  1. Zoom Out (scale < 0.3): See all projects as distinct clusters with hull boundaries
  2. Mid Zoom (scale 0.3-0.5): See knowledge regions within projects
  3. Zoom In (scale > 0.5): See individual items with full labels

The zoom indicator in the bottom-left shows your current zoom level and semantic view.

Knowledge Regions

Regions help organize related items within a project:

  1. Click the Regions button in the toolbar
  2. Create a new region with a name and color
  3. Add items to regions by selecting them in the graph
  4. Regions appear as visual boundaries in the graph view

Searching

Via Web UI:

  • Use the search bar at the top
  • Results show both exact matches and similar items
  • Filter by type, tags, or project

Via Goose:

You: Search Brian for "machine learning"
Goose: Found 5 items related to machine learning...

πŸ”§ Configuration

Environment Variables

Create a .env file in the project root:

# Database location
BRIAN_DB_PATH=~/.brian/brian.db

# API server
BRIAN_HOST=127.0.0.1
BRIAN_PORT=8080
BRIAN_DEBUG=false

# Frontend (optional)
VITE_PORT=5173           # Frontend dev server port (auto-fallback if busy)
VITE_API_URL=http://127.0.0.1:8080  # Backend API URL for proxy

Dynamic Port Configuration:

  • If VITE_PORT is busy, the frontend will automatically use the next available port
  • Useful when running multiple instances or when ports are occupied

Goose Integration

The setup script automatically configures Goose. The configuration is added to ~/.config/goose/config.yaml:

extensions:
  brian:
    provider: mcp
    config:
      command: "/path/to/brian/venv/bin/python"
      args:
        - "-m"
        - "brian_mcp.server"
      env:
        BRIAN_DB_PATH: "~/.brian/brian.db"

After setup, restart Goose to load the Brian extension.

πŸ› οΈ Development

Manual Setup

If you prefer manual installation:

# Backend setup
python3 -m venv venv
source venv/bin/activate
pip install -e .

# Frontend setup
cd frontend
pnpm install

# Start backend
python -m brian.main

# Start frontend (in another terminal)
cd frontend
pnpm dev

Project Structure

brian/
β”œβ”€β”€ brian/                  # Backend Python package
β”‚   β”œβ”€β”€ api/               # FastAPI routes
β”‚   β”œβ”€β”€ database/          # SQLite database layer
β”‚   β”‚   β”œβ”€β”€ migrations.py  # Database migrations
β”‚   β”‚   β”œβ”€β”€ repository.py  # Data access layer
β”‚   β”‚   └── schema.py      # Database schema
β”‚   β”œβ”€β”€ models/            # Data models
β”‚   β”‚   └── knowledge_item.py
β”‚   └── services/          # Business logic
β”‚       β”œβ”€β”€ similarity.py  # Similarity calculations
β”‚       └── clustering.py  # Item clustering
β”œβ”€β”€ brian_mcp/             # MCP server for Goose integration
β”œβ”€β”€ frontend/              # React frontend
β”‚   └── src/
β”‚       β”œβ”€β”€ components/    # React components
β”‚       β”‚   β”œβ”€β”€ SimilarityGraph.jsx    # Main graph visualization
β”‚       β”‚   β”œβ”€β”€ ProjectSelector.jsx    # Project management UI
β”‚       β”‚   β”œβ”€β”€ ProjectPill.jsx        # Project indicator component
β”‚       β”‚   β”œβ”€β”€ Timeline.jsx           # Chronological view
β”‚       β”‚   β”œβ”€β”€ InfinitePinboard.jsx   # Spatial canvas
β”‚       β”‚   β”œβ”€β”€ RegionEditDialog.jsx   # Region management
β”‚       β”‚   └── Settings.jsx           # App settings
β”‚       β”œβ”€β”€ contexts/      # React contexts
β”‚       β”‚   └── SettingsContext.jsx
β”‚       β”œβ”€β”€ store/         # State management
β”‚       β”‚   └── useStore.js  # Zustand store
β”‚       └── lib/           # Utilities
β”œβ”€β”€ setup.sh               # One-command installation
β”œβ”€β”€ start.sh               # Start both servers
└── stop.sh                # Stop both servers

Running Tests

# Activate virtual environment
source venv/bin/activate

# Run Python tests
pytest

# Test MCP server
python test_mcp_simple.py

# Test search functionality
python test_search_fix.py

🎨 UI Features

Project Selector

  • Large pill-shaped button at top center
  • Shows current project with icon, name, and item count
  • "All Projects" mode shows universe icon with total counts
  • Dropdown with all projects, create new, and edit options
  • 25+ Lucide icons to choose from

Timeline View

  • Chronological display of all items
  • Grouped by date
  • Project pills showing item origin
  • Theme lines connecting related items
  • Smooth animations

Graph View

  • Force-directed layout with D3.js
  • Real-time similarity calculations
  • Interactive node selection
  • Theme-based filtering with drop shadows
  • Bottom sheet for detailed view with project pills
  • Pulsing animation on selected nodes
  • Hierarchical zoom with semantic rendering
  • Project hulls when viewing all projects
  • Zoom indicator showing current level

Navigation

  • Circular icon buttons matching modern UI patterns
  • Smooth transitions between views
  • Responsive design
  • Keyboard shortcuts (coming soon)

πŸ”Œ Goose MCP Tools

When integrated with Goose, Brian provides these tools:

Knowledge Management

create_knowledge_item

Add new items to your knowledge base.

Parameters:
- title: Item title
- content: Main content
- item_type: link, note, snippet, or paper
- url: Optional URL
- tags: Optional list of tags
- project_id: Optional project to add to

search_knowledge

Search your knowledge base with full-text and similarity search.

Parameters:
- query: Search query
- limit: Max results (default: 10)
- project_id: Optional project filter

find_similar_items

Find items similar to a given item.

Parameters:
- item_id: UUID of the reference item
- limit: Max results (default: 5)

get_item_details

Get full details of a specific item.

Parameters:
- item_id: UUID of the item

Project Management

list_projects

List all knowledge base projects.

create_project

Create a new knowledge base project.

Parameters:
- name: Project name
- description: Optional description
- icon: Optional emoji icon
- color: Optional hex color

switch_project

Switch the default project for new items.

Parameters:
- project_id: UUID of the project

get_project_context

Get knowledge context from a specific project.

Parameters:
- project_id: Optional project ID
- query: Optional query to filter items
- limit: Max items (default: 20)

Region Management

list_regions

List all knowledge regions.

create_region

Create a new knowledge region.

Parameters:
- name: Region name
- description: Optional description
- color: Optional hex color
- item_ids: Optional items to include

get_region_context

Get knowledge context from a specific region.

Parameters:
- region_id: UUID of the region
- query: Optional query to filter items

Context & Intelligence

get_knowledge_context

Get relevant knowledge items for a topic.

Parameters:
- topic: Topic to get context for
- limit: Max items (default: 5)

suggest_regions

Suggest relevant regions for a query.

Parameters:
- query: Query to find relevant regions
- limit: Max regions (default: 3)

debug_item_connections

Debug similarity connections for an item.

Parameters:
- item_id: UUID of the item to debug

πŸ“Š Similarity Algorithm

Brian uses a hybrid approach for finding connections:

  1. TF-IDF Vectorization: Converts text to numerical vectors
  2. Cosine Similarity: Measures angle between vectors
  3. Threshold Filtering: Only shows connections above 0.15 similarity
  4. Global IDF Scores: Pre-computed for all documents
  5. Project-Aware: Can filter connections by project

This creates meaningful connections between related items without manual linking.

πŸ› Troubleshooting

Backend won't start

# Check if port 8080 is in use
lsof -i :8080

# Check logs
tail -f backend.log

Frontend won't start

# Check if port 5173 is in use
lsof -i :5173

# Check logs
tail -f frontend.log

# Reinstall dependencies
cd frontend && pnpm install

Goose doesn't see Brian extension

# Verify config
cat ~/.config/goose/config.yaml

# Check Python path is correct
which python  # Should be inside brian/venv/bin/

# Restart Goose

Database issues

# Check database exists
ls -la ~/.brian/brian.db

# Reset database (WARNING: deletes all data)
rm ~/.brian/brian.db
# Restart backend to recreate

Graph not showing project hulls

  • Ensure you're in "All Projects" mode (click Project Selector β†’ All Projects)
  • Zoom out significantly (scale < 0.4) to see project boundaries
  • Check that you have items in multiple projects

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“š Documentation

πŸ—ΊοΈ Roadmap

Recently Completed

  • βœ… Multi-project knowledge bases
  • βœ… Project selector with custom icons
  • βœ… Hierarchical zoom (Knowledge Universe)
  • βœ… Project hulls and semantic zoom
  • βœ… All Projects view
  • βœ… Project pills in Timeline and Graph
  • βœ… Dynamic port configuration (VITE_PORT, VITE_API_URL env vars)
  • βœ… Automatic project assignment for new regions
  • βœ… Fixed Universe Mode initial load issues
  • βœ… Fixed region persistence across project views

Coming Soon

  • πŸ”œ Zoom slider control
  • πŸ”œ Preset zoom buttons (All / Project / Items)
  • πŸ”œ Breadcrumb navigation
  • πŸ”œ Keyboard shortcuts for navigation
  • πŸ”œ Image upload with LLM interpretation
  • πŸ”œ Standardized card components

Made with 🧠 and ❀️

A play on "brain" - because your knowledge deserves a smart home.

About

A complete local knowledge store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •