How asoft-ltd/majestic works
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.