# ronak99/majestic-ui-flutter architecture

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

- Interactive diagram: https://gitdiagram.com/ronak99/majestic-ui-flutter
- Repository: https://github.com/ronak99/majestic-ui-flutter

## Overview

##### Project type and purpose
- This is a monorepo for “Majestic UI”, a Flutter UI widget library plus a CLI tool (`majestic_ui`) that lets developers install and publish individual widgets.
- The repo contains:
- `src/` – a folder of independent Flutter packages (one per widget) ready for publication.
- `app/` – a sample Flutter application that demonstrates all widgets.
- `demo/` – a more focused demo application showcasing each widget in isolation.
- CI workflows under `.github/workflows/` to automate tasks (widget count, widget updates).

##### File structure
- Top‑level:
- `.github/` – CI (GitHub Actions) definitions (`file_count.yml`, `update_all_widgets.yml`)
- `src/` – each widget is a separate Dart package with its own `pubspec.yaml`, `lib/`, docs, and tests.
- `app/` – a full Flutter app (multi-platform: Android, iOS, Linux, macOS, Windows, Web) consuming these packages.
- `demo/` – similar multi‑platform Flutter apps but organized per widget for isolated demos.
- `all_widgets.json` – a manifest of available widgets (used by the CLI).
- Notice the Flutter platform folders under `app/` and `demo/`: Android, iOS, macOS, Linux, Windows, Web.

##### Readme insights
- Confirms: Majestic UI is a “Flutter UI library/collection of widgets.”
- CLI command: `dart pub global activate majestic_ui` and `majestic_ui add <widget>`
- CI ensures widget metadata is up to date.

##### Main components
a. Developer Workstation
- Terminal/CLI (`majestic_ui`)
- Local Monorepo Clone
b. Monorepo (GitHub)
- `src/` – individual widget packages
- `app/` – sample app
- `demo/` – widget demos
- CI (GitHub Actions)
c. Pub.dev (Dart package registry)
d. Flutter Engine / Platform Runtimes
- iOS, Android, Web, macOS, Windows, Linux
e. Documentation Site (majesticui.com)

##### Relationships & data flows
- Developer uses the CLI to:
1. Read `all_widgets.json` from the repo (or remote manifest)
2. `majestic_ui add <widget>` → CLI fetches that widget’s package from `src/<widget>` (locally) or from Pub.dev (if published)
3. Inserts code/asset files into the developer’s own project
- CI workflow:
- `file_count.yml` reads `src/` folders → updates `all_widgets.json`
- `update_all_widgets.yml` can publish packages to Pub.dev or push updates to docs
- Sample apps (`app/`, `demo/`) import packages from `src/` (path dependencies) to render demos on multiple platforms.
- Documentation site (external) pulls metadata from the manifest or the GitHub repo.

##### Architectural patterns & design principles
- Monorepo of loosely coupled packages – each widget is independently versioned and tested.
- CLI-driven workflow – manifests drive code scaffolding.
- Platform abstraction via Flutter – single codebase runs on 6 platforms.
- CI automation – keeps manifest and publications in sync.

