# iampawan/flutter-ui-kit architecture

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

- Interactive diagram: https://gitdiagram.com/iampawan/flutter-ui-kit
- Repository: https://github.com/iampawan/flutter-ui-kit

## Overview

##### Project type and purpose
- This is a cross‐platform Flutter mobile UI‐kit, intended to showcase a clean, well‐organized Flutter codebase and a collection of real‐world UI templates (login, shopping, profile, dashboard, timeline, payment, settings, etc.). There is no backend server in this repo; it is purely a front‐end demonstration with mock/real service stubs.

##### File structure
- Top-level “android” and “ios” folders contain the native wrappers and build scripts for each platform.
- The entire Dart code lives under “lib/”, subdivided into:
- di/ (dependency injection setup)
- inherited/ (InheritedWidget providers)
- logic/ (BLoC and ViewModel layers)
- model/ (data structures)
- services/ (abstract interfaces, mock and real implementations, network service, REST client)
- ui/ (widget and page tree for all templates)
- utils/ (translations, constants)
- Assets (fonts, images) and locale JSON files for i18n under “assets/” and “locale/”.

##### README for additional insights
- Confirms the focus is on UI templates and showcases proper project structure.
- Mentions no real backend, but does include OTP services (mock and real) via an abstract interface.

##### Main components
a. Mobile Platform Layer
- Android wrapper
- iOS wrapper
- Flutter Engine
b. UI Layer
- Widget tree (pages under lib/ui/page)
- Shared widgets (lib/ui/widgets & tools)
c. State & Presentation Layer
- BLoC components (lib/logic/bloc/*.dart)
- ViewModels (lib/logic/viewmodel/*.dart)
- InheritedWidget providers (lib/inherited/*.dart)
d. Dependency Injection
- di container (lib/di/dependency_injection.dart)
e. Service Layer
- Abstract interfaces (lib/services/abstract)
- Mock implementations (lib/services/mock)
- Real implementations (lib/services/real)
- NetworkService & RestClient (lib/services/network_service.dart & restclient.dart)
f. Data Layer
- Models (lib/model/*.dart)
- FetchProcess (error/response wrapper)
g. Assets & Localization
- Fonts/images under assets/
- i18n JSON under locale/
h. External APIs
- OTP service endpoints (real OTP service)
- Any REST endpoints consumed via RestClient

##### Relationships and interactions
- The UI Widgets call into BLoCs or ViewModels to fetch/update state.
- BLoCs/ViewModels request services through interfaces; DI container injects either mock or real service.
- Services use NetworkService/RestClient to make HTTP calls to external endpoints.
- Responses are parsed into Model objects, returned back up to BLoC/ViewModel, which pushes new state to UI.
- InheritedWidget providers wrap subtrees to allow deep access to shared state.
- Localization utility loads JSON files based on current locale and provides translation maps to widgets.

##### Architectural patterns and design principles
- MVVM / BLoC for state management and separation of concerns.
- Dependency Injection for swapping mock vs real services.
- Layered architecture: UI → Presentation → Services → Data.
- Use of InheritedWidget for global state or context.
- Asset management and i18n for scalability.

##### Final advice
- Be very detailed: map out each page/template group as a sub-component if needed.
- How DI wires up abstract interfaces to concrete implementations.
- Localization as a cross-cutting concern feeding into UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Platform Layer
    subgraph "Mobile Platform Layer"
        direction TB
        AndroidWrapper["Android Wrapper"]:::platform
        iOSWrapper["iOS Wrapper"]:::platform
    end

    FlutterEngine["Flutter Engine"]:::engine

    AndroidWrapper --> FlutterEngine
    iOSWrapper --> FlutterEngine

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Pages["Pages (lib/ui/page/)"]:::ui
        Widgets["Shared Widgets (lib/ui/widgets/ & lib/ui/tools/)"]:::ui
    end

    FlutterEngine --> UIContainer["App Entry (lib/main.dart & lib/myapp.dart)"]:::engine
    UIContainer --> Pages
    UIContainer --> Widgets

    %% State & Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Blocs["BLoC Components (lib/logic/bloc/)"]:::presentation
        ViewModels["ViewModels (lib/logic/viewmodel/)"]:::presentation
        Providers["InheritedWidget Providers"]:::presentation
    end

    Pages --> Blocs
    Pages --> ViewModels
    Widgets --> Providers

    %% Dependency Injection
    DI["DI Container (lib/di/dependency_injection.dart)"]:::di

    Blocs -->|"injects services via"| DI
    ViewModels -->|"injects services via"| DI

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        IOTP["IOTPService Interface\n(lib/services/abstract/i_otp_service.dart)"]:::service
        MockOTP["MockOTPService\n(lib/services/mock/mock_otp_service.dart)"]:::service
        RealOTP["RealOTPService\n(lib/services/real/real_otp_service.dart)"]:::service
        NetworkService["NetworkService\n(lib/services/network_service.dart)"]:::service
        RestClient["RestClient\n(lib/services/restclient.dart)"]:::service
    end

    DI -->|"binds to"| IOTP
    IOTP --> MockOTP
    IOTP --> RealOTP
    MockOTP --> NetworkService
    RealOTP --> RestClient
    NetworkService --> RestClient

    %% External API
    ExternalOTP["OTP Service Endpoint"]:::external
    RestClient -->|"HTTP call"| ExternalOTP

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Models["Models\n(lib/model/)"]:::data
        FetchProc["FetchProcess Wrapper\n(lib/model/fetch_process.dart)"]:::data
    end

    MockOTP -->|"returns models"| Models
    RealOTP -->|"returns models"| Models
    Models --> FetchProc
    FetchProc --> Blocs
    FetchProc --> ViewModels

    %% Assets & Localization
    subgraph "Assets & Localization"
        direction TB
        Fonts["Fonts\n(assets/fonts/)"]:::assets
        Images["Images\n(assets/images/)"]:::assets
        Locale["i18n JSON\n(locale/i18n_en.json & locale/i18n_hi.json)"]:::assets
    end

    Fonts --> Pages
    Images --> Pages
    Locale --> Pages

    %% Click Events
    click AndroidWrapper "https://github.com/iampawan/flutter-ui-kit/tree/master/android/"
    click iOSWrapper "https://github.com/iampawan/flutter-ui-kit/tree/master/ios/"
    click UIContainer "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/main.dart"
    click UIContainer "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/myapp.dart"
    click Pages "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/ui/page/"
    click Widgets "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/ui/widgets/"
    click Widgets "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/ui/tools/"
    click Blocs "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/logic/bloc/"
    click ViewModels "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/logic/viewmodel/"
    click Providers "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/inherited/login_provider.dart"
    click Providers "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/inherited/product_provider.dart"
    click DI "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/di/dependency_injection.dart"
    click IOTP "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/services/abstract/i_otp_service.dart"
    click MockOTP "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/services/mock/mock_otp_service.dart"
    click RealOTP "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/services/real/real_otp_service.dart"
    click NetworkService "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/services/network_service.dart"
    click RestClient "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/services/restclient.dart"
    click Models "https://github.com/iampawan/flutter-ui-kit/tree/master/lib/model/"
    click FetchProc "https://github.com/iampawan/flutter-ui-kit/blob/master/lib/model/fetch_process.dart"
    click Fonts "https://github.com/iampawan/flutter-ui-kit/tree/master/assets/fonts/"
    click Images "https://github.com/iampawan/flutter-ui-kit/tree/master/assets/images/"
    click Locale "https://github.com/iampawan/flutter-ui-kit/blob/master/locale/i18n_en.json"
    click Locale "https://github.com/iampawan/flutter-ui-kit/blob/master/locale/i18n_hi.json"

    %% Styles
    classDef platform fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef engine fill:#f0f8ff,stroke:#333,stroke-width:1px
    classDef ui fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef di fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef assets fill:#F5F5F5,stroke:#333,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#000,stroke-dasharray: 5 5
```
