# sureshg/kotlin-mpp-playground architecture

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

- Interactive diagram: https://gitdiagram.com/sureshg/kotlin-mpp-playground
- Repository: https://github.com/sureshg/kotlin-mpp-playground

## Overview

##### Project type and purpose
- This is a Kotlin Multiplatform Playground: a single Gradle multi‐project repository demonstrating JVM (Ktor) backend services, JS/WASM web front-ends, Compose desktop & web UIs, native binaries, agents, profiling, security modules, CLI tools, and meta-components (compiler plugin, KSP processor).
- Its purpose is to showcase Kotlin MPP targets, platform‐specific modules, shared business logic, and end-to-end flows (from HTTP clients to database and observability).

##### File structure
- Top-level “backend” folder contains multiple subprojects:
- agent (JFR & OTEL Java agents)
- boot (Ktor application, SQL schema)
- data (data-generation tooling)
- jvm (Ktor server with routes, plugins, OpenAPI, templates)
- native (Kotlin/Native HTTP server)
- profiling (JFR/profiling utilities)
- security (TLS, TrustStore, cert scanning, password gen)
- “shared” is the cross-platform library used by backend, web, compose, native, etc.
- “web” holds Kotlin/JS and WASM web clients (HTTP + xterm + playground).
- “compose” houses Compose Multiplatform subprojects: CLI, desktop (cmp), HTML (via Kobweb).
- “benchmark” uses Kotlinx-benchmark over the shared core.
- “meta” holds build-time plugins: a compiler plugin and a KSP processor.
- “dep-mgmt” defines your BOM and catalog modules.
- Gradle build logic under “gradle/build-logic” and GitHub Actions under “.github”.

##### README for additional insights
- Multiplatform targets: JVM, JS, WASM, Native, Desktop, Web.
- Build & run instructions, containerization, GraalVM native image, OpenTelemetry, JVM agents, AOT, tests, benchmarking, publishing.

