# asoft-ltd/majestic architecture

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

- Interactive diagram: https://gitdiagram.com/asoft-ltd/majestic
- Repository: https://github.com/asoft-ltd/majestic

## Overview

##### Project type and purpose
- Majestic is a Kotlin Multiplatform library of reusable UI components (Compose-style widgets) organized into domain-specific modules (drawers, graphs, inputs, overlays, etc.).
- Its goal is to let consumers mix-and-match UI building blocks across targets (Android, desktop, web via JS) with a shared core and theme.

##### File structure
- Root: build.gradle.kts, settings.gradle.kts, gradle wrapper → a multi-module Gradle KMM project.
- Top-level modules (each with its own build.gradle.kts):
– drawers, graphs, loaders, overlays, table, theme, screen, kotlin-js-store
- Each module uses commonMain for shared code; some (screen) add androidMain, jvmMain, skikoMain for platform-specific implementations.

- Layer 1 – Build & Publishing
– Gradle Kotlin DSL orchestrates module compilation, Kotlin Multiplatform targets, publishing to Maven/JS packages.
- Layer 2 – Core & Theme Foundations
– input/core: basic interactive controls (buttons, toggle, editor chunks).
– screen: device and window metrics, orientation abstraction for layout adaptivity.
- Layer 3 – Widget Modules
– drawers, overlays, loaders, graphs, table: higher-order UI components that depend on core & theme.
- Layer 4 – Specialized Input Modules
- Layer 5 – Platform Adapters & Targets
– screen/androidMain, screen/jvmMain, screen/skikoMain for platform glue.
– kotlin-js-store (empty folder suggests JS-targeted utilities or state store).

##### Dependencies & Interactions
- theme → core → specialized input & widget modules.
- screen provides runtime context (DP/PX, orientation) to all modules.
- input modules depend on core + theme + screen.
- build module (kotlin-js-store) produces an NPM/JS artifact that ties into a web app’s state management.

