# adrninistrator/java-all-call-graph architecture

> Architecture diagram of the GitHub repository adrninistrator/java-all-call-graph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adrninistrator/java-all-call-graph
- Repository: https://github.com/adrninistrator/java-all-call-graph

## Overview

##### Main Components
a. Input Module – Source Code Scanner:
- This module is responsible for reading Java source or compiled classes.
- It may include file system traversal logic and initial filtering that leads the tool to process certain packages or files.
b. Call Graph Extraction Engine:
- The heart of the system, which parses the code (or bytecode), extracts method call relationships, and handles specialized scenarios like recursive calls, loops, or even filtering based on configuration.
- Within the project, the package structure under “src/main/java/com/adrninistrator/jacg/extractor” and “src/main/java/com/adrninistrator/jacg/runner” are central to this functionality.
c. Analysis and Handler Subsystems:
- There are multiple “handler” packages (for annotations, classes, method calls, field relationships, etc.) that process, validate, and format the extracted data.
- They implement strategies for dealing with edge cases (e.g., cyclic calls, lambda expressions, annotation specifics) and support extensibility.
d. Configuration and Extension Management:
- The system uses configuration files (found in resource directories like “_jacg_config” and “_jacg_extensions”) which govern filtering rules, output details, and custom extensions.
- Additionally, the project supports extension points – allowing users to plug in custom code to modify extraction or output behavior.
e. Output/Storage Module:
- This component formats and organizes the extracted call graph data (e.g., as JSON, SQL insertions, or files) for generating reports or visual representations.
- Integration with databases is supported (refer to the “SQL语句” directory with SQL scripts and “neo4j” packages for graph database output).
f. External Integration Interfaces:
- Integration with external systems such as Neo4j is evident from dedicated modules for graph database operation.
- There are also runner scripts (shell, Gradle build files) and test cases that demonstrate command-line execution and integration.

##### Establish Relationships and Interactions
- Flow starting from the source code input, which feeds into the extraction and parsing engine.
- The extracted method call data is passed to various handler modules that process and ﬁlter the raw data.
- Processed data is directed to output modules where it can be written directly to files, inserted into SQL databases, or sent to a Neo4j graph database.

##### Important Architectural Patterns
- Existence of “Extension” points that follow Strategy or Plugin patterns, allowing custom behaviors for annotation parsing, filtering, or method call transformation.
- Separation of concerns is visible: the code is organized by functionality (e.g., extraction tasks vs. database writing tasks) and by runtime environment (source vs. test resources).

##### Technologies and Frameworks
- Gradle is used as the build tool – include a small note that the build configuration manages dependencies.
- For data persistence and graph representation, integration with SQL databases and Neo4j is central.
- Java itself is the primary language, and parts of the system likely leverage reflection and bytecode reading libraries.

##### Detail on Essential Architectural Elements
- Clearly split the system into as many logical components as possible. Even sub-packages should have their own representation if they play a distinct role.
- Interfaces and abstract classes where strategy or dependency injection is in use.
- Optionally, include testing infrastructure separately to demonstrate how automated tests validate core functionalities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input Layer"
        A["Source Code Scanner"]:::input
    end

    subgraph "Processing Layer"
        B["Call Graph Extraction Engine"]:::processing
        C["Annotation & Handler Processors"]:::processing
    end

    subgraph "Configuration Layer"
        D1["Config Manager"]:::config
        D2["Extension Manager"]:::config
    end

    subgraph "Output Layer"
        E["Output Formatter (SQL)"]:::output
        F["Output Formatter (Neo4j)"]:::output
    end

    subgraph "External Interfaces"
        G1["Runner Scripts"]:::external
        G2["Shell Scripts"]:::external
        G3["Batch Scripts"]:::external
    end

    A -->|"scans"| B
    B -->|"extracts"| C
    D1 -.->|"config-feedback"| B
    D2 -.->|"extension-feedback"| B
    C -->|"formats-to"| E
    C -->|"formats-to"| F
    B -->|"initiates"| G1
    B -->|"initiates"| G2
    B -->|"initiates"| G3

    click A "https://github.com/adrninistrator/java-all-call-graph/blob/main/java-all-call-graph/src/main/java/com/adrninistrator/jacg/extractor/entry/BaseExtractor.java"
    click B "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/java/com/adrninistrator/jacg/extractor/"
    click C "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/java/com/adrninistrator/jacg/handler/"
    click D1 "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/resources/_jacg_config"
    click D2 "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/resources/_jacg_extensions"
    click E "https://github.com/adrninistrator/java-all-call-graph/tree/main/SQL语句"
    click F "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/java/com/adrninistrator/jacg/neo4j/"
    click G1 "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/src/main/java/com/adrninistrator/jacg/runner/"
    click G2 "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/shell/"
    click G3 "https://github.com/adrninistrator/java-all-call-graph/tree/main/java-all-call-graph/bat/"

    classDef input fill:#f4a460,stroke:#333,stroke-width:2px;
    classDef processing fill:#87ceeb,stroke:#333,stroke-width:2px;
    classDef config fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef output fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef external fill:#dcdcdc,stroke:#333,stroke-width:2px;
```