##### Final advice
- Be very detailed: list each major folder as a sub‑component.
- CI workflows and how they feed into the manifest and publishing.
- How one source widget (e.g., `src/star_rush_background`) flows through CLI, into demo, into a real app, and ultimately to end‑users via Pub.dev.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workstation
    subgraph "Developer Workstation"
        CLI["majestic_ui CLI"]:::dev
    end

    %% Monorepo Components
    subgraph "Monorepo (GitHub)" 
        Manifest["all_widgets.json"]:::repo

        subgraph "Package Layer"
            PKG1["auth_page pkg"]:::repo
            PKG2["star_rush_background pkg"]:::repo
        end

        subgraph "Demo Layer"
            Demo1["star_rush_background_demo"]:::dev
            Demo2["user_feed_demo"]:::dev
            subgraph "Demo Majestic UI Imports"
                IMPORT1["auth_page.dart"]:::repo
                IMPORT2["categories_page.dart"]:::repo
            end
            subgraph "Demo Platform Folders"
                DPLAT1["Android"]:::platform
                DPLAT2["iOS"]:::platform
                DPLAT3["Linux"]:::platform
                DPLAT4["macOS"]:::platform
                DPLAT5["Windows"]:::platform
                DPLAT6["Web"]:::platform
            end
        end

        subgraph "Sample App"
            AppMain["main.dart"]:::dev
            AppRouter["router.dart"]:::dev
            subgraph "App Platform Folders"
                PLAT1["Android"]:::platform
                PLAT2["iOS"]:::platform
                PLAT3["Linux"]:::platform
                PLAT4["macOS"]:::platform
                PLAT5["Windows"]:::platform
                PLAT6["Web"]:::platform
            end
        end

        subgraph "CI Workflows"
            CI1["file_count.yml"]:::ci
            CI2["update_all_widgets.yml"]:::ci
        end
    end

    %% External Services
    PubDev["Pub.dev Registry"]:::ext
    Docs["Documentation Site"]:::ext

    %% Flutter Engine & Platforms
    FlutterEngine["Flutter Engine"]:::platform

    %% Relationships
    CLI -->|reads manifest| Manifest
    CLI -->|fetch widget| PKG1
    CLI -->|fetch widget| PKG2
    CLI -->|scaffolds code| DeveloperProject["Developer Project"]:::dev

    CI1 -->|updates manifest| Manifest
    CI2 -->|publishes packages| PubDev

    Docs -->|pulls manifest| Manifest

    Demo1 -->|imports pkg| PKG2
    Demo2 -->|imports pkg| PKG1
    IMPORT1 -->|source| PKG1
    IMPORT2 -->|source| PKG2

    AppMain -->|imports pkg| PKG1
    AppMain -->|imports pkg| PKG2
    AppRouter -->|routes| AppMain

    AppMain --> FlutterEngine
    Demo1 --> FlutterEngine
    Demo2 --> FlutterEngine

    FlutterEngine --> PLAT1
    FlutterEngine --> PLAT2
    FlutterEngine --> PLAT3
    FlutterEngine --> PLAT4
    FlutterEngine --> PLAT5
    FlutterEngine --> PLAT6

    %% Click Events
    click Manifest "https://github.com/ronak99/majestic-ui-flutter/blob/master//all_widgets.json"
    click CI1 "https://github.com/ronak99/majestic-ui-flutter/blob/master//.github/workflows/file_count.yml"
    click CI2 "https://github.com/ronak99/majestic-ui-flutter/blob/master//.github/workflows/update_all_widgets.yml"
    click PKG1 "https://github.com/ronak99/majestic-ui-flutter/blob/master//src/auth_page/pubspec.yaml"
    click PKG2 "https://github.com/ronak99/majestic-ui-flutter/blob/master//src/star_rush_background/pubspec.yaml"
    click AppMain "https://github.com/ronak99/majestic-ui-flutter/blob/master//app/lib/main.dart"
    click AppRouter "https://github.com/ronak99/majestic-ui-flutter/blob/master//app/lib/router/router.dart"
    click Demo1 "https://github.com/ronak99/majestic-ui-flutter/blob/master//demo/lib/star_rush_background_demo.dart"
    click Demo2 "https://github.com/ronak99/majestic-ui-flutter/blob/master//demo/lib/user_feed_demo.dart"
    click IMPORT1 "https://github.com/ronak99/majestic-ui-flutter/blob/master//demo/lib/majestic/ui/auth_page/auth_page.dart"
    click IMPORT2 "https://github.com/ronak99/majestic-ui-flutter/blob/master//demo/lib/majestic/ui/categories_page/categories_page.dart"
    click PLAT1 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/android"
    click PLAT2 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/ios"
    click PLAT3 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/linux"
    click PLAT4 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/macos"
    click PLAT5 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/windows"
    click PLAT6 "https://github.com/ronak99/majestic-ui-flutter/tree/master//app/web"
    click DPLAT1 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/android"
    click DPLAT2 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/ios"
    click DPLAT3 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/linux"
    click DPLAT4 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/macos"
    click DPLAT5 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/windows"
    click DPLAT6 "https://github.com/ronak99/majestic-ui-flutter/tree/master//demo/web"

    %% Styles
    classDef dev fill:#a2f5a0,stroke:#333,stroke-width:1px
    classDef repo fill:#9ecbf8,stroke:#333,stroke-width:1px
    classDef ci fill:#f5d27e,stroke:#333,stroke-width:1px
    classDef ext fill:#d0a2f5,stroke:#333,stroke-width:1px
    classDef platform fill:#c0c0c0,stroke:#333,stroke-width:1px
```
