# webby813/fc-merchant architecture

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

- Interactive diagram: https://gitdiagram.com/webby813/fc-merchant
- Repository: https://github.com/webby813/fc-merchant

## Overview

##### Project Type and Purpose
- Type: Cross-platform mobile application (Flutter)
- Purpose: Merchant-side food-ordering client. Receives real-time orders from the fypuser platform, displays dashboards, lets merchants manage and update order statuses.

##### File Structure
- Top-level “android” and “ios” folders: platform-specific runner/stubs generated by Flutter.
- “lib” folder: core Dart code broken into:
- Firebase services (create_data.dart, retrieve_data.dart, update_data.dart, delete_data.dart, view_order.dart)
- Responsive UI layer (shared Cross-platform code + Mobile + Tablet views)
- SharedPref (local caching)
- Entry points (main.dart, login.dart, home.dart)
- Configuration files: pubspec.yaml, firebase.json, firebase_app_id_file.json.

##### README for Additional Insights
- Real-time order notifications → implies use of Firebase Cloud Messaging (FCM)
- Order CRUD → Cloud Firestore or Realtime Database as primary data store
- No backend code in repo → backend that pushes orders lives elsewhere (fypuser platform).

##### Main Components
a. Presentation Layer (Flutter UI)
- Component library widgets & styles
- Responsive layout controllers (mobile vs. tablet)
- Screens: Login, Dashboard, Order Details, Settings
b. Business Logic Layer (Dart services)
- FirebaseService – wraps CRUD operations & order retrieval
- NotificationService – handles FCM token registration & incoming messages
- SharedPrefService – local storage for tokens, user info, preferences
c. Data Layer / External Services
- Firebase Cloud Firestore (or RTDB) – order data store
- Firebase Cloud Messaging – push notifications
- Authentication (Firebase Auth, if used—token management)
- fypuser Platform (external backend) → writes orders into Firestore & triggers FCM
d. Platform Runners
- Android runner (Gradle, Kotlin MainActivity)
- iOS runner (Swift AppDelegate)

##### Relationships and Data Flows
- User taps UI → UI Layer invokes Business Logic Service (e.g., view_order.dart)
- Business Logic calls FirebaseService → reads/writes Firestore
- Firestore persists order data → updates propagate back to app (streams or queries)
- fypuser backend → pushes new order documents to Firestore & triggers FCM → NotificationService receives FCM payload → UI displays real-time alerts
- SharedPrefService caches auth tokens and preferences for quick access by UI & Services

##### Architectural Patterns
- Layered architecture (Presentation → Business Logic → Data)
- Responsive design pattern: single codebase, but conditional layouts for Mobile vs. Tablet
- Service-based abstraction for external dependencies (Firebase APIs)
- Reusable widget library for UI consistency

##### Final Checklist
- [ ] Node for fypuser external backend
- [ ] Nodes for Firestore & FCM under “External Services”
- [ ] Nodes for Shared Preferences and Firebase Auth (if used)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Widgets["Component Library Widgets & Styles"]:::presentation
        Color["Color Styles"]:::presentation
        RespLayout["Responsive Layout Controller"]:::presentation
        MobileScaffold["Mobile Scaffold"]:::presentation
        TabletScaffold["Tablet Scaffold"]:::presentation
        DashboardViews["Cross-Platform Dashboard Views"]:::presentation
        ManageViews["Cross-Platform Manage Views"]:::presentation
        MobileUI["Mobile-Specific UI"]:::presentation
        TabletUI["Tablet-Specific UI"]:::presentation
        Login["Login Screen"]:::presentation
        Home["Home/Dashboard Screen"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        FirebaseService["FirebaseService (CRUD & Order Retrieval)"]:::business
        SharedPref["SharedPrefService"]:::business
        NotificationSvc["NotificationService"]:::business
    end

    %% Data & External Services
    subgraph "Data & External Services"
        Firestore["Cloud Firestore"]:::external
        FCM["Firebase Cloud Messaging"]:::external
        Auth["Firebase Auth"]:::external
        Backend["fypuser Platform"]:::external
    end

    %% Platform Runners
    subgraph "Platform Runners"
        Android["Android MainActivity"]:::platform
        iOS["iOS AppDelegate"]:::platform
    end

    %% Connections
    Widgets -->|used by| RespLayout
    RespLayout --> MobileUI
    RespLayout --> TabletUI
    MobileUI --> DashboardViews
    TabletUI --> DashboardViews
    MobileUI --> ManageViews
    TabletUI --> ManageViews

    Login -->|invokes| FirebaseService
    Home -->|invokes| FirebaseService
    FirebaseService -->|Firestore REST/SDK| Firestore
    FirebaseService -->|Auth operations| Auth
    Backend -->|writes orders| Firestore
    Backend -->|triggers| FCM
    FCM -->|push| NotificationSvc
    NotificationSvc -->|alerts| Home

    main["App Initialization (main.dart)"]:::presentation
    main -->|loads tokens| SharedPref
    SharedPref -->|provides| FirebaseService

    Android -->|runs| main
    iOS -->|runs| main

    %% Click Events
    click Widgets "https://github.com/webby813/fc-merchant/tree/main/lib/Components/"
    click Color "https://github.com/webby813/fc-merchant/blob/main/lib/Color/color.dart"
    click RespLayout "https://github.com/webby813/fc-merchant/blob/main/lib/Responsive/responsive_layout.dart"
    click MobileScaffold "https://github.com/webby813/fc-merchant/blob/main/lib/Responsive/mobileScaffold.dart"
    click TabletScaffold "https://github.com/webby813/fc-merchant/blob/main/lib/Responsive/tabletScaffold.dart"
    click DashboardViews "https://github.com/webby813/fc-merchant/tree/main/lib/Responsive/Cross-platform code/DashboardTab/"
    click ManageViews "https://github.com/webby813/fc-merchant/tree/main/lib/Responsive/Cross-platform code/ManageTab/"
    click MobileUI "https://github.com/webby813/fc-merchant/tree/main/lib/Responsive/Mobile/"
    click TabletUI "https://github.com/webby813/fc-merchant/tree/main/lib/Responsive/Tablet/"
    click Login "https://github.com/webby813/fc-merchant/blob/main/lib/login.dart"
    click Home "https://github.com/webby813/fc-merchant/blob/main/lib/home.dart"
    click main "https://github.com/webby813/fc-merchant/blob/main/lib/main.dart"
    click FirebaseService "https://github.com/webby813/fc-merchant/blob/main/lib/Firebase/create_data.dart"
    click FirebaseService "https://github.com/webby813/fc-merchant/blob/main/lib/Firebase/retrieve_data.dart"
    click FirebaseService "https://github.com/webby813/fc-merchant/blob/main/lib/Firebase/update_data.dart"
    click FirebaseService "https://github.com/webby813/fc-merchant/blob/main/lib/Firebase/delete_data.dart"
    click FirebaseService "https://github.com/webby813/fc-merchant/blob/main/lib/Firebase/view_order.dart"
    click SharedPref "https://github.com/webby813/fc-merchant/blob/main/lib/SharedPref/pref.dart"
    click Android "https://github.com/webby813/fc-merchant/blob/main/android/app/src/main/kotlin/com/example/fypmerchant/MainActivity.kt"
    click iOS "https://github.com/webby813/fc-merchant/blob/main/ios/Runner/AppDelegate.swift"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#000
    classDef business fill:#DFF2BF,stroke:#000
    classDef external fill:#FFE4B5,stroke:#000
    classDef platform fill:#E0E0E0,stroke:#000
```
