# flyapex/netplus architecture

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

- Interactive diagram: https://gitdiagram.com/flyapex/netplus
- Repository: https://github.com/flyapex/netplus

## Overview

##### Project type and purpose
- This is a cross-platform Flutter client application (“netplus”) targeting Android, iOS, Linux, macOS, Windows and Web.
- It presents a user-centric ordering/offers system: login, home, offers, orders, push notifications, connectivity checks.

##### High-level architecture overview
- The Flutter “engine” and host platform embedding live in each “android/”, “ios/”, etc. folder.
- The real app logic sits under “lib/” with a classic layered structure:
- Presentation Layer: “lib/view/…” (Widgets, pages)
- Business Logic Layer: “lib/controller/…” (NavController, PostController, UserController, DbController)
- Data Layer: “lib/api/api.dart” (network client), local persistence via DbController, plus Firebase Interaction in “lib/firebase_options.dart” and notification helpers.

A. Flutter Host & Engine (per-platform runners)
- Android embedding (MainActivity.kt)
- iOS embedding (AppDelegate.swift)
- Linux/macOS/Windows/ Web runner
B. Flutter Framework & Dart VM (single core)
C. Presentation Layer
- UI Widgets & Pages under “lib/view”
D. Business Logic Layer
- Controllers (Nav, Post, User, DB) under “lib/controller”
- Connectivity & Permissions helpers under “lib/utils”
E. Data Layer
- API client (“api.dart”) connecting to external REST endpoints
- Local persistence (DbController) – e.g. SQLite or local file
- Firebase (Auth, Analytics, Cloud Messaging)
F. External Services
- Third-party REST API
- Firebase Cloud Messaging & Analytics
- Google Services configuration (google-services.json, GoogleService-Info.plist)

##### Relationships & data flow
- User taps UI Widget → Presentation Layer → calls Business Logic Controller
- Controller → Data Layer:
- For network calls, invokes Api client → External REST API → JSON response → models (send/receive) → returns data to controller → updates UI
- For local cache, uses DbController → local DB → Controller
- For notifications, uses PushNotification and NotificationHelper → Firebase Cloud Messaging
- ConnectivityController monitors network state → informs controllers/UI of offline/online
- Permission helpers prompt OS to grant notification/location, etc.