- Front-ends → Backend → Database
- Backend ↔ Agents/Profiling → OTEL Collector
- Build Infra → All modules (Gradle triggers build, GitHub Actions runs workflows)
- Green for shared libraries
- Orange for build-time infra (Gradle, meta plugins)
- Red for external services (OTEL, DB, Grafana)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Shared Core
    subgraph "Shared & Core"
        Shared["Shared Core Library"]:::shared
    end

    %% Runtime Modules
    subgraph "Runtime Modules"
        subgraph Backend
            Boot["Ktor Boot Module"]:::runtime
            JVM["JVM Ktor Server"]:::runtime
            Data["Data Generation Tooling"]:::runtime
            Security["Security Module"]:::runtime
            Profiling["Profiling Utilities"]:::runtime
            JFRAgent["JFR Java Agent"]:::runtime
            OTELAgent["OpenTelemetry Java Agent"]:::runtime
            NativeServer["Native HTTP Server"]:::runtime
        end
        subgraph Frontends
            WebClient["Web Client (JS & WASM)"]:::runtime
            CLI["Compose CLI Tool"]:::runtime
            Desktop["Compose Desktop UI"]:::runtime
            WebUI["Compose Web UI"]:::runtime
        end
        Benchmark["Benchmarking Harness"]:::runtime
    end

    %% Observability & Deployment
    subgraph "Observability & Deployment"
        DB[(Database)]:::external
        OTELCollector[(OpenTelemetry Collector)]:::external
        Grafana[(Grafana & Prometheus)]:::external
    end

    %% Build-time Infrastructure
    subgraph "Build-time Infrastructure"
        Gradle["Gradle Build Logic"]:::build
        GHActions["GitHub Actions Workflows"]:::build
        BOM["Dependency Management (BOM)"]:::build
        Catalog["Dependency Management (Catalog)"]:::build
        CompilerPlugin["Kotlin Compiler Plugin"]:::build
        KSPProcessor["KSP Processor"]:::build
        OTelScripts["Observability Scripts & Config"]:::build
    end

    %% Relationships
    WebClient -->|"HTTP" | JVM
    CLI -->|"CLI Invoke"| JVM
    Desktop -->|"HTTP" | JVM
    WebUI -->|"Static Assets"| JVM
    NativeServer -->|"HTTP" | Shared
    JVM -->|"uses" | Shared
    WebClient -->|"uses" | Shared
    CLI -->|"uses" | Shared
    Desktop -->|"uses" | Shared
    WebUI -->|"uses" | Shared
    Benchmark -->|"measures"| Shared

    JVM -->|"SQL" | Data
    Data -->|"reads/writes"| DB
    JVM -->|"TLS/Auth"| Security
    JVM -->|"JFR Hooks"| Profiling
    Profiling -->|"OTLP"| OTELCollector
    JFRAgent -->|"JFR"| JVM
    OTELAgent -->|"OTLP"| JVM
    JFRAgent -->|"OTLP"| OTELCollector
    OTELAgent -->|"OTLP"| OTELCollector
    OTELCollector -->|"metrics/logs"| Grafana

    %% Build infra connections
    GHActions -->|"runs"| Gradle
    Gradle -->|"build/triggers"| Boot
    Gradle -->|"build/triggers"| JVM
    Gradle -->|"build/triggers"| Data
    Gradle -->|"build/triggers"| Security
    Gradle -->|"build/triggers"| Profiling
    Gradle -->|"build/triggers"| JFRAgent
    Gradle -->|"build/triggers"| OTELAgent
    Gradle -->|"build/triggers"| NativeServer
    Gradle -->|"build/triggers"| WebClient
    Gradle -->|"build/triggers"| CLI
    Gradle -->|"build/triggers"| Desktop
    Gradle -->|"build/triggers"| WebUI
    Gradle -->|"build/triggers"| Benchmark
    Gradle -->|"uses"| BOM
    Gradle -->|"uses"| Catalog
    Gradle -->|"applies"| CompilerPlugin
    Gradle -->|"applies"| KSPProcessor
    Gradle -->|"configures"| OTelScripts

    %% Click events
    click Shared "https://github.com/sureshg/kotlin-mpp-playground/tree/main/shared"
    click Boot "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/boot"
    click JVM "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/jvm"
    click Data "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/data"
    click Security "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/security"
    click Profiling "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/profiling"
    click JFRAgent "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/agent/jfr"
    click OTELAgent "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/agent/otel"
    click NativeServer "https://github.com/sureshg/kotlin-mpp-playground/tree/main/backend/native"
    click WebClient "https://github.com/sureshg/kotlin-mpp-playground/tree/main/web"
    click CLI "https://github.com/sureshg/kotlin-mpp-playground/tree/main/compose/cli"
    click Desktop "https://github.com/sureshg/kotlin-mpp-playground/tree/main/compose/cmp"
    click WebUI "https://github.com/sureshg/kotlin-mpp-playground/tree/main/compose/html"
    click Benchmark "https://github.com/sureshg/kotlin-mpp-playground/tree/main/benchmark"
    click BOM "https://github.com/sureshg/kotlin-mpp-playground/tree/main/dep-mgmt/bom"
    click Catalog "https://github.com/sureshg/kotlin-mpp-playground/tree/main/dep-mgmt/catalog"
    click Gradle "https://github.com/sureshg/kotlin-mpp-playground/tree/main/gradle/build-logic"
    click GHActions "https://github.com/sureshg/kotlin-mpp-playground/tree/main/.github/workflows"
    click CompilerPlugin "https://github.com/sureshg/kotlin-mpp-playground/tree/main/meta/compiler/plugin"
    click KSPProcessor "https://github.com/sureshg/kotlin-mpp-playground/tree/main/meta/ksp/processor"
    click OTelScripts "https://github.com/sureshg/kotlin-mpp-playground/tree/main/meta/scripts/otel"

    %% Styles
    classDef runtime fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef shared fill:#90EE90,stroke:#000,stroke-width:1px
    classDef build fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#FF6347,stroke:#000,stroke-width:1px
```