##### Architectural patterns and principles
- Layered modular architecture: clear separation of concerns (foundation, theme, widgets, domain inputs).
- Dependency inversion: high-level widgets depend on abstract core interfaces, allowing theme and platform to plug in.
- Multiplatform abstraction: commonMain code in each module, with thin platform-specific sources for runtime details.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Build & Publishing"
        BuildGradle["build.gradle.kts"]:::build
        Settings["settings.gradle.kts"]:::build
    end

    subgraph "Foundation"
        Theme["theme"]:::foundation
        Core["core"]:::foundation
        Screen["screen"]:::foundation
    end

    subgraph "Widget Modules"
        Drawers["drawers"]:::widgets
        Overlays["overlays"]:::widgets
        Loaders["loaders"]:::widgets
        Graphs["graphs"]:::widgets
        Table["table"]:::widgets
    end

    subgraph "Input Modules"
        Choice["choice"]:::inputs
        Text["text"]:::inputs
        Chrono["chrono"]:::inputs
        Color["color"]:::inputs
        Phone["phone"]:::inputs
    end

    JSStore["kotlin-js-store"]:::build

    subgraph "Platform Targets"
        Android["Android"]:::platform
        JVM["JVM"]:::platform
        Skiko["Skiko"]:::platform
        JS["JS"]:::platform
    end

    Settings -->|module registry| BuildGradle
    BuildGradle -->|orchestrates| Theme
    BuildGradle -->|orchestrates| Core
    BuildGradle -->|orchestrates| Screen
    BuildGradle -->|builds| Drawers
    BuildGradle -->|builds| Overlays
    BuildGradle -->|builds| Loaders
    BuildGradle -->|builds| Graphs
    BuildGradle -->|builds| Table
    BuildGradle -->|builds| Choice
    BuildGradle -->|builds| Text
    BuildGradle -->|builds| Chrono
    BuildGradle -->|builds| Color
    BuildGradle -->|builds| Phone
    BuildGradle -->|publishes| JSStore

    Theme -->|provides styles to| Core
    Core -->|foundation for| Drawers
    Core -->|foundation for| Overlays
    Core -->|foundation for| Loaders
    Core -->|foundation for| Graphs
    Core -->|foundation for| Table
    Core -->|foundation for| Choice
    Core -->|foundation for| Text
    Core -->|foundation for| Chrono
    Core -->|foundation for| Color
    Core -->|foundation for| Phone

    Theme -->|styles used by| Drawers
    Theme -->|styles used by| Overlays
    Theme -->|styles used by| Loaders
    Theme -->|styles used by| Graphs
    Theme -->|styles used by| Table
    Theme -->|styles used by| Choice
    Theme -->|styles used by| Text
    Theme -->|styles used by| Chrono
    Theme -->|styles used by| Color
    Theme -->|styles used by| Phone

    Screen -->|context to| Drawers
    Screen -->|context to| Overlays
    Screen -->|context to| Loaders
    Screen -->|context to| Graphs
    Screen -->|context to| Table
    Screen -->|context to| Choice
    Screen -->|context to| Text
    Screen -->|context to| Chrono
    Screen -->|context to| Color
    Screen -->|context to| Phone

    Screen -->|androidMain| Android
    Screen -->|jvmMain| JVM
    Screen -->|skikoMain| Skiko
    JSStore -->|targets JS| JS

    click BuildGradle "https://github.com/asoft-ltd/majestic/blob/main/build.gradle.kts"
    click Settings "https://github.com/asoft-ltd/majestic/blob/main/settings.gradle.kts"

    click Core "https://github.com/asoft-ltd/majestic/blob/main/input/core/build.gradle.kts"
    click Core "https://github.com/asoft-ltd/majestic/tree/main/input/core/src/commonMain/kotlin/majestic"

    click Theme "https://github.com/asoft-ltd/majestic/blob/main/theme/build.gradle.kts"
    click Theme "https://github.com/asoft-ltd/majestic/blob/main/theme/src/commonMain/kotlin/majestic/ThemeEngine.kt"
    click Theme "https://github.com/asoft-ltd/majestic/tree/main/theme/src/commonMain/kotlin/majestic/colors"

    click Screen "https://github.com/asoft-ltd/majestic/blob/main/screen/build.gradle.kts"
    click Screen "https://github.com/asoft-ltd/majestic/tree/main/screen/src/commonMain/kotlin/composex/screen"
    click Screen "https://github.com/asoft-ltd/majestic/tree/main/screen/src/commonMain/kotlin/majestic/config"

    click Drawers "https://github.com/asoft-ltd/majestic/blob/main/drawers/build.gradle.kts"
    click Drawers "https://github.com/asoft-ltd/majestic/tree/main/drawers/src/commonMain/kotlin/majestic/drawer"

    click Overlays "https://github.com/asoft-ltd/majestic/blob/main/overlays/build.gradle.kts"
    click Overlays "https://github.com/asoft-ltd/majestic/tree/main/overlays/src/commonMain/kotlin/majestic"

    click Loaders "https://github.com/asoft-ltd/majestic/blob/main/loaders/build.gradle.kts"
    click Loaders "https://github.com/asoft-ltd/majestic/tree/main/loaders/src/commonMain/kotlin/majestic/loaders"

    click Graphs "https://github.com/asoft-ltd/majestic/blob/main/graphs/build.gradle.kts"
    click Graphs "https://github.com/asoft-ltd/majestic/tree/main/graphs/src/commonMain/kotlin/majestic/graph"

    click Table "https://github.com/asoft-ltd/majestic/blob/main/table/build.gradle.kts"
    click Table "https://github.com/asoft-ltd/majestic/tree/main/table/src/commonMain/kotlin/majestic"

    click Choice "https://github.com/asoft-ltd/majestic/blob/main/input/choice/build.gradle.kts"
    click Choice "https://github.com/asoft-ltd/majestic/tree/main/input/choice/src/commonMain/kotlin/majestic"

    click Text "https://github.com/asoft-ltd/majestic/blob/main/input/text/build.gradle.kts"
    click Text "https://github.com/asoft-ltd/majestic/tree/main/input/text/src/commonMain/kotlin/majestic"

    click Chrono "https://github.com/asoft-ltd/majestic/blob/main/input/chrono/build.gradle.kts"
    click Chrono "https://github.com/asoft-ltd/majestic/tree/main/input/chrono/src/commonMain/kotlin/majestic/calendar"

    click Color "https://github.com/asoft-ltd/majestic/blob/main/input/color/build.gradle.kts"
    click Color "https://github.com/asoft-ltd/majestic/tree/main/input/color/src/commonMain/kotlin/majestic"

    click Phone "https://github.com/asoft-ltd/majestic/blob/main/input/phone/build.gradle.kts"
    click Phone "https://github.com/asoft-ltd/majestic/tree/main/input/phone/src/commonMain/kotlin/majestic"

    click JSStore "https://github.com/asoft-ltd/majestic/tree/main/kotlin-js-store"

    click Android "https://github.com/asoft-ltd/majestic/tree/main/screen/src/androidMain/kotlin/composex/screen"
    click JVM "https://github.com/asoft-ltd/majestic/tree/main/screen/src/jvmMain/kotlin/majestic/config"
    click Skiko "https://github.com/asoft-ltd/majestic/tree/main/screen/src/skikoMain/kotlin/composex/screen"

    classDef foundation fill:#cfe2f3,stroke:#333,stroke-width:1px
    classDef widgets fill:#d9ead3,stroke:#333,stroke-width:1px
    classDef inputs fill:#f9cb9c,stroke:#333,stroke-width:1px
    classDef build fill:#d9d9d9,stroke:#333,stroke-width:1px
    classDef platform fill:#ececec,stroke:#333,stroke-width:1px
```
