Skip to main content

2. Core Subsystems

2.1 Subsystem Inventory​

Batho is composed of tightly-integrated subsystems that work together to provide code intelligence capabilities. Each subsystem has a well-defined responsibility and can be tested independently.

SubsystemPurposeStatus
AST Extractiontree-sitter based multi-language parsingProduction
Code GraphIn-memory hypergraph with adjacency indexingProduction
Arrow Graph BackendColumnar memory-mapped graph storage with CSR/CSC adjacency indexesProduction
BSG Map & CompressionFlat symbol index, priority token budgeting, and rule loadersProduction
Dependency Indexerstdlib and installed virtual environment dependency indexerProduction
Storage RegistryArrow IPC database manager, BSG scratch store, and unified cacheProduction
Integrity VerificationDatabase checker, repair engine, and report generationProduction
Orchestrator LayerHigh-level command implementations (build, patch, export, load, gc)Production
Community DetectionGreedy modularity clustering based code network groupingProduction
MCP ServerModel Context Protocol server exposing code graph capabilitiesProduction
Shared UtilitiesHashing, file I/O, encoding, ignore patterns, logging, path sanitization, memory monitoringProduction
CLI Command SuiteCommand interface parsing and subcommand orchestrationProduction

2.2 Technology Stack​

Runtime Environment​

LayerTechnologyVersion
Language RuntimePython3.12+
AST Parsingtree-sitter0.25+
Language Packtree-sitter-language-packLatest
ConfigurationPydantic2.x

Interface Layer​

LayerTechnologyPurpose
CLI Frameworkargparse (stdlib)Command-line interface
Data ExportJSON / PrettyProgrammatic data output
MCP ProtocolFastMCPModel Context Protocol server (stdio)

Data Layer​

LayerTechnologyPurpose
Registry / Cachemsgpack + Arrow IPCDurable database storage and high-speed memory-mapping
Artifact BundleZIP ZSTD ArchiveTransport packaging format

Development & Testing​

LayerTechnologyPurpose
Testingpytest + pytest-cov8.x / 5.x
Build TooluvLatest
Lintingruff, mypyCode quality

2.3 Subsystem Interactions​

Subsystems communicate through well-defined interfaces:

Figure 4: Subsystem Interactions - Dependency graph showing how Batho subsystems communicate through well-defined interfaces.

2.4 Data Flow Between Subsystems​

  1. Command Phase: CLI → Orchestrator (parse options, load config)
  2. Extraction Phase: Orchestrator → Extractor → Cache + Graph
  3. Resolution Phase: Graph → SymbolIndex → Graph (cross-file resolution)
  4. Intelligence Phase: Graph → BSG → Rules → BSG (semantic tagging)
  5. Storage & Serialization: BSG → Storage Registry (Arrow IPC views)
  6. Output Phase: Storage Registry → Orchestrator → CLI (Command output / JSON Export)