# intanaqilah-mf/kitatongtong architecture

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

- Interactive diagram: https://gitdiagram.com/intanaqilah-mf/kitatongtong
- Repository: https://github.com/intanaqilah-mf/kitatongtong

## Overview

##### Project type and purpose
- This is a cross-platform Flutter application (“projects”) targeting Android, iOS, Web, Linux, macOS, and Windows.
- It integrates with Firebase services (hosting, messaging, Cloud Functions) and also includes a standalone Node.js backend in `lib/backend/server.js`.
- The app provides user-facing pages (login, payments, package management, vouchers, staff management, etc.), and leverages Firebase Cloud Functions (in `functions/`) for server-side logic such as sending tax receipts.

##### File structure
- Top-level platform folders (`android/`, `ios/`, `web/`, `linux/`, `macos/`, `windows/`) contain the native shell for Flutter on each OS.
- `lib/` holds the Dart code:
- `lib/main.dart` – Flutter entry point
- `lib/firebase_options.dart` – Firebase SDK configuration
- `lib/pages/` – UI screens
- `lib/widgets/` – reusable UI components
- `lib/backend/` – custom Node.js server code
- `functions/` contains Firebase Cloud Functions (JavaScript) for on-demand backend tasks.
- `fix-firebase-urls/` is a utility script to patch hosting URLs.
- Configuration files: `firebase.json`, `.firebaserc`, `pubspec.yaml`, `package.json`.

##### README for additional insights
- Minimal README: boilerplate Flutter readme. No custom architecture docs.

a. Main components
- Flutter Client (multi-platform)
- Firebase Services
– Authentication
– Firestore / Realtime Database (if used)
– Cloud Messaging
– Hosting (serving the Web app)
– Cloud Functions (`functions/`)
- Custom Node.js Backend (`lib/backend/server.js`)
- Utility Scripts (`fix-firebase-urls/`)
- External Services (e-mail provider, payment gateways, etc.)
b. Relationships and interactions
– Flutter Client ↔ Firebase SDK (Auth, Database, Messaging) via REST/SDK calls
– Flutter Client → Cloud Functions (HTTP triggers) for tasks (sendTaxReceipt, fixPackageImages)
– Flutter Client ↔ Custom Node.js server for any non-Firebase APIs
– Cloud Functions ↔ Firebase database and external APIs (SMTP, payment processor)
– Utility scripts run during CI/deploy to update hosting URLs
c. Architectural patterns
– Frontend: MVVM or widget/page separation in Flutter
– Backend: micro-services split (Firebase Functions vs. standalone Node service)
– CI/CD: Firebase Hosting deploy for Web, native build pipelines for each platform
d. Technologies and frameworks
– Flutter/Dart for UI
– Firebase SDK (Auth, Firestore, Messaging)
– Firebase CLI & Hosting
– Firebase Cloud Functions (Node.js)
– Custom Node.js Express server in `lib/backend`
– build tools: Gradle, Xcode, CMake for desktops

