# adityaambre/cricket_stats architecture

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

- Interactive diagram: https://gitdiagram.com/adityaambre/cricket_stats
- Repository: https://github.com/adityaambre/cricket_stats

## Overview

##### Project Type and Purpose
- This is a single-page mobile application built in Flutter, targeting Android and iOS, that fetches and displays cricket statistics.
- It follows an MVVM-style layering: presentation (screens + view-models), data (API + models), plus shared utilities and resources.

##### File Structure
- Native host code under `android/` and `ios/`—these folders contain platform-specific build/configuration, the Flutter engine embedding, and app delegates/manifests.
- Dart code under `lib/` subdivided into:
- `core/` for API client setup (`api.dart`)
- `model/` for data structures (`cricket_model.dart`)
- `screen/` for each UI feature (splash, match, team), each with `view.dart`, `view_model.dart`, and platform-specific mobile variants
- `widget/` for reusable UI components (e.g., `dialog.dart`)
- `util/` for logging and helper functions
- Entry point: `lib/main.dart`.

##### README for Insights
- Confirms Flutter SDK 3.24.3 and Dart 3.5.3
- No backend code; the app relies on external cricket-stats REST APIs via `core/api.dart`.

a. Native Shells
- Android (Gradle projects, manifest, MainActivity.java)
- iOS (Xcode workspace, AppDelegate.swift)
b. Flutter Engine & Dart VM
- Bridges native and Dart code
c. Presentation Layer (MVVM)
- Screens: SplashScreen, MatchView, TeamView
- ViewModels: manage state, call API client
- Widgets: Dialogs, common UI elements
d. Domain/Data Layer
- API Client (`core/api.dart`): issues HTTP requests to external cricket-stats endpoints
- Models (`cricket_model.dart`): parse JSON into Dart classes
e. Shared Resources
- Constants (`constant/constant.dart`)
- Utilities (`util/logger.dart`, `util/util.dart`)
f. External Services
- Cricket Stats REST API (third-party or internal)

##### Relationships and Interactions
- User taps a UI widget → Screen widget triggers ViewModel action → ViewModel calls API client → HTTP request to external service → JSON response → Model parsed → ViewModel updates state → UI rebuilds via Flutter’s reactive framework.
- Constants and resources are accessed across all layers. Utilities support logging and common helper functions.

##### Architectural Patterns & Principles
- MVVM: clear separation of Views (UI), ViewModels (state + logic), and Models (data).
- Layered architecture: Presentation → Domain/Data → External.
- Dependency inversion: ViewModels depend on abstracted API client interfaces.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Native Shell" 
        direction TB
        A1["MainActivity.java"]:::native
        A2["AndroidManifest.xml"]:::native
        I1["AppDelegate.swift"]:::native
        I2["Info.plist"]:::native
    end

    subgraph "Flutter Engine & Dart VM" 
        direction TB
        FEP["lib/main.dart"]:::boundary
    end

    subgraph "Flutter/Dart Layer"
        direction TB

        subgraph "Presentation Layer"
            direction TB
            SV["SplashView"]:::presentation
            SVP["SplashMobile"]:::presentation
            SVM["SplashViewModel"]:::viewmodel
            MV["MatchView"]:::presentation
            MVP["MatchMobile"]:::presentation
            MVM["MatchViewModel"]:::viewmodel
            TV["TeamView"]:::presentation
            TVP["TeamMobile"]:::presentation
            TVM["TeamViewModel"]:::viewmodel
            WDG["dialog.dart"]:::presentation
        end

        subgraph "Data Layer"
            direction TB
            API["api.dart"]:::data
            DM["cricket_model.dart"]:::data
        end

        subgraph "Shared Resources"
            direction TB
            CONS["constant.dart"]:::resource
            THEME["res_colors.dart"]:::resource
            LOG["logger.dart"]:::resource
            UTIL["util.dart"]:::resource
        end
    end

    EX["Cricket Stats REST API"]:::external

    %% Relationships
    SV -->|user event| SVM
    SVP -->|user event| SVM
    MV -->|user event| MVM
    MVP -->|user event| MVM
    TV -->|user event| TVM
    TVP -->|user event| TVM

    SVM -->|fetch data| API
    MVM -->|fetch data| API
    TVM -->|fetch data| API

    API -->|HTTP request| EX
    EX -->|HTTP response| API

    API -->|parse JSON| DM
    DM -->|model data| SVM
    DM -->|model data| MVM
    DM -->|model data| TVM

    %% Shared resources usage
    SVM --> CONS
    MVM --> CONS
    TVM --> CONS
    SV --> THEME
    MV --> THEME
    TV --> THEME
    SV --> LOG
    MV --> LOG
    TV --> LOG
    SVM --> UTIL
    MVM --> UTIL
    TVM --> UTIL

    %% Native to Flutter boundary
    A1 --> FEP
    A2 --> FEP
    I1 --> FEP
    I2 --> FEP
    FEP --> SV
    FEP --> MV
    FEP --> TV

    %% Click Events
    click A1 "https://github.com/adityaambre/cricket_stats/blob/main/android/app/src/main/java/com/cricket/stats/cricket_stats/MainActivity.java"
    click A2 "https://github.com/adityaambre/cricket_stats/blob/main/android/app/src/main/AndroidManifest.xml"
    click I1 "https://github.com/adityaambre/cricket_stats/blob/main/ios/Runner/AppDelegate.swift"
    click I2 "https://github.com/adityaambre/cricket_stats/blob/main/ios/Runner/Info.plist"
    click FEP "https://github.com/adityaambre/cricket_stats/blob/main/lib/main.dart"
    click SV "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/splash_view/splash_view.dart"
    click SVP "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/splash_view/splash_mobile.dart"
    click SVM "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/splash_view/splash_view_model.dart"
    click MV "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/match_view/match_view.dart"
    click MVP "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/match_view/match_mobile.dart"
    click MVM "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/match_view/match_view_model.dart"
    click TV "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/team_view/team_view.dart"
    click TVP "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/team_view/team_mobile.dart"
    click TVM "https://github.com/adityaambre/cricket_stats/blob/main/lib/screen/team_view/team_view_model.dart"
    click API "https://github.com/adityaambre/cricket_stats/blob/main/lib/core/api.dart"
    click DM "https://github.com/adityaambre/cricket_stats/blob/main/lib/model/cricket_model.dart"
    click WDG "https://github.com/adityaambre/cricket_stats/blob/main/lib/widget/dialog.dart"
    click CONS "https://github.com/adityaambre/cricket_stats/blob/main/lib/constant/constant.dart"
    click THEME "https://github.com/adityaambre/cricket_stats/blob/main/lib/res/res_colors.dart"
    click LOG "https://github.com/adityaambre/cricket_stats/blob/main/lib/util/logger.dart"
    click UTIL "https://github.com/adityaambre/cricket_stats/blob/main/lib/util/util.dart"

    %% Styles
    classDef native fill:#FFA500,stroke:#333,stroke-width:1px
    classDef boundary fill:#DDDDDD,stroke:#333,stroke-width:1px
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef viewmodel fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef resource fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
```
