# taufiqelahi/phi architecture

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

- Interactive diagram: https://gitdiagram.com/taufiqelahi/phi
- Repository: https://github.com/taufiqelahi/phi

## Overview

##### Project type and purpose
- This is a multi-platform Flutter e-commerce application (Android, iOS, web, Windows, macOS, Linux) that lets users browse products, manage a cart and place orders.
- It uses Riverpod for state management, GetX for navigation/controllers, Firebase (Authentication + Firestore) for backend data and auth.

##### File structure
- Top-level “android”, “ios”, “web”, “windows”, “macos”, “linux” folders: platform-specific Flutter runners.
- lib/
- main.dart: Flutter entry point
- component/: reusable widgets (buttons, text fields, carousels)
- screen/: UI screens organized by feature (dashboard/home, add_cart, add_product, etc.)
- backend/: business/data layer
– controller/: GetX controllers for e.g. cart item counts
– services/: functions that call Firestore (offer_func.dart, product_func.dart, utility)
– model/: domain models (Offer, Product) with Freezed+json_serializable
- utils/: shared constants and extensions
- firebase_options.dart: Firebase initialization settings
- pubspec.yaml / build files: declares Flutter, Riverpod, GetX, Firebase dependencies.

##### README
- Confirms feature set: product browsing, searching, Firebase Auth, cart management, order history.
- Mentions Figma design, implies a clean MVC/MVVM-style separation.

