# roshan9419/sortlizer architecture

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

- Interactive diagram: https://gitdiagram.com/roshan9419/sortlizer
- Repository: https://github.com/roshan9419/sortlizer

## Overview

##### Project Type and Purpose
- Its primary purpose is to provide interactive visualizations for various sorting techniques, along with algorithm information, customizations, and performance history during a session.

##### Main Components to Identify
- Flutter UI Layer:
- Views: The various UI screens (home_view, onboarding_view, settings_view, visualizer_view, sorting_detailed_view, etc.) present in lib/ui/views.
- Widgets: Custom widgets such as bars_loader, custom_rect_btn, code_viewer, sorting_history, etc., located in lib/ui/widgets.
- UI Themes & Dialogs: Theme setups and dialog elements (custom_input_dialog, confirmation_dialog, etc.) from lib/ui.
- MVVM Architecture Components:
- ViewModels: Each view has a corresponding viewmodel (e.g., home_viewmodel, settings_viewmodel, sorting_detailed_viewmodel, and visualizer_viewmodel).
- Views: Directly associated with viewmodels.
- Services and Business Logic:
- Services: Handling shared preferences, third-party integrations, etc., in lib/services.
- Utility Classes: Such as sorting_color_schemes and other utility functions found in lib/utils.
- Data Models:
- Sorting-Specific Models: The datamodels for various sorting attributes (algo_history_track, algorithmType, barType, etc.) found in lib/datamodels.
- Dependency Injection & Routing:
- Dependency Injection: The locator (lib/app/locator.dart) and its configuration (locator.config.dart) that wire up dependencies using get_it/injectable.
- Routing: Defining the navigation structure using auto_route and stacked_services (files like router.dart and router.router.dart in lib/app).

##### Relationships and Interactions
- UI Layer (Views) communicates with their corresponding ViewModels for user actions and display updates.
- ViewModels interact with Services (e.g., shared preference service, third-party services) to retrieve and update data.
- The data models are used both in the UI layer (for visualization) and within services to store the state (like sorting history).
- Dependency injection ensures that all of these components (services, models, viewmodels) are provided consistently and are decoupled.
- Routing is used to transition between views and is central to the navigation flow.

##### Architectural Patterns and Design Principles
- Dependency Injection (IoC) using a locator pattern: Make note of how get_it/injectable is used to manage dependencies.
- Use of auto_route: Emphasize the navigation component.
- Flutter’s Widget Tree: Illustrate how the UI components (views, widgets) build upon one another.
- Multi-platform Layers: While the core logic is in Flutter (lib directory), the project also contains native, platform-specific folders (android, ios, linux, macos, windows) that bootstrap the Flutter engine and integrate platform-specific assets and configurations.

- Components should be clearly labeled. For instance:
- "Views" with subcomponents like HomeView, SettingsView, etc.
- "ViewModels" corresponding to each view.
- "Services" such as ThirdPartyServices and SharedPreferenceService.
- "Models" representing sorting algorithms and history.
- "DI Container" for dependency injection and "Router" for navigation.
- From user interaction in the view -> ViewModel processes -> Calls Services -> Updates Models -> Reflects changes back to the views.
- Between DI container providing dependencies to viewmodels and services.
- Navigation flows mediated by Router.
- Rectangles for high-level layers (UI, Business Logic, Data Models).
- Ovals for utility components like dependency injection or configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Sortlizer App"):::app

    subgraph "Core Flutter Modules"
        subgraph "UI Layer"
            a1("Views"):::ui
            a2("Widgets"):::ui
            a3("Themes"):::ui
            a4("Dialogs"):::ui
        end
        subgraph "Presentation Layer"
            b1("ViewModels"):::presentation
        end
        subgraph "Business Logic"
            c1("Services"):::business
            c2("Utility Classes"):::business
        end
        subgraph "Data Models"
            d1("Data Models"):::models
        end
        subgraph "Infrastructure"
            e1("DI Container"):::infra
            e2("Router"):::infra
        end
    end

    subgraph "Native Platforms"
        n1("Android"):::native
        n2("iOS"):::native
        n3("Linux"):::native
        n4("macOS"):::native
        n5("Windows"):::native
    end

    %% Connections between components
    A --> a1
    a1 -->|"interaction"| b1
    b1 -->|"calls"| c1
    c1 -->|"updates"| d1
    c2 -->|"supports"| c1
    e1 -->|"injects"| b1
    e1 -->|"injects"| c1
    e2 -->|"navigates"| a1

    %% Connections to native platforms
    A --> n1
    A --> n2
    A --> n3
    A --> n4
    A --> n5

    %% Click Events
    click a1 "https://github.com/roshan9419/sortlizer/tree/master/lib/ui/views"
    click a2 "https://github.com/roshan9419/sortlizer/tree/master/lib/ui/widgets"
    click a3 "https://github.com/roshan9419/sortlizer/blob/master/lib/ui/theme_setup.dart"
    click a4 "https://github.com/roshan9419/sortlizer/tree/master/lib/ui/dialogs"
    click b1 "https://github.com/roshan9419/sortlizer/tree/master/lib/ui/views"
    click c1 "https://github.com/roshan9419/sortlizer/tree/master/lib/services"
    click c2 "https://github.com/roshan9419/sortlizer/tree/master/lib/utils"
    click d1 "https://github.com/roshan9419/sortlizer/tree/master/lib/datamodels"
    click e1 "https://github.com/roshan9419/sortlizer/blob/master/lib/app/locator.dart"
    click e2 "https://github.com/roshan9419/sortlizer/blob/master/lib/app/router.dart"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef presentation fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef business fill:#FFFFE0,stroke:#333,stroke-width:2px;
    classDef models fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef native fill:#D8BFD8,stroke:#333,stroke-width:2px;
    classDef app fill:#ffcccb,stroke:#333,stroke-width:2px;
```