##### Architectural patterns & design principles
- Separation of Concerns: clear division Presentation / Logic / Data
- MVVM-like or MVC-like layering with controllers as ViewModels
- Dependency injection via Bind (in “lib/utils/bind.dart”)
- Reactive updates: controllers push state changes back to UI widgets
- Platform-agnostic core in lib/; platform-specific runner only handles embedding.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Platform Runners
  subgraph "Platform Runners" 
    AndroidRunner["Android Runner\n(MainActivity.kt)"]:::runner
    iOSRunner["iOS Runner\n(AppDelegate.swift)"]:::runner
    LinuxRunner["Linux Runner\n(main.cc)"]:::runner
    macOSRunner["macOS Runner\n(AppDelegate.swift)"]:::runner
    WindowsRunner["Windows Runner\n(main.cpp)"]:::runner
    WebRunner["Web Runner\n(index.html)"]:::runner
  end

  %% Flutter Core
  subgraph "Flutter Core" 
    FrameworkVM["Flutter Framework & VM\n(lib/main.dart)"]:::core
  end

  %% Presentation Layer
  subgraph "Presentation Layer" 
    UIWidgets["UI Widgets & Pages\n(lib/view/)"]:::presentation
    HomeView["Home View\n(home_view.dart)"]:::presentation
    PageViews["Page Views\n(lib/view/page/)"]:::presentation
    SharedUI["Shared UI Components\n(lib/view/ui/)"]:::presentation
  end

  %% Business Logic Layer
  subgraph "Business Logic Layer"
    NavController["NavController\n(navcontroller.dart)"]:::logic
    PostController["PostController\n(postcontroller.dart)"]:::logic
    UserController["UserController\n(usercontroller.dart)"]:::logic
    DbController["DbController\n(db_controller.dart)"]:::logic
    ConnectivityController["ConnectivityController\n(connectivity_controller.dart)"]:::logic
    PermissionHelper["NotificationHelper\n(notification_helper.dart)"]:::logic
    PushNotification["PushNotificationHelper\n(pushnotification.dart)"]:::logic
    BindDI["Dependency Injection Bindings\n(bind.dart)"]:::logic
  end

  %% Data Layer
  subgraph "Data Layer"
    APIClient["API Client\n(api.dart)"]:::data
    LocalDB["Local Persistence\n(DbController)"]:::data
    FirebaseConfig["Firebase Config\n(firebase_options.dart)"]:::data
  end

  %% External Services
  subgraph "External Services"
    RESTAPI["External REST API"]:::external
    FCM["Firebase Cloud Messaging"]:::external
    Analytics["Firebase Analytics"]:::external
    AndroidConfig["google-services.json"]:::external
    iOSConfig["GoogleService-Info.plist"]:::external
    macOSConfig["GoogleService-Info.plist"]:::external
  end

  %% Connections
  AndroidRunner --> FrameworkVM
  iOSRunner --> FrameworkVM
  LinuxRunner --> FrameworkVM
  macOSRunner --> FrameworkVM
  WindowsRunner --> FrameworkVM
  WebRunner --> FrameworkVM

  FrameworkVM --> UIWidgets
  UIWidgets --> HomeView
  UIWidgets --> PageViews
  UIWidgets --> SharedUI

  HomeView --> NavController
  PageViews --> PostController
  SharedUI --> UserController

  NavController --> APIClient
  PostController --> APIClient
  UserController --> APIClient

  NavController --> DbController
  PostController --> DbController
  UserController --> DbController

  DbController --> LocalDB

  APIClient --> RESTAPI
  APIClient --> FirebaseConfig

  PushNotification --> FCM
  PushNotification --> FirebaseConfig
  PermissionHelper --> PushNotification
  ConnectivityController --> NavController
  ConnectivityController --> UIWidgets

  BindDI --> NavController
  BindDI --> PostController
  BindDI --> UserController
  BindDI --> DbController

  %% Click Events
  click AndroidRunner "https://github.com/flyapex/netplus/blob/main/android/app/src/main/kotlin/com/example/netplus/MainActivity.kt"
  click iOSRunner "https://github.com/flyapex/netplus/blob/main/ios/Runner/AppDelegate.swift"
  click LinuxRunner "https://github.com/flyapex/netplus/blob/main/linux/main.cc"
  click macOSRunner "https://github.com/flyapex/netplus/blob/main/macos/Runner/AppDelegate.swift"
  click WindowsRunner "https://github.com/flyapex/netplus/blob/main/windows/runner/main.cpp"
  click WebRunner "https://github.com/flyapex/netplus/blob/main/web/index.html"
  click FrameworkVM "https://github.com/flyapex/netplus/blob/main/lib/main.dart"
  click UIWidgets "https://github.com/flyapex/netplus/tree/main/lib/view/"
  click HomeView "https://github.com/flyapex/netplus/blob/main/lib/view/home_view.dart"
  click PageViews "https://github.com/flyapex/netplus/tree/main/lib/view/page/"
  click SharedUI "https://github.com/flyapex/netplus/tree/main/lib/view/ui/"
  click NavController "https://github.com/flyapex/netplus/blob/main/lib/controller/navcontroller.dart"
  click PostController "https://github.com/flyapex/netplus/blob/main/lib/controller/postcontroller.dart"
  click UserController "https://github.com/flyapex/netplus/blob/main/lib/controller/usercontroller.dart"
  click DbController "https://github.com/flyapex/netplus/blob/main/lib/controller/db_controller.dart"
  click ConnectivityController "https://github.com/flyapex/netplus/blob/main/lib/utils/connectivity_controller.dart"
  click PermissionHelper "https://github.com/flyapex/netplus/blob/main/lib/utils/permission/notification_helper.dart"
  click PushNotification "https://github.com/flyapex/netplus/blob/main/lib/utils/pushnotification.dart"
  click BindDI "https://github.com/flyapex/netplus/blob/main/lib/utils/bind.dart"
  click APIClient "https://github.com/flyapex/netplus/blob/main/lib/api/api.dart"
  click FirebaseConfig "https://github.com/flyapex/netplus/blob/main/lib/firebase_options.dart"
  click AndroidConfig "https://github.com/flyapex/netplus/blob/main/android/app/google-services.json"
  click iOSConfig "https://github.com/flyapex/netplus/blob/main/ios/Runner/GoogleService-Info.plist"
  click macOSConfig "https://github.com/flyapex/netplus/blob/main/macos/Runner/GoogleService-Info.plist"

  %% Styles
  classDef runner fill:#f9f,stroke:#333,stroke-width:1px
  classDef core fill:#fcc,stroke:#333,stroke-width:1px
  classDef presentation fill:#bbf,stroke:#333,stroke-width:1px
  classDef logic fill:#bfb,stroke:#333,stroke-width:1px
  classDef data fill:#fbf,stroke:#333,stroke-width:1px
  classDef external fill:#ffb,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
