# btraceio/jafar architecture

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

- Interactive diagram: https://gitdiagram.com/btraceio/jafar
- Repository: https://github.com/btraceio/jafar

## Overview

##### Main Components

a) Core Parser Components:
- Parser Module (Central component)
- API Layer
- Internal API Layer
- Metadata Processing System
- Utilities Layer
- Gradle Plugin Component

b) External Integration Points:
- JFR File Input
- Client Application Integration
- Build System Integration

**Top Level (Client Integration):**
**[Client Application] <---> [Generated Interfaces] <---> [JFR Handler Interface]**
- ^

**Middle Level (Core Processing):   |**
**[JFR File] --> [Parser Core] --> [Bytecode Generation]**

- v
**Lower Level (Internal Components):**
**[Metadata Processing] <--> [Constant Pools] <--> [Event Processing]**

##### Component Details

a) Parser Core (io.jafar.parser):
- Connections to JafarParserImpl and AbstractEvent
- Interaction with API interfaces

b) API Layer (io.jafar.parser.api):
- JafarParser interface and JFR annotations
- Connection to client code

c) Internal API (io.jafar.parser.internal_api):
- Metadata processing components
- Streaming and chunk processing elements

d) Gradle Plugin:
- Connection to build process
- Type generation workflow

##### Important Relationships to Highlight

a) Data Flow:
- JFR File → Parser → Handler Interfaces → Client Code
- Metadata → Type Generation → Interface Creation

b) Build-time Flow:
- Gradle Plugin → Type Generation → Generated Interfaces

##### Implementation Details

**[Parser Implementation Details]**
- MutableConstantPool management
- Streaming chunk processing
- Metadata handling
- Event filtering system

##### Technical Notes

Notes indicating:
- Java 21 requirement
- Git LFS dependency
- Performance characteristics
- Memory optimization strategies

Remember to emphasize:
##### The metadata processing system

This will provide a comprehensive view of the system while maintaining clarity about its core purpose as a high-performance JFR parser.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Integration Layer"]
        CA[Client Application]
        GI[Generated Interfaces]
        JH["JFR Handler Interface"]:::handler
    end

    subgraph Core["Core Processing Layer"]
        PC["Parser Core"]:::parser
        BG["Bytecode Generation"]:::codegen
        JF["JFR File Input"]
    end

    subgraph Internal["Internal Components Layer"]
        MP["Metadata Processing"]:::metadata
        CP["Constant Pools"]:::constant
        EP["Event Processing"]:::event
        ST["Streaming Implementation"]:::stream
    end

    subgraph Build["Build Integration"]
        GP["Gradle Plugin"]:::gradle
        TG["Type Generation"]:::types
    end

    %% Connections
    CA <--> GI
    GI <--> JH
    JF --> PC
    PC --> BG
    PC <--> MP
    MP <--> CP
    CP <--> EP
    GP --> TG
    TG --> GI
    ST --> PC
    
    %% Performance Critical Paths
    PC -.->|Performance Critical| EP
    MP -.->|Performance Critical| CP

    %% Click Events
    click PC "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/JafarParserImpl.java"
    click JH "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/api/JFRHandler.java"
    click MP "https://github.com/btraceio/jafar/tree/main/parser/src/main/java/io/jafar/parser/internal_api/metadata/"
    click CP "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/MutableConstantPool.java"
    click ST "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/internal_api/RecordingStream.java"
    click BG "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/internal_api/CodeGenerator.java"
    click GP "https://github.com/btraceio/jafar/blob/main/jafar-gradle-plugin/src/main/groovy/io/jafar/gradle/TypeGeneratorPlugin.groovy"
    click TG "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/utils/TypeGenerator.java"
    click EP "https://github.com/btraceio/jafar/blob/main/parser/src/main/java/io/jafar/parser/AbstractEvent.java"

    %% Styling
    classDef parser fill:#3498db
    classDef handler fill:#2ecc71
    classDef metadata fill:#f1c40f
    classDef constant fill:#e67e22
    classDef event fill:#9b59b6
    classDef stream fill:#1abc9c
    classDef codegen fill:#34495e
    classDef gradle fill:#e74c3c
    classDef types fill:#95a5a6

    %% Legend
    subgraph Legend
        L1[Parser Components]:::parser
        L2[API Components]:::handler
        L3[Internal Components]:::metadata
        L4[Build Tools]:::gradle
    end
```
