# tommy811/jcat architecture

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

- Interactive diagram: https://gitdiagram.com/tommy811/jcat
- Repository: https://github.com/tommy811/jcat

## Overview

##### Project Components
- JCat-web: This is the frontend part of the system. It’s built with Vue.js (as seen from files like App.vue, main.js, components, router, and store). Its responsibility is to present a web UI (developer console) very similar to Chrome’s dev tools.
- agent-adapter: A Java module (with Gradle build) that likely acts as a bridge between the agent and external functions (or possibly between the frontend and the agent).
- jCat-agent: This module contains the core Java agent functionality. It has both Groovy and Java sources. It implements the core of the agent including:
- Agent attachment (see Agent.java).
- Console functionalities and command handling (packages for console and groovyLsp).
- Service components (for HTTP server, resource explorer, etc.).
- jcat-boot: This is the bootstrap/loader module. It provides the executable jar (jcat-boot.jar) that a user runs to start the process. It handles selecting the target JVM and injecting the agent (as indicated by classes like BootstrapAgent.java and JCatLoader.java).
- test-spring: A sample Spring application meant for testing or demonstration of the agent’s integration with a running Java application.

##### Interactions and Data Flow
- The user starts the system by launching jcat-boot.jar. This bootloader is responsible for attaching or injecting the agent (jCat-agent) into a target JVM process.
- Once injected, the agent module (jCat-agent) likely starts an HTTP server (via DefaultHttpServer.java) or other communication mechanism so that external components can communicate with the target JVM.
- The web console (JCat-web) provides the user interface. It communicates (via APIs, found in the src/api folder) with backend services to send commands or scripts (Groovy scripts, for example) that are executed inside the loaded agent in the target JVM.
- The agent-adapter may act as a supporting layer to transform or handle communications between these layers, ensuring that commands from the web console are correctly executed within the agent.
- The test-spring module serves as an example of a target application that exists in the JVM when the agent is attached.

##### Architectural Patterns and Key Technologies
- Java Agent Injection: The system uses the Javaagent approach to integrate with another JVM process.
- Web-based UI (Frontend/Backend separation): Visual presentation is handled by the Vue.js-based frontend (JCat-web) while the backend agent functionalities reside within jCat-agent and the boot process in jcat-boot.
- Gradle-based project builds: Multiple modules are built using Gradle.
- Service and API layers: The backend creates endpoints and services (e.g., DefaultHttpServer in jCat-agent) for command execution and result delivery.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        JCatWeb["Frontend (JCat-web): Vue.js UI,API interactions"]
    end

    subgraph "Boot/Loader"
        BootLoader["Agent Bootloader (jcat-boot)"]
    end

    subgraph "Backend Agent Layer"
        subgraph "Java Agent (jCat-agent)"
            AgentEntry["Agent Injection (Agent.java)"]
            ConsoleBase["Console Base (ConsoleBase.groovy)"]
            GroovyLoader["Groovy Console Loader (GroovyConsoleLoader.java)"]
            HttpService["HTTP Service (DefaultHttpServer.java)"]
            Utility["Utility Classes"]
        end
        AgentAdapter["Agent Adapter"]
    end

    subgraph "Target Application"
        TestSpring["Target Application (test-spring)"]
    end

    BootLoader -->|"injects"| AgentEntry
    BootLoader -->|"attachesAgent"| TestSpring
    JCatWeb   -->|"sendCommand"| HttpService
    AgentAdapter -->|"adapts"| AgentEntry

    class JCatWeb frontend
    class BootLoader,AgentEntry,ConsoleBase,GroovyLoader,HttpService,Utility,AgentAdapter backend
    class TestSpring external

    classDef frontend fill:#D0E9FF,stroke:#007ACC,stroke-width:2px;
    classDef backend fill:#DFFFD0,stroke:#00A300,stroke-width:2px;
    classDef external fill:#FFE0B2,stroke:#FF9800,stroke-width:2px;

    click JCatWeb "https://github.com/tommy811/jcat/tree/main/JCat-web"
    click BootLoader "https://github.com/tommy811/jcat/tree/main/jcat-boot/src/main/java/org/coderead/jcat"
    click AgentEntry "https://github.com/tommy811/jcat/blob/main/jCat-agent/src/main/java/org/coderead/jcat/Agent.java"
    click ConsoleBase "https://github.com/tommy811/jcat/blob/main/jCat-agent/src/main/groovy/org/coderead/jcat/console/ConsoleBase.groovy"
    click GroovyLoader "https://github.com/tommy811/jcat/blob/main/jCat-agent/src/main/java/org/coderead/jcat/console/GroovyConsoleLoader.java"
    click HttpService "https://github.com/tommy811/jcat/blob/main/jCat-agent/src/main/java/org/coderead/jcat/service/DefaultHttpServer.java"
    click Utility "https://github.com/tommy811/jcat/tree/main/jCat-agent/src/main/java/org/coderead/jcat/common"
    click AgentAdapter "https://github.com/tommy811/jcat/tree/main/agent-adapter/src/main/java/org/coderead/jcat"
    click TestSpring "https://github.com/tommy811/jcat/tree/main/test-spring/src/main/java/cn/coderead/testspring"
```
