← Home System Overview Architecture Data Pipeline Health System Usage System Workflows MCP Tools

System Overview — The Brain

Blueprint · Last updated 2026-05-02

Purpose

The Brain is a Python CLI orchestration system that offloads AI tasks from Claude to free provider APIs. Claude acts as orchestrator — deciding what to do and which worker to use — while the actual AI work (summarization, code generation, classification, etc.) is handled by free-tier providers. All calls are logged for cost tracking.

Core promise: Claude only does what only Claude can do. Everything else is delegated.

Tech Stack

ComponentTechnology
RuntimePython 3
Entry pointdelegate.py CLI
Provider adaptersbrain/adapters/ — one file per provider
Routing logicbrain/router.py
Stats trackingbrain/stats.py → stats/usage.json
Orchestratorbrain/orchestrator.py
IntegrationGlobal CLAUDE.md routing table

CLI Interface

python delegate.py --provider <name> --type <type> --prompt "<prompt>"

Claude reads the routing table in CLAUDE.md and calls delegate.py directly. The result is returned on stdout and relayed to the user.

Task Types

TypeBest ProviderUse case
classificationcerebrasYes/no, scoring, labelling
factual_qacerebras / groqQuick factual questions, general explanation
summarizationgeminiLong text compression, 1M token context
translationgeminiAny language pair
codingmistralCode generation, debugging
extractionmistralStructured data extraction from text
creativemistralWriting, drafting, brainstorming
reasoningsambanovaDeep analysis, trade-off evaluation
generalcerebrasAnything that doesn't fit above

Provider Registry

KeyDefault ModelSpeedNotes
cerebrasllama3.1-8b~284msUltra-fast; best for classification and quick Q&A
groqllama-3.1-8b-instant~366msFast LPU inference; general fallback
geminigemini-2.5-flash-lite~541ms1M token context; best for long docs, translation
mistralmistral-small-latest~1172msBest free quality for coding and creative tasks
sambanovaMeta-Llama-3.3-70B~1.4s70B model; highest free-tier quality for reasoning
fireworksllama-v3p3-70b-instructfastStrong coding; DeepSeek V3 available
openaigpt-4o-ministandardReliable all-rounder
coherecommand-r-08-2024standardRetrieval and extraction specialist
cloudflarellama-3.1-8b-instructfastEdge-hosted; no credit card required
huggingfaceQwen2.5-72B-InstructslowLast-resort fallback; broad model selection
openroutergemma-4-26b-a4b-it:freestandard50+ models via one key
ollamaqwen2.5-coder:7blocalLocal inference; fully private, no API key
pollinationsopenai / fluxvariesKeyless; text and image generation fallback

Repository Structure

the-brain/
├── delegate.py              # CLI entry point — call this to offload
├── session_start.py         # Session startup: prints provider health + stats
├── report.py                # Usage stats report
├── push_stats.py            # Update GitHub README with usage stats
├── health_check.py          # Provider health polling
├── brain/
│   ├── orchestrator.py      # Core dispatcher
│   ├── router.py            # Routing table and fallback chains
│   ├── stats.py             # Persistent usage tracking
│   └── adapters/            # One file per provider
├── config/
│   ├── keys.json            # API keys (not committed)
│   └── keys.example.json    # Template
├── stats/
│   └── usage.json           # Running usage log (auto-created)
├── assets/
│   └── brain.png            # Project image
└── docs/
    └── index.html           # Public project page (GitHub Pages)

Persistence

FileContents
.envAPI keys per provider (gitignored)
stats/usage.jsonAggregate lifetime totals per provider; last 100 calls for display (bounded)
stats/call_log.jsonlPermanent per-call history — one JSON line per delegate call, never truncated
stats/health_log.jsonAppend-only health probe results — one entry per provider/model per check cycle
stats/model_state.jsonPer-model state: active / paused / disabled with reason and timestamp

Integration with Claude Code

The Brain is activated by adding a routing table to the global CLAUDE.md (at C:\Users\<user>\.claude\CLAUDE.md). Claude reads this at session start and automatically delegates matching tasks rather than answering them directly.

Session startup runs session_start.py which prints live provider health and usage stats so routing advisories can be relayed before any work begins.