# git-probe/gitprobe architecture

> Architecture diagram of the GitHub repository git-probe/gitprobe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/git-probe/gitprobe
- Repository: https://github.com/git-probe/gitprobe

## Overview

##### Project type and purpose
- GitProbe is a full-stack developer tool composed of a CLI and a RESTful Web API (FastAPI).
- It clones arbitrary GitHub repositories, parses source code with Tree-sitter, runs language-specific analyzers to build call graphs and metadata, and returns JSON for visualization (e.g., Cytoscape.js).

##### File structure
- Top-level:
- CLI entrypoints: `src/gitprobe/__main__.py`, `src/gitprobe/cli.py`
- Core engine: `src/gitprobe/analysis/`
- Language plugins: `src/gitprobe/analyzers/`
- Web server: `src/gitprobe/web/server.py`
- Data models and limits: `src/gitprobe/models/`, `src/gitprobe/core/analysis_limits.py`
- Utilities: `src/gitprobe/utils/`
- Configs & scripts: `pyproject.toml`, `requirements.txt`, `DEVELOPMENT.md`
- Tests: a comprehensive integration suite under `tests/`

##### README for additional insights
- “Architecture” section outlines components.
- Technologies: Python 3.8+, FastAPI, Pydantic, Tree-sitter, Rich, Cytoscape.js.
- Key services: repository cloning, syntax parsing, call graph generation, REST API.

## Diagram (Mermaid)

```mermaid
graph TB
  %% Entry Points (Blue)
  subgraph "Entry Points"
    CLI["gitprobe CLI"]:::entry
    CLI_main["__main__.py"]:::entry
    CLI_cli["cli.py"]:::entry
    Web["FastAPI Server"]:::entry
    Server["server.py"]:::entry
  end

  %% Service & Core (Green)
  subgraph "Service Layer"
    AnalysisSvc["AnalysisService"]:::service
    RepoCloner["RepoCloner"]:::service
    Limits["Analysis Limits"]:::models
  end

  %% Core Analyzers (Green)
  subgraph "Core Analyzers"
    RepoAnalyzer["repo_analyzer.py"]:::service
    CallGraphAnalyzer["call_graph_analyzer.py"]:::service
  end

  %% Language Analyzers (Plugins, Green)
  subgraph "Language Analyzers"
    PythonAnalyzer["python.py"]:::service
    JSAnalyzer["javascript.py"]:::service
    RustAnalyzer["rust.py"]:::service
    GoAnalyzer["go.py"]:::service
    CPPAnalyzer["c_cpp.py"]:::service
  end

  %% Models & Utils (Gray)
  subgraph "Models & Utilities"
    AnalysisModel["analysis.py"]:::models
    CoreModel["core.py"]:::models
    LoggingUtil["logging_config.py"]:::models
    PatternsUtil["patterns.py"]:::models
  end

  %% External Systems (Orange)
  subgraph "External Systems"
    GitHub["GitHub API / Git"]:::external
    TreeSitter["Tree-sitter"]:::external
    Cytoscape["Cytoscape.js"]:::external
  end

  %% Data Flow
  CLI -->|"invoke"| CLI_main
  CLI_main -->|"calls"| CLI_cli
  CLI_cli -->|"CLI request"| AnalysisSvc
  Web -->|"POST /analyze"| Server
  Server -->|"calls analyze()"| AnalysisSvc

  AnalysisSvc -->|"clone(repo_url)"| RepoCloner
  RepoCloner -->|"git clone"| GitHub

  AnalysisSvc -->|"load plugins"| PythonAnalyzer
  AnalysisSvc -->|"load plugins"| JSAnalyzer
  AnalysisSvc -->|"load plugins"| RustAnalyzer
  AnalysisSvc -->|"load plugins"| GoAnalyzer
  AnalysisSvc -->|"load plugins"| CPPAnalyzer

  PythonAnalyzer -->|"parse AST"| TreeSitter
  JSAnalyzer -->|"parse AST"| TreeSitter
  RustAnalyzer -->|"parse AST"| TreeSitter
  GoAnalyzer -->|"parse AST"| TreeSitter
  CPPAnalyzer -->|"parse AST"| TreeSitter

  PythonAnalyzer -->|"file results"| RepoAnalyzer
  JSAnalyzer -->|"file results"| RepoAnalyzer
  RustAnalyzer -->|"file results"| RepoAnalyzer
  GoAnalyzer -->|"file results"| RepoAnalyzer
  CPPAnalyzer -->|"file results"| RepoAnalyzer

  RepoAnalyzer -->|"aggregate calls"| CallGraphAnalyzer
  CallGraphAnalyzer -->|"build graph"| AnalysisModel
  CallGraphAnalyzer -->|"summary"| CoreModel

  AnalysisSvc -->|"validate/serialize"| AnalysisModel
  AnalysisSvc -->|"enforce limits"| Limits
  AnalysisSvc -->|"log progress"| LoggingUtil
  AnalysisSvc -->|"pattern match"| PatternsUtil

  AnalysisSvc -->|"return JSON"| CLI_cli
  AnalysisSvc -->|"return JSON"| Server
  CLI_cli -->|"print JSON"| Cytoscape
  Server -->|"HTTP JSON"| Cytoscape

  %% Click Events
  click CLI_main "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/__main__.py"
  click CLI_cli "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/cli.py"
  click Server "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/web/server.py"
  click AnalysisSvc "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analysis/analysis_service.py"
  click RepoCloner "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analysis/cloning.py"
  click RepoAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analysis/repo_analyzer.py"
  click CallGraphAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analysis/call_graph_analyzer.py"
  click PythonAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analyzers/python.py"
  click JSAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analyzers/javascript.py"
  click RustAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analyzers/rust.py"
  click GoAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analyzers/go.py"
  click CPPAnalyzer "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/analyzers/c_cpp.py"
  click AnalysisModel "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/models/analysis.py"
  click CoreModel "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/models/core.py"
  click Limits "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/core/analysis_limits.py"
  click LoggingUtil "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/utils/logging_config.py"
  click PatternsUtil "https://github.com/git-probe/gitprobe/blob/main/src/gitprobe/utils/patterns.py"

  %% Styles
  classDef entry fill:#ADD8E6,stroke:#333,stroke-width:1px
  classDef service fill:#90EE90,stroke:#333,stroke-width:1px
  classDef models fill:#D3D3D3,stroke:#333,stroke-width:1px
  classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
