# kamranbekirovyz/versionarte architecture

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

- Interactive diagram: https://gitdiagram.com/kamranbekirovyz/versionarte
- Repository: https://github.com/kamranbekirovyz/versionarte

## Overview

##### Project Type and Purpose
- This is a Flutter package designed to integrate with mobile apps, handling update prompts and maintenance notifications.
- Its primary function is to check version status through one of several providers and inform the app whether the user should update forcibly, be warned of an optional update, or if the app is temporarily inactive for maintenance.

##### Analyzing the File Structure
- Top-Level Files: You have typical Flutter package files (pubspec.yaml, README.md, license, etc.).
- The lib directory contains the core API:
- lib/versionarte.dart and lib/src/versionarte.dart are the main entry points.
- lib/src/models holds data models such as DistributionManifest, VersionarteResult, and VersionarteStatus.
- lib/src/providers contains the provider implementations:
- RemoteConfigVersionarteProvider for Firebase remote config integration.
- RestfulVersionarteProvider for fetching data from a RESTful endpoint.
- An abstract VersionarteProvider (inherited by custom implementations).
- lib/src/utilities contains utility helpers like Logger and pretty_json for logging and debugging.
- The example directory illustrates how a client would integrate the package on both Android and iOS, including complete platform-specific setup (e.g., AndroidManifest, Info.plist, build files).

##### Key Components
A. Client App (Flutter Application):
- Represents the host application that imports the versionarte package.
- Initiates version checking by calling Versionarte.check() and then handles the response (forcing updates, showing optional update indicators, or maintenance dialogs).

B. Versionarte Package Core:
- Main Entry Point: Versionarte.check() serves as the primary API call which will be shown as a central component.
- Provider Abstraction: An abstract VersionarteProvider interface which is implemented by:
- RemoteConfigVersionarteProvider (for Firebase-based integration)
- RestfulVersionarteProvider (for a RESTful approach)
- Any potential custom provider (CustomVersionarteProvider in sample code)
- Models: DistributionManifest (holds configuration data from the JSON), VersionarteResult (result of checking), and VersionarteStatus (enum-like status).
- Utilities: Logger and pretty_json to assist in debugging or formatting outputs.

C. External Services:
- Firebase Remote Config: When using RemoteConfigVersionarteProvider the package will interface with Firebase.
- RESTful Service Endpoint: When using the RestfulVersionarteProvider, the package calls an external HTTP/REST API to fetch the configuration JSON.
- Optionally, App Stores (Google Play and Apple App Store) which are used when launching the update URLs.

##### Relationships and Interactions
- The Client App communicates with the Versionarte package via its public API (Versionarte.check()).
- Versionarte.check() delegates to the chosen VersionarteProvider implementation to fetch the configuration detail.
- The provider obtains the configuration JSON (either from Firebase Remote Config, a REST call, or a custom method) and deserializes it into a DistributionManifest.
- Finally, based on the VersionarteStatus (forced update, optional update, or inactive), the client app displays the correct UI (dialogs/indicators) and calls Versionarte.launchDownloadUrl() when an update is needed.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system design cleanly separates theories between configuration fetching (via providers), data modeling, and UI interactions in client apps.
- Dependency Injection / Abstraction: The use of an abstract VersionarteProvider allows for easy swapping between data source implementations.
- Platform-Specific Integration: The example app demonstrates platform-specific configuration (Android and iOS) which is important when deploying on mobile.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Application
    subgraph "Client App"
        A["Client App (Flutter Application)"]:::client
    end

    %% Versionarte Package Core
    subgraph "Versionarte Package Core"
        B["Core API: Versionarte.check() & launchDownloadUrl()"]:::core
        C["Models: DistributionManifest, VersionarteResult, VersionarteStatus"]:::models
        D["Utilities: Logger & pretty_json"]:::utilities
    end

    %% Providers Module inside Versionarte Package
    subgraph "Providers Module"
        E["Abstract VersionarteProvider"]:::providerAbstract
        F["RemoteConfigVersionarteProvider"]:::provider
        G["RestfulVersionarteProvider"]:::provider
        H["CustomVersionarteProvider"]:::provider
    end

    %% External Services
    subgraph "External Services"
        I["Firebase Remote Config"]:::external
        J["RESTful API Endpoint"]:::external
    end

    %% Interactions
    A -->|"calls_Versionarte.check()"| B
    B -->|"delegates_to"| E
    E -->|"implemented_by"| F
    E -->|"implemented_by"| G
    E -->|"implemented_by"| H
    F -->|"fetches_config"| I
    G -->|"fetches_config"| J
    F ---|"deserializes_json"| C
    G ---|"deserializes_json"| C
    C -->|"returns_result"| B
    B -->|"triggers_UI_update"| A

    %% Click Events
    click A "https://github.com/kamranbekirovyz/versionarte/blob/main/example/lib/main.dart"
    click B "https://github.com/kamranbekirovyz/versionarte/blob/main/lib/versionarte.dart"
    click E "https://github.com/kamranbekirovyz/versionarte/blob/main/lib/src/providers/versionarte_provider.dart"
    click F "https://github.com/kamranbekirovyz/versionarte/blob/main/lib/src/providers/remote_config_versionarte_provider.dart"
    click G "https://github.com/kamranbekirovyz/versionarte/blob/main/lib/src/providers/restful_versionarte_provider.dart"
    click C "https://github.com/kamranbekirovyz/versionarte/tree/main/lib/src/models/"
    click D "https://github.com/kamranbekirovyz/versionarte/tree/main/lib/src/utilities/"

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef core fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef models fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef utilities fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;
    classDef providerAbstract fill:#D1C4E9,stroke:#512DA8,stroke-width:2px,stroke-dasharray: 5 5;
    classDef provider fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef external fill:#EEEEEE,stroke:#616161,stroke-width:2px,stroke-dasharray: 3 3;
```
