# phodal/chapi architecture

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

- Interactive diagram: https://gitdiagram.com/phodal/chapi
- Repository: https://github.com/phodal/chapi

## Overview

##### Main Components Architecture

**┌─────────────────────────────────────────────────────────────┐**
- Chapi Core System                       │
- ┬─────────────────────────┬──────────────────┤
- Language ASTs │     Domain Model        │    Helpers       │
- (Tier 1-3)    │                         │                  │
- ┴─────────────────────────┴──────────────────┘

##### Detailed Component Breakdown

- Tier 1 (Green): Java, TypeScript
- Tier 2 (Yellow): Kotlin, Go, Python, Scala
- Tier 3 (Orange): Rust, C#, C, C++
- IDL (Blue): Protobuf, Thrift

b) Domain Model (Core):
- CodeProject
- CodeModule
- CodePackage
- CodeContainer
- CodeDataStruct
- CodeFunction
- Supporting Elements (CodeAnnotation, CodeField, etc.)

**Source Code ─→ Language Parser ─→ AST Generation ─→ Domain Model ─→ Unified Output**

##### Component Interactions

- How language parsers interact with the domain model
- How the domain model components relate to each other
- How helpers support the main components

##### Key Features Layer

Supported features for each language:
- HTTP API Declaration
- Syntax Parsing
- Function Calls
- Architecture/Package Analysis
- Real-world Usage

##### Implementation Details

Technical details like:
- ANTLR Grammar Integration
- Two-pass Scanning Process
- Language-specific Rules
- Extension Points

##### Labels
- Clear, concise component names
- Version information where relevant
- Support status indicators

##### Notes
- Important implementation details
- Experimental features
- Extension points

Remember to:
- Most important interactions
- Version information
- Clear boundaries between components
- Extension points for future development

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Chapi Core System"
        DM["Domain Model"]
        AST["Language ASTs"]
        HP["Helpers"]:::helper
    end

    subgraph "Domain Model Components"
        CP["CodeProject"]:::core
        CM["CodeModule"]:::core
        CPK["CodePackage"]:::core
        CC["CodeContainer"]:::core
        CDS["CodeDataStruct"]:::core
        CF["CodeFunction"]:::core
    end

    subgraph "Language Support"
        subgraph "Tier 1"
            JAVA["Java"]:::tier1
            TS["TypeScript"]:::tier1
        end

        subgraph "Tier 2"
            KOTLIN["Kotlin"]:::tier2
            GO["Go"]:::tier2
            PYTHON["Python"]:::tier2
            SCALA["Scala"]:::tier2
        end

        subgraph "Tier 3"
            RUST["Rust"]:::tier3
            CSHARP["C#"]:::tier3
            C["C"]:::tier3
            CPP["C++"]:::tier3
        end

        subgraph "IDL"
            PROTO["Protobuf"]:::idl
            THRIFT["Thrift"]:::idl
        end
    end

    subgraph "Parser Support"
        CMAKE["CMake Parser"]:::parser
        TOML["TOML Parser"]:::parser
    end

    %% Relationships
    DM --> CP & CM & CPK & CC & CDS & CF
    AST --> JAVA & TS & KOTLIN & GO & PYTHON & SCALA & RUST & CSHARP & C & CPP & PROTO & THRIFT
    HP --> DM
    HP --> AST

    %% Click Events
    click CP "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodeProject.kt"
    click CM "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodeModule.kt"
    click CPK "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodePackage.kt"
    click CC "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodeContainer.kt"
    click CDS "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodeDataStruct.kt"
    click CF "https://github.com/phodal/chapi/blob/master/chapi-domain/src/main/kotlin/chapi/domain/core/CodeFunction.kt"
    click JAVA "https://github.com/phodal/chapi/tree/master/chapi-ast-java"
    click TS "https://github.com/phodal/chapi/tree/master/chapi-ast-typescript"
    click KOTLIN "https://github.com/phodal/chapi/tree/master/chapi-ast-kotlin"
    click GO "https://github.com/phodal/chapi/tree/master/chapi-ast-go"
    click PYTHON "https://github.com/phodal/chapi/tree/master/chapi-ast-python"
    click SCALA "https://github.com/phodal/chapi/tree/master/chapi-ast-scala"
    click RUST "https://github.com/phodal/chapi/tree/master/chapi-ast-rust"
    click CSHARP "https://github.com/phodal/chapi/tree/master/chapi-ast-csharp"
    click C "https://github.com/phodal/chapi/tree/master/chapi-ast-c"
    click CPP "https://github.com/phodal/chapi/tree/master/chapi-ast-cpp"
    click PROTO "https://github.com/phodal/chapi/tree/master/chapi-ast-protobuf"
    click THRIFT "https://github.com/phodal/chapi/tree/master/chapi-ast-thrift"
    click HP "https://github.com/phodal/chapi/tree/master/chapi-helper/src/main/kotlin/chapi/ast/helper"
    click CMAKE "https://github.com/phodal/chapi/tree/master/chapi-parser-cmake"
    click TOML "https://github.com/phodal/chapi/tree/master/chapi-parser-toml"

    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef tier1 fill:#90EE90,stroke:#333
    classDef tier2 fill:#FFD700,stroke:#333
    classDef tier3 fill:#FFA500,stroke:#333
    classDef idl fill:#87CEEB,stroke:#333
    classDef helper fill:#DDA0DD,stroke:#333
    classDef parser fill:#20B2AA,stroke:#333

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Tier 1 Languages"]:::tier1
        L3["Tier 2 Languages"]:::tier2
        L4["Tier 3 Languages"]:::tier3
        L5["IDL Support"]:::idl
        L6["Helpers"]:::helper
        L7["Parsers"]:::parser
    end
```
