# nguyenvikhang170300/appbanhang_flutter architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenvikhang170300/appbanhang_flutter
- Repository: https://github.com/nguyenvikhang170300/appbanhang_flutter

## Overview

##### Main Components Identification

a) Client-Side (Mobile App):
- User Interface Layer
- State Management Layer (Provider)
- Service Layer
- Model Layer
- Authentication Layer
- Local Storage Layer

b) Backend Services (implied from the structure):
- Authentication Service
- Database Service
- Storage Service (for products/images)

**1. Presentation Layer (UI)**
- Pages (/lib/pages/*)
- Widgets (/lib/widgets/*)

**2. State Management Layer**
- Provider Components (/lib/provider/*)
- Cart Provider
- Order Provider
- Product Provider
- User Provider

**3. Business Logic Layer**
- Services (/lib/services/*)
- Authentication
- Database Methods
- Shared Preferences

**4. Data Layer**
- Models (/lib/model/*)
- API Services
- Local Storage

##### Connection Types

- Double lines: API communications

##### Component Details

For each major component, include:
- Component name
- Key responsibilities
- Primary dependencies
- Data flow direction

##### Additional Elements

Annotations for:
- Third-party integrations
- Local storage mechanisms
- Platform-specific implementations
- Security boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "UI Layer"
        UI_Pages["Pages"]
        UI_Admin["Admin Interface"]
        UI_User["User Interface"]
        UI_Widgets["Widgets"]
        UI_ProductW["Product Widgets"]
        UI_UserW["User Widgets"]
        UI_ProfileW["Profile Widgets"]
    end

    subgraph "State Management Layer"
        SM_Cart["Cart Provider"]
        SM_Order["Order Provider"]
        SM_Product["Product Provider"]
        SM_User["User Provider"]
    end

    subgraph "Services Layer"
        SVC_Auth["Authentication Service"]
        SVC_DB["Database Service"]
        SVC_Prefs["Shared Preferences"]
    end

    subgraph "Data Layer"
        DATA_Cart["Cart Model"]
        DATA_Category["Category Model"]
        DATA_Order["Order Model"]
        DATA_Product["Product Model"]
        DATA_User["User Model"]
    end

    subgraph "Backend Services"
        BE_Auth["Firebase Auth"]
        BE_DB["Cloud Database"]
        BE_Storage["Storage Service"]
    end

    subgraph "Platform Config"
        PLATFORM_Android["Android Config"]
        PLATFORM_iOS["iOS Config"]
    end

    subgraph "Assets"
        ASSETS_Images["Images"]
        ASSETS_Text["Text Resources"]
    end

    %% Relationships
    UI_Pages --> UI_Admin & UI_User
    UI_Widgets --> UI_ProductW & UI_UserW & UI_ProfileW
    
    UI_Pages -.-> SM_Cart & SM_Order & SM_Product & SM_User
    UI_Widgets -.-> SM_Cart & SM_Product & SM_User
    
    SM_Cart --> SVC_DB
    SM_Order --> SVC_DB
    SM_Product --> SVC_DB
    SM_User --> SVC_Auth
    
    SVC_Auth --> BE_Auth
    SVC_DB --> BE_DB
    SVC_Prefs --> DATA_User
    
    SM_Cart --> DATA_Cart
    SM_Order --> DATA_Order
    SM_Product --> DATA_Product
    SM_User --> DATA_User

    %% Click Events
    click UI_Pages "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/pages/"
    click UI_Admin "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/pages/admin/"
    click UI_User "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/pages/homepages.dart"
    click UI_Widgets "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/widgets/"
    click UI_ProductW "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/widgets/products/"
    click UI_UserW "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/widgets/users/"
    click UI_ProfileW "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//lib/widgets/profile/"
    click SM_Cart "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/provider/cartprovider.dart"
    click SM_Order "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/provider/orderprovider.dart"
    click SM_Product "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/provider/productprovider.dart"
    click SM_User "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/provider/userprovider.dart"
    click SVC_Auth "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/services/auth/auth.dart"
    click SVC_DB "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/services/database/databasemethod.dart"
    click SVC_Prefs "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/services/sharedpreferences/userpreferences.dart"
    click DATA_Cart "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/model/cartitem.dart"
    click DATA_Category "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/model/category.dart"
    click DATA_Order "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/model/orders.dart"
    click DATA_Product "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/model/products.dart"
    click DATA_User "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//lib/model/users.dart"
    click PLATFORM_Android "https://github.com/nguyenvikhang170300/appbanhang_flutter/blob/master//android/app/google-services.json"
    click PLATFORM_iOS "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//ios/Runner/"
    click ASSETS_Images "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//assets/images/"
    click ASSETS_Text "https://github.com/nguyenvikhang170300/appbanhang_flutter/tree/master//assets/txt/"

    %% Styling
    classDef ui fill:#a8d1f0
    classDef stateManagement fill:#90EE90
    classDef service fill:#FFE5B4
    classDef data fill:#FFA07A
    classDef backend fill:#DDA0DD
    classDef platform fill:#D3D3D3
    classDef assets fill:#F0E68C

    class UI_Pages,UI_Admin,UI_User,UI_Widgets,UI_ProductW,UI_UserW,UI_ProfileW ui
    class SM_Cart,SM_Order,SM_Product,SM_User stateManagement
    class SVC_Auth,SVC_DB,SVC_Prefs service
    class DATA_Cart,DATA_Category,DATA_Order,DATA_Product,DATA_User data
    class BE_Auth,BE_DB,BE_Storage backend
    class PLATFORM_Android,PLATFORM_iOS platform
    class ASSETS_Images,ASSETS_Text assets
```
