# yuzutech/kroki architecture

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

- Interactive diagram: https://gitdiagram.com/yuzutech/kroki
- Repository: https://github.com/yuzutech/kroki

## Overview

##### Main Components
a. API Gateway (Server):
- ‘server’ module as the central component. This Java web server (built using Maven and powered by Vert.x) exposes REST endpoints that accept HTTP GET and POST requests.
- It handles authentication, request decoding (using deflate + base64 encoding), logging, error handling, and routing.
b. Companion Services:
c. Build and Deployment Infrastructure:
- The Maven build system for the Java components.
- TaskRunner (using Taskfile) to coordinate Maven builds and Docker image builds.
- Docker images and Docker Compose orchestration, which define how the gateway and multiple companion containers interact.
d. External Interfaces:
- CI/CD pipelines (GitHub Actions workflows) to run tests and build images.
- External configuration via environment variables (for instance, KROKI_MERMAID_HOST, etc.) that link the gateway with its companion containers.

##### Relationships & Interactions
c. Optionally, indicate the feedback paths (responses with rendered images like SVG, PNG, etc.) returning from the companion services back to the gateway and ultimately to the client.
d. An indication of logging, error handling, and caching strategies incorporated by the gateway.

##### Architectural Patterns & Technologies
a. Use the API Gateway pattern as the core design principle – the gateway centralizes client interaction and dispatches requests to microservices.
b. Pattern-wise, this is a microservices-based design: the companion services are independent, containerized, and separately deployable.
c. Technologies to highlight:
– Java, Vert.x, and Maven for the server.
– Node.js and micro for companion services.
– Docker (and Docker Compose) as the container orchestration tool.
– Task (the build tool) for automation.
– GitHub Actions for CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Interaction Layer
    Client["Client (Browser/HTTP)"]:::external

    %% API Gateway Layer
    subgraph "API Gateway & Request Handling"
        API["Kroki API Gateway (Java/Vert.x)"]:::java
        Log["Logging/ErrorHandling/Caching"]:::java
        API -->|"internal"| Log
    end

    %% Companion Services Layer
    subgraph "Companion Services"
        Mermaid["Mermaid Companion Service"]:::node
        BPMN["BPMN Companion Service"]:::node
        Excal["Excalidraw Companion Service"]:::node
        Diagrams["Diagrams.net Companion Service"]:::node
        Nomnoml["Nomnoml Companion Service"]:::node
        Bytefield["Bytefield Companion Service"]:::node
        DBML["DBML Companion Service"]:::node
        Vega["Vega Companion Service"]:::node
        Wavedrom["Wavedrom Companion Service"]:::node
    end

    %% Operational Infrastructure Layer
    subgraph "Operational Infrastructure"
        Build["Build & Deployment Infrastructure"]:::build
        CICD["CI/CD Pipelines"]:::cicd
        Docker["Container Orchestration (Docker Compose)"]:::build
    end

    %% Request Flow from Client to API Gateway
    Client -->|"HTTPRequest"| API

    %% API Gateway forwards requests to Companion Services
    API -->|"RESTForwarding"| Mermaid
    API -->|"RESTForwarding"| BPMN
    API -->|"RESTForwarding"| Excal
    API -->|"RESTForwarding"| Diagrams
    API -->|"RESTForwarding"| Nomnoml
    API -->|"RESTForwarding"| Bytefield
    API -->|"RESTForwarding"| DBML
    API -->|"RESTForwarding"| Vega
    API -->|"RESTForwarding"| Wavedrom

    %% Companion Services send back rendered diagrams to API Gateway
    Mermaid -->|"RenderedDiagram"| API
    BPMN -->|"RenderedDiagram"| API
    Excal -->|"RenderedDiagram"| API
    Diagrams -->|"RenderedDiagram"| API
    Nomnoml -->|"RenderedDiagram"| API
    Bytefield -->|"RenderedDiagram"| API
    DBML -->|"RenderedDiagram"| API
    Vega -->|"RenderedDiagram"| API
    Wavedrom -->|"RenderedDiagram"| API

    %% API Gateway sends HTTP Response back to Client
    API -->|"HTTPResponse"| Client

    %% Integration with Operational Infrastructure
    API ---|"BuiltAndDeployedVia"| Build
    Build ---|"CI/CDTriggers"| CICD
    API --- Docker
    Mermaid --- Docker
    BPMN --- Docker
    Excal --- Docker
    Diagrams --- Docker
    Nomnoml --- Docker
    Bytefield --- Docker
    DBML --- Docker
    Vega --- Docker
    Wavedrom --- Docker

    %% Click Events for Component Mapping
    click API "https://github.com/yuzutech/kroki/tree/main/server/"
    click BPMN "https://github.com/yuzutech/kroki/tree/main/bpmn/"
    click Bytefield "https://github.com/yuzutech/kroki/tree/main/bytefield/"
    click DBML "https://github.com/yuzutech/kroki/tree/main/dbml/"
    click Diagrams "https://github.com/yuzutech/kroki/tree/main/diagrams.net/"
    click Excal "https://github.com/yuzutech/kroki/tree/main/excalidraw/"
    click Mermaid "https://github.com/yuzutech/kroki/tree/main/mermaid/"
    click Nomnoml "https://github.com/yuzutech/kroki/tree/main/nomnoml/"
    click Vega "https://github.com/yuzutech/kroki/tree/main/vega/"
    click Wavedrom "https://github.com/yuzutech/kroki/tree/main/wavedrom/"
    click Build "https://github.com/yuzutech/kroki/blob/main/Taskfile.yml"
    click Build "https://github.com/yuzutech/kroki/tree/main/.mvn/"
    click Build "https://github.com/yuzutech/kroki/blob/main/pom.xml"
    click CICD "https://github.com/yuzutech/kroki/tree/main/.github/workflows/"

    %% Styles
    classDef java fill:#FFCCFF,stroke:#660066,stroke-width:2px;
    classDef node fill:#CCE5FF,stroke:#003366,stroke-width:2px;
    classDef external fill:#CCFFCC,stroke:#006600,stroke-width:2px;
    classDef build fill:#FFD699,stroke:#CC6600,stroke-width:2px;
    classDef cicd fill:#99CCFF,stroke:#3366CC,stroke-width:2px;
```
