# sophoun/khqr_widget architecture

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

- Interactive diagram: https://gitdiagram.com/sophoun/khqr_widget
- Repository: https://github.com/sophoun/khqr_widget

## Overview

##### Project type and purpose
- This is a Flutter-package (khqr_widget) that provides two reusable QR-code widgets conforming to the Cambodia QR spec. It’s not a stand-alone app or microservice—rather it’s a UI widget library to be consumed by any Flutter application on mobile, desktop, or web.

##### File structure
- Top-level “lib/” folder contains the source API:
- khqr_widget.dart (public export)
- src/khqr_widget.dart (main QR widget)
- src/khqr_stand_widget.dart (alternate layout widget)
- src/scale.dart (layout helpers)
- “example/” holds a full multi-platform Flutter app demonstrating usage.
- Platform folders (android/, ios/, linux/, macos/, windows/, web/) are auto-generated for the example and for plugin support but contain no custom platform‐channel code.
- Configuration files: pubspec.yaml (declares dependencies and metadata), publish.sh (release script), analysis_options.yaml, .gitignore, LICENSE, CHANGELOG.md.

##### README for additional insights
- Describes two widgets (KhqrWidget and KhqrStandWidget), their parameters and callbacks.
- No external services or backends are referenced—everything is pure Dart/UI.

##### Elements
- Clearly labeled nodes for:
– Client App
– khqr_widget Library
– Flutter Framework (Widget → Render → Engine)
– Platform Embedders (Android, iOS, Linux, macOS, Windows, Web)
– Build-time: pub get → asset bundling → compilation
– Runtime: client → library API → widget tree → engine → OS
– Framework layers (another)
– Platform embedders (third)

##### Final Recommendations
- Be as detailed as possible in identifying each layer, but avoid implying any hidden backend or services since this is a pure UI library.
- Two primary flows: build/integration flow (flutter pub → compile → assemble) and runtime/rendering flow (widget invocations → rendering pipeline → native surface).
- Timers (for countdown), asset loading (qrIcon, images), and customization callbacks (onRetry, onCountingDown) as interactions inside the widget library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Build & Integration"
        ExampleApp["Example App Entry (main.dart)"]:::app
        Pub["flutter pub get & compile"]:::framework
        KHQRPKG["khqr_widget Package"]:::package
        ExampleApp -->|"depends on"| KHQRPKG
        Pub --> KHQRPKG
    end

    subgraph "Runtime Flow"
        ExampleAppRT["Client App Runtime"]:::app
        API["khqr_widget.dart API Facade"]:::package
        Impl["KhqrWidget Implementation"]:::package
        Stand["KhqrStandWidget Alternate Layout"]:::package
        Scale["Scale Utilities"]:::package
        WidgetLayer["Widget Layer"]:::framework
        RenderLayer["Rendering Layer"]:::framework
        Engine["Flutter Engine"]:::framework
        ExampleAppRT -->|"imports API"| API
        API -->|"calls Impl"| Impl
        API -->|"calls Stand"| Stand
        Impl -->|"uses"| Scale
        Stand -->|"uses"| Scale
        Impl --> WidgetLayer
        Stand --> WidgetLayer
        WidgetLayer --> RenderLayer
        RenderLayer --> Engine
        Engine -->|"renders to"| Android
        Engine -->|"renders to"| iOS
        Engine -->|"renders to"| macOS
        Engine -->|"renders to"| Windows
        Engine -->|"renders to"| Linux
        Engine -->|"renders to"| Web
    end

    subgraph "Platform Embedders"
        Android["Android Embedder"]:::platform
        iOS["iOS Embedder"]:::platform
        macOS["macOS Embedder"]:::platform
        Windows["Windows Embedder"]:::platform
        Linux["Linux Embedder"]:::platform
        Web["Web Embedder"]:::platform
    end

    subgraph "Configuration & Metadata"
        PSpec["pubspec.yaml"]:::config
        Publish["publish.sh"]:::config
        AO["analysis_options.yaml"]:::config
        CL["CHANGELOG.md"]:::config
        Lic["LICENSE"]:::config
        Test["Widget Library Tests"]:::config
    end

    click ExampleApp "https://github.com/sophoun/khqr_widget/blob/main/example/lib/main.dart"
    click API "https://github.com/sophoun/khqr_widget/blob/main/lib/khqr_widget.dart"
    click Impl "https://github.com/sophoun/khqr_widget/blob/main/lib/src/khqr_widget.dart"
    click Stand "https://github.com/sophoun/khqr_widget/blob/main/lib/src/khqr_stand_widget.dart"
    click Scale "https://github.com/sophoun/khqr_widget/blob/main/lib/src/scale.dart"
    click Android "https://github.com/sophoun/khqr_widget/blob/main/example/android/app/src/main/kotlin/com/sophoun/khqr/example/MainActivity.kt"
    click iOS "https://github.com/sophoun/khqr_widget/blob/main/example/ios/Runner/AppDelegate.swift"
    click macOS "https://github.com/sophoun/khqr_widget/blob/main/example/macos/Runner/AppDelegate.swift"
    click Linux "https://github.com/sophoun/khqr_widget/blob/main/example/linux/main.cc"
    click Windows "https://github.com/sophoun/khqr_widget/blob/main/example/windows/runner/main.cpp"
    click Web "https://github.com/sophoun/khqr_widget/blob/main/example/web/index.html"
    click PSpec "https://github.com/sophoun/khqr_widget/blob/main/pubspec.yaml"
    click Publish "https://github.com/sophoun/khqr_widget/blob/main/publish.sh"
    click AO "https://github.com/sophoun/khqr_widget/blob/main/analysis_options.yaml"
    click CL "https://github.com/sophoun/khqr_widget/blob/main/CHANGELOG.md"
    click Lic "https://github.com/sophoun/khqr_widget/tree/main/LICENSE"
    click Test "https://github.com/sophoun/khqr_widget/blob/main/test/khqr_test.dart"

    classDef app fill:#f9f,stroke:#333,stroke-width:1px;
    classDef package fill:#bbf,stroke:#333,stroke-width:1px;
    classDef framework fill:#bfb,stroke:#333,stroke-width:1px;
    classDef platform fill:#fbf,stroke:#333,stroke-width:1px;
    classDef config fill:#ffd,stroke:#333,stroke-width:1px;
```
