# hieutbui/ecoparking_flutter architecture

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

- Interactive diagram: https://gitdiagram.com/hieutbui/ecoparking_flutter
- Repository: https://github.com/hieutbui/ecoparking_flutter

## Overview

##### Project Type and Purpose
- This is a full-stack Flutter application designed for two main use cases: (a) users finding parking lots, and (b) parking owners/employees managing their parking. It leverages a mobile/web cross‐platform Flutter codebase with native implementations for Android, iOS, Linux, macOS, Windows, and web.
- The app uses Supabase as its primary backend (for database, auth, and functions) and integrates third-party services such as Stripe for payments, Mapbox for map functionalities, and Google for OAuth sign-in.

##### Key Architectural Layers & Components
a. Presentation (Frontend/UI Layer):
- Flutter “pages” (e.g., home, login, register, profile, ticket details) and “widgets” (action_button, search_bar, etc.) which define the user interface.
- That the UI is cross-platform, targeting mobile (Android/iOS) and desktop/web via separate folders (android, ios, web, etc.).
b. Application / State Management:
- “lib/app_state” and “lib/domain/state” directories that manage application status, login states, markers (parking information), and other feature-specific states.
- This layer bridges UI events with domain logic.
c. Domain Layer:
- Encompass “lib/domain” including repositories, services, usecases, and state management. This layer handles business logic such as login flows, parking service interactions, payment handling, etc.
- How user actions trigger usecases (like booking a ticket, searching parkings) that then leverage the repository interfaces.
d. Data Layer:
- “lib/data” which is divided into:
- Data Sources: Both remote (making API calls to Supabase, Stripe, Mapbox) and local (maybe through Hive or caching mechanisms). For instance, datasources for login, markers, payment, etc.
- Repositories (in “lib/data/repository” and “lib/domain/repository”): These implement the contract defined in the domain layer and call the relevant datasources.
- Network Layer: Highlight the presence of “lib/data/network/dio_client.dart” and payment APIs that handle HTTP requests.
- Integration with Supabase: Note the “lib/data/supabase_data” folder which includes bucket and table definitions indicative of how data storage is structured with Supabase.
e. Dependency Injection & Configuration:
- “lib/di” folder which shows the management of dependency injection (using GetIt, Hive initializers, and network/supabase utilities).
- Also, the configuration files in “lib/config” (app_config, app_routes, env_loader, and themes) should be represented.
f. External Services:
- Stripe: Show integration with Stripe for payment processing.
- Mapbox: Indicate integration for mapping services.
- OAuth Providers: Represent Google and Facebook sign-in through the specific mixins.
g. CI/CD & Project Management:
- (Optional) Include components for GitHub workflows, issue/PR templates, and release management as seen in the “.github” folder. Although not core to runtime architecture, they ensure quality and deployment automation.

##### Relationships & Interactions
- From UI components (pages/widgets) → to State Management → to Domain Usecases.
- Domain usecases interact with repositories in the Data Layer to fetch/store data.
- The Data Layer makes HTTP/network calls to external services (Supabase, Stripe, Mapbox).
- Dependency injection container (GetIt) as an orchestrator that wires these components.

##### Final Steps
- Provide detailed annotations if needed to explain interactions, especially where architectural patterns like MVC or Clean Architecture are being followed.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User
    U("User"):::externalStyle

    %% Presentation Layer
    subgraph "Presentation Layer"
        P1("UI - Pages"):::presentation
        P2("UI - Widgets"):::presentation
    end

    %% State Management Layer
    subgraph "State Management Layer"
        S1("App State"):::state
        S2("Domain State"):::state
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D1("Business Logic & Usecases"):::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        DA("Data - Sources/Repos"):::data
        DB("Data - Network & Supabase"):::data
    end

    %% Dependency Injection & Configuration
    subgraph "DI & Configuration"
        DI("DI & Config"):::di
    end

    %% External Services
    subgraph "External Services"
        EX1("Supabase"):::external
        EX2("Stripe Payment API"):::external
        EX3("Mapbox"):::external
        EX4("OAuth Providers"):::external
    end

    %% Platform Specific Implementations
    subgraph "Platform Specific"
        PL1("Android"):::platform
        PL2("iOS"):::platform
        PL3("Linux"):::platform
        PL4("macOS"):::platform
        PL5("Windows"):::platform
        PL6("Web"):::platform
    end

    %% CI/CD & Project Management
    CICD("CI/CD & PM"):::cicd

    %% Relationships & Interactions
    U -->|"interacts"| P1
    U -->|"interacts"| P2

    P1 -->|"triggers"| S1
    P2 -->|"triggers"| S1

    S1 -->|"updates"| S2
    S1 -->|"invokes"| D1

    D1 -->|"calls"| DA
    DA -->|"retrieves/updates"| DB

    DB -->|"fetches"| EX1
    DB -->|"calls"| EX2
    DB -->|"integrates"| EX3
    D1 -->|"authenticatesVia"| EX4

    DI -->|"configures"| S1
    DI -->|"configures"| D1
    DI -->|"configures"| DB

    CICD -->|"supports"| DI
    CICD -->|"supports"| P1
    CICD -->|"supports"| D1

    P1 -->|"runsOn"| PL1
    P1 -->|"runsOn"| PL2
    P1 -->|"runsOn"| PL3
    P1 -->|"runsOn"| PL4
    P1 -->|"runsOn"| PL5
    P1 -->|"runsOn"| PL6

    %% Click Events
    click P1 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/pages"
    click P2 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/widgets"
    click S1 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/app_state"
    click S2 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/domain/state"
    click D1 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/domain"
    click DA "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/data"
    click DB "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/data/network"
    click DI "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/di"
    click EX2 "https://github.com/hieutbui/ecoparking_flutter/blob/main/lib/data/network/payment/stripe_payment_api.dart"
    click EX4 "https://github.com/hieutbui/ecoparking_flutter/tree/main/lib/utils/mixins/oauth_mixin"
    click CICD "https://github.com/hieutbui/ecoparking_flutter/blob/main/.github"
    click PL1 "https://github.com/hieutbui/ecoparking_flutter/tree/main/android"
    click PL2 "https://github.com/hieutbui/ecoparking_flutter/tree/main/ios"
    click PL3 "https://github.com/hieutbui/ecoparking_flutter/tree/main/linux"
    click PL4 "https://github.com/hieutbui/ecoparking_flutter/tree/main/macos"
    click PL5 "https://github.com/hieutbui/ecoparking_flutter/tree/main/windows"
    click PL6 "https://github.com/hieutbui/ecoparking_flutter/tree/main/web"

    %% Style Definitions
    classDef presentation fill:#CFF,stroke:#333,stroke-width:2px;
    classDef state fill:#FFD,stroke:#333,stroke-width:2px;
    classDef domain fill:#FCF,stroke:#333,stroke-width:2px;
    classDef data fill:#FFC,stroke:#333,stroke-width:2px;
    classDef di fill:#CFC,stroke:#333,stroke-width:2px;
    classDef external fill:#FCC,stroke:#333,stroke-width:2px;
    classDef platform fill:#CCF,stroke:#333,stroke-width:2px;
    classDef cicd fill:#FDC,stroke:#333,stroke-width:2px;
    classDef externalStyle fill:#EFE,stroke:#333,stroke-width:2px;
```
