How blarapp/blarify works
Project type and purpose
• Blarify is an open-source code-analysis and graph-building CLI tool.
• It traverses a local codebase in multiple languages, builds a semantic graph of files, folders, classes, functions, and their relationships, then persists that graph to a database so that an LLM (or other client) can query, traverse, debug, or refactor the code.
File structure
• Top-level “blarify/” module contains all core packages:
• project_file_explorer – discovers files and folders in the target repo
• code_hierarchy – uses Tree-sitter definitions per language to build an AST hierarchy
• code_references – uses LSP (language servers) to resolve cross-file references
• graph – defines node and relationship types, environment, update logic, and an external relationship store
• db_managers – adapters for Neo4j or FalkorDB to persist the graph
• internal – CLI command implementations for create, update, diff operations
• utils, stats, logger – supporting utilities and metrics
• Entry point: main.py (parses CLI, delegates to internal/create or update routines)
• Examples and prebuilt scripts show typical usage patterns
Pull architecture cues from the README
• Purpose: present any codebase as a graph for LLM traversal
• Supported languages hint at a plug-in architecture for language definitions
• Quickstart refers to graph visualization, implying a separation between graph construction and graph consumption
a. Main components:
1. CLI / Orchestration Layer (main.py + internal/)
2. File Explorer (project_file_explorer/)
3. Syntax & Semantic Analyzers
– code_hierarchy (Tree-sitter)
– code_references (LSP helper)
4. Graph Model Layer (graph/ + external_relationship_store)
5. Persistence Layer (db_managers: Neo4j, FalkorDB)
6. Utilities & Metrics (logger, stats, utils)
7. External Services
– Language Servers (per supported language)
– Graph Consumers (LLM, visualization tools)
b. Relationships & interactions:
• CLI triggers File Explorer to scan file system → feeds file list to Syntax/ Semantic Analyzers.
• code_hierarchy builds node hierarchy; code_references resolves symbol links via language servers.
• Both pass their outputs to Graph Model Layer, which creates Node and Relationship objects.
• Graph Model Layer calls Persistence Layer adapters to write/read the graph.
• The graph can be queried by an LLM or exported to visualization.
• Utilities (logger, stats) are cross-cutting services used by all layers.
c. Architectural patterns & design principles:
• Modular “pipeline” or “stages” pattern: each stage (explore, parse, resolve, build, persist) is decoupled.
• Adapter pattern for DB managers and language definitions—easy to extend to new backends or languages.
• Single responsibility modules (each package focuses on one task).
• Incremental update support via diff/updater modules in internal/.
d. Key technologies & frameworks:
• Python 3, Tree-sitter for syntax trees.
• LSP protocol for cross-reference resolution.
• Neo4j & FalkorDB drivers for graph persistence.
• CLI via argparse or click (in main.py).