##### Elements
- Blue for UI/presentation
- Green for state management/controllers
- Orange for data services
- Yellow for external/cloud services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Runners
    subgraph "Platform Runners"
        Android["Android Engine"]:::external
        iOS["iOS Engine"]:::external
        Web["Web Engine"]:::external
        Windows["Windows Engine"]:::external
        macOS["macOS Engine"]:::external
        Linux["Linux Engine"]:::external
    end

    %% App Entry
    Main["Main (lib/main.dart)"]:::external

    %% Flutter Client
    subgraph "Flutter Client"
        subgraph "Presentation Layer" 
            Dashboard["DashboardScreen"]:::ui
            Home["HomeScreen"]:::ui
            Bookmark["BookmarkScreen"]:::ui
            Notification["NotificationScreen"]:::ui
            Profile["ProfileScreen"]:::ui
            AddCart["AddCartScreen"]:::ui
            AddProduct["AddProductScreen"]:::ui
            Button["Button Widget"]:::ui
            Carousel["Custom Carousel"]:::ui
            TextField["Custom TextField"]:::ui
            Label["Label Widget"]:::ui
            ProductView["Product View"]:::ui
        end

        subgraph "State Management & Navigation"
            Controllers["GetX Controllers"]:::controller
            Providers["Riverpod Providers"]:::controller
        end

        subgraph "Data Access Layer"
            ProductService["ProductService"]:::service
            OfferService["OfferService"]:::service
            UtilityService["UtilityService"]:::service
        end

        subgraph "Domain Models"
            ProductModel["Product Model"]:::model
            OfferModel["Offer Model"]:::model
            ShoeUtility["Shoe Utility"]:::model
        end

        FirebaseConfig["FirebaseConfig (lib/firebase_options.dart)"]:::external
    end

    %% Firebase Cloud
    subgraph "Firebase Cloud"
        AuthService["Firebase Auth"]:::external
        FirestoreDB["Cloud Firestore"]:::external
    end

    %% Connections
    Android -->|runs on| Main
    iOS -->|runs on| Main
    Web -->|runs on| Main
    Windows -->|runs on| Main
    macOS -->|runs on| Main
    Linux -->|runs on| Main

    Main -->|"starts"| Dashboard
    Dashboard -->|"navigate()/invoke()"| Controllers
    Home -->|"navigate()"| Controllers
    Bookmark -->|"navigate()"| Controllers
    Notification -->|"navigate()"| Controllers
    Profile -->|"navigate()"| Controllers
    AddCart -->|"invoke()"| Controllers
    AddProduct -->|"invoke()"| Controllers

    Button -->|used by| Dashboard
    Carousel -->|used by| Home
    TextField -->|used by| AddProduct
    Label -->|used by| ProductView
    ProductView -->|used by| Dashboard

    Controllers -->|"invoke Provider"| Providers
    Providers -->|"call(product CRUD)"| ProductService
    Providers -->|"call(offer CRUD)"| OfferService
    Providers -->|"call(util funcs)"| UtilityService

    ProductService -->|"query()/update()"| FirestoreDB
    OfferService -->|"query()/update()"| FirestoreDB
    UtilityService -->|"query()/update()"| FirestoreDB

    FirestoreDB -->|"snapshot()"/map to| ProductService
    FirestoreDB -->|"snapshot()"/map to| OfferService
    FirestoreDB -->|"snapshot()"/map to| UtilityService

    ProductService -->|"map to Model"| ProductModel
    OfferService -->|"map to Model"| OfferModel
    UtilityService -->|"map to Model"| ShoeUtility

    ProductModel -->|"update State"| Providers
    OfferModel -->|"update State"| Providers
    ShoeUtility -->|"update State"| Providers

    Dashboard -->|"login()/signUp()"| AuthService
    AuthService -->|"authenticate()"| FirebaseConfig
    FirebaseConfig -->|"init Firebase SDK"| Providers

    AuthService -->|"auth state"| Providers

    Providers -->|"state change"| Dashboard

    %% Click Events
    click Main "https://github.com/taufiqelahi/phi/blob/master/lib/main.dart"
    click Dashboard "https://github.com/taufiqelahi/phi/blob/master/lib/screen/dashboard/dashboard_screen.dart"
    click Home "https://github.com/taufiqelahi/phi/blob/master/lib/screen/dashboard/home_screen.dart"
    click Bookmark "https://github.com/taufiqelahi/phi/blob/master/lib/screen/dashboard/bookmark_screen.dart"
    click Notification "https://github.com/taufiqelahi/phi/blob/master/lib/screen/dashboard/notification_screen.dart"
    click Profile "https://github.com/taufiqelahi/phi/blob/master/lib/screen/dashboard/profile_screen.dart"
    click AddCart "https://github.com/taufiqelahi/phi/blob/master/lib/screen/add_cart.dart"
    click AddProduct "https://github.com/taufiqelahi/phi/blob/master/lib/screen/add_product_screen.dart"
    click Button "https://github.com/taufiqelahi/phi/blob/master/lib/component/button.dart"
    click Carousel "https://github.com/taufiqelahi/phi/blob/master/lib/component/custom_carousel.dart"
    click TextField "https://github.com/taufiqelahi/phi/blob/master/lib/component/custom_text_field.dart"
    click Label "https://github.com/taufiqelahi/phi/blob/master/lib/component/label.dart"
    click ProductView "https://github.com/taufiqelahi/phi/blob/master/lib/component/product_view.dart"
    click Controllers "https://github.com/taufiqelahi/phi/blob/master/lib/backend/get/controller/cart_item_count_controller.dart"
    click ProductModel "https://github.com/taufiqelahi/phi/blob/master/lib/backend/model/product.dart"
    click OfferModel "https://github.com/taufiqelahi/phi/blob/master/lib/backend/model/offer.dart"
    click ShoeUtility "https://github.com/taufiqelahi/phi/blob/master/lib/backend/model/shoe_utility.dart"
    click ProductService "https://github.com/taufiqelahi/phi/blob/master/lib/backend/services/produc_func.dart"
    click OfferService "https://github.com/taufiqelahi/phi/blob/master/lib/backend/services/offer_func.dart"
    click UtilityService "https://github.com/taufiqelahi/phi/blob/master/lib/backend/services/utility_func.dart"
    click FirebaseConfig "https://github.com/taufiqelahi/phi/blob/master/lib/firebase_options.dart"
    click Android "https://github.com/taufiqelahi/phi/tree/master/android/"
    click iOS "https://github.com/taufiqelahi/phi/tree/master/ios/"
    click Web "https://github.com/taufiqelahi/phi/tree/master/web/"
    click Windows "https://github.com/taufiqelahi/phi/tree/master/windows/"
    click macOS "https://github.com/taufiqelahi/phi/tree/master/macos/"
    click Linux "https://github.com/taufiqelahi/phi/tree/master/linux/"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:1px;
    classDef controller fill:#ABEBC6,stroke:#1D8348,stroke-width:1px;
    classDef service fill:#F5B041,stroke:#B9770E,stroke-width:1px;
    classDef model fill:#D7BDE2,stroke:#6C3483,stroke-width:1px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:1px;
```