##### Detail
- Every platform target under the Flutter block.
- Firebase service used.
- Where utility scripts fit into the deployment pipeline.
- Both serverless (Cloud Functions) and self-hosted (Node.js) backends.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter Client Layer
    subgraph "Flutter Client" 
        direction TB
        FC_Main["main.dart"]:::frontend
        FC_Pages["Pages (lib/pages/)"]:::frontend
        FC_Widgets["Widgets (lib/widgets/)"]:::frontend
        FC_Config["firebase_options.dart"]:::frontend
        subgraph "Platforms"
            direction TB
            Plat_Android["android/"]:::platform
            Plat_iOS["ios/"]:::platform
            Plat_Web["web/"]:::platform
            Plat_Linux["linux/"]:::platform
            Plat_macOS["macos/"]:::platform
            Plat_Windows["windows/"]:::platform
        end
    end

    %% Firebase Services
    subgraph "Firebase Services"
        direction TB
        Auth["Authentication"]:::serverless
        Firestore["Cloud Firestore"]:::database
        Messaging["Cloud Messaging"]:::serverless
        Hosting["Hosting"]:::serverless
    end

    %% Cloud Functions
    subgraph "Cloud Functions (functions/)" 
        direction TB
        CF_Send["sendTaxReceipt.js"]:::serverless
        CF_FixImages["fixPackageKasihImages.js"]:::serverless
    end

    %% Custom Node.js Backend
    subgraph "Node.js API Server (lib/backend/)"
        direction TB
        API_Server["server.js"]:::backend
    end

    %% Utility Scripts
    subgraph "Utility Scripts (CI/CD)"
        direction TB
        Util_FixURLs["fixUrls.js"]:::util
    end

    %% External Services
    External["External Services\n(e-mail, payment gateways)"]:::external

    %% Connections - SDK calls
    FC_Main -->|"SDK: Auth"| Auth
    FC_Main -->|"SDK: Firestore"| Firestore
    FC_Main -->|"SDK: Messaging"| Messaging

    %% HTTP calls - dashed
    FC_Main -.->|"HTTP: Cloud Functions"| CF_Send
    FC_Main -.->|"HTTP: Cloud Functions"| CF_FixImages
    FC_Main -.->|"HTTP: Node.js API"| API_Server

    %% Cloud Functions interactions
    CF_Send -->|"reads/writes"| Firestore
    CF_Send -->|"calls"| External
    CF_FixImages -->|"reads/writes"| Firestore

    %% Hosting serves Web
    Hosting -->|"serves assets"| Plat_Web

    %% Utility script in pipeline
    Util_FixURLs -->|"patches URLs"| Hosting

    %% Click Events
    click FC_Main "https://github.com/intanaqilah-mf/kitatongtong/blob/master/lib/main.dart"
    click FC_Pages "https://github.com/intanaqilah-mf/kitatongtong/tree/master/lib/pages/"
    click FC_Widgets "https://github.com/intanaqilah-mf/kitatongtong/tree/master/lib/widgets/"
    click FC_Config "https://github.com/intanaqilah-mf/kitatongtong/blob/master/lib/firebase_options.dart"
    click Plat_Android "https://github.com/intanaqilah-mf/kitatongtong/tree/master/android/"
    click Plat_iOS "https://github.com/intanaqilah-mf/kitatongtong/tree/master/ios/"
    click Plat_Web "https://github.com/intanaqilah-mf/kitatongtong/tree/master/web/"
    click Plat_Linux "https://github.com/intanaqilah-mf/kitatongtong/tree/master/linux/"
    click Plat_macOS "https://github.com/intanaqilah-mf/kitatongtong/tree/master/macos/"
    click Plat_Windows "https://github.com/intanaqilah-mf/kitatongtong/tree/master/windows/"
    click Hosting "https://github.com/intanaqilah-mf/kitatongtong/blob/master/firebase.json"
    click CF_Send "https://github.com/intanaqilah-mf/kitatongtong/blob/master/functions/sendTaxReceipt.js"
    click CF_FixImages "https://github.com/intanaqilah-mf/kitatongtong/blob/master/functions/fixPackageKasihImages.js"
    click API_Server "https://github.com/intanaqilah-mf/kitatongtong/blob/master/lib/backend/server.js"
    click Util_FixURLs "https://github.com/intanaqilah-mf/kitatongtong/blob/master/fix-firebase-urls/fixUrls.js"

    %% Styles
    classDef frontend fill:#C3E88D,stroke:#2E7D32,color:#1B5E20;
    classDef platform fill:#E0E0E0,stroke:#616161,color:#212121;
    classDef serverless fill:#FFCC80,stroke:#EF6C00,color:#E65100;
    classDef backend fill:#90CAF9,stroke:#1565C0,color:#0D47A1;
    classDef database fill:#B39DDB,stroke:#6A1B9A,color:#4A148C;
    classDef util fill:#FFAB91,stroke:#D84315,color:#BF360C;
    classDef external fill:#EEEEEE,stroke:#424242,color:#212121;
```
