# derisstrict/pnbfoods architecture

> Architecture diagram of the GitHub repository derisstrict/pnbfoods, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/derisstrict/pnbfoods
- Repository: https://github.com/derisstrict/pnbfoods

## Overview

1. **Project shape**
   - This is a **Flutter client application** called **pnbfoods**.  
   - It is built to run on **Android, iOS, web, Linux, macOS, and Windows**, but the actual app behavior lives in `lib/`; the platform folders are mostly Flutter-generated runners and launch shells.

2. **Core application entry**
   - The app entrypoint is `lib/main.dart`.
   - From the file layout, the app likely boots into an authentication or role-selection flow before routing users into the buyer or seller experience.

3. **High-level product domain**
   - The repository models a **food ordering system** with two main user roles:
     - **Pembeli** = buyer/customer
     - **Penjual** = seller/vendor
   - The app domain includes canteens (`kantin`), products (`produk`), carts (`keranjang`), orders (`orderan`), payments (`pembayaran`), favorites (`favorit`), and history/receipts (`riwayat`).

4. **Authentication and account boundary**
   - `lib/auth/` contains the login and access-control flow:
     - login page
     - forgot password
     - role selection
     - authentication orchestration
   - `lib/akun/` contains user account management:
     - user profile
     - edit user
     - change password
   - This suggests identity and profile management are separated from the purchase/order flows.

5. **Shared UI building blocks**
   - `lib/common/` holds reusable UI components used across multiple screens:
     - forms
     - login form
     - navbar
     - top bar
     - buttons
     - color/theme constants
     - a “palang tamu” component, likely a guest-access or banner-style widget
   - These shared widgets form the app’s presentation layer and reduce duplication across buyer and seller screens.

6. **Buyer-facing subsystem**
   - `lib/pembeli/` is the main customer flow and is organized by business capability:
     - `list_kantin` for browsing canteens
     - `list_produk` for product browsing
     - `deskripsi_makanan` for product detail pages
     - `favorit` for saved items
     - `keranjang` for cart review and checkout details
     - `order` for order submission
     - `pembayaran` for payment execution
     - `riwayat` for transaction history
   - This is the main end-user journey: browse → inspect → favorite/cart → order → pay → review history.

7. **Payment flow boundary**
   - The payment area has its own widgets for:
     - QR-style payment display (`qris_box`)
     - payment button/action
     - countdown timer for expiration
   - That indicates payment is treated as a distinct stage after checkout, with time-sensitive UI state.

8. **Seller-facing subsystem**
   - `lib/penjual/` covers the merchant/admin side:
     - dashboard
     - canteen form
     - product form
     - order management
   - The seller flow is focused on **content management and fulfillment**, not consumer browsing.  
   - The `pesanan` screen and its detail widget imply sellers can inspect incoming orders and act on them.

9. **Data model layer**
   - `lib/models/` defines the app’s shared domain objects:
     - people and roles: `pelanggan`, `penjual`
     - catalog: `kantin`, `produk`
     - shopping state: `keranjang`, `item_keranjang`, `favorit`
     - order lifecycle: `orderan`, `detail_orderan`, `item_riwayat`
     - payment state: `pembayaran`
   - These models are the main contract between UI and service layers.

10. **Service/API layer**
   - `lib/services/` is a dedicated data-access boundary, with one service per domain area:
     - cart, favorites, canteens, products
     - orders, order details, payments
     - buyer/seller/user services
     - history/riwayat
   - `base_url.dart` indicates the app talks to an **external backend API** rather than storing business data locally in the client.

11. **Architecture pattern**
   - The app is structured as a **feature-based Flutter UI** with:
     - presentation widgets/screens in feature folders
     - domain models in `models/`
     - network/API calls in `services/`
   - The main data flow is: **screen → service → backend API → model → UI update**.

12. **Assets and theming**
   - The repo includes `assets/img`, `fonts`, and platform-specific launch/background assets.
   - These support branding and visual consistency but are not central to the business architecture.

13. **Platform/runtime boundaries**
   - The Android, iOS, desktop, and web folders are standard Flutter platform scaffolding.
   - Native code exists only as generated launchers/bootstrap code (`MainActivity.kt`, `AppDelegate.swift`, Windows/Linux runners), while the product logic remains cross-platform in Dart.

14. **Testing and tooling**
   - There is a minimal Flutter widget test in `test/widget_test.dart`.
   - `analysis_options.yaml`, Gradle/Xcode configs, and Flutter tool files show a standard Flutter development toolchain, with no separate backend or microservice code inside this repository.

Main entry points: [`lib/services`](https://github.com/derisstrict/pnbfoods/tree/main/lib/services) (Services), [`lib/auth/autentikasi.dart`](https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/autentikasi.dart) (Auth), [`lib/pembeli/list_produk/list_produk.dart`](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_produk/list_produk.dart) (Products), [`lib/pembeli/list_kantin/list_kantin.dart`](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_kantin/list_kantin.dart) (Canteens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App Shell"]
  node_main["Main<br/>Flutter entrypoint<br/>[main.dart]"]
end

subgraph group_group_core["Core Client"]
  node_auth["Auth<br/>login flow<br/>[autentikasi.dart]"]
  node_login["Login<br/>screen<br/>[login_page.dart]"]
  node_role["Role Select<br/>screen<br/>[role_page.dart]"]
  node_account["Account<br/>profile mgmt<br/>[akun_user.dart]"]
  node_home["Home<br/>navigation hub<br/>[home.dart]"]
  node_shared_ui["Shared UI<br/>widgets"]
end

subgraph group_group_buyer["Buyer Flow"]
  node_canteens["Canteens<br/>browse/catalog<br/>[list_kantin.dart]"]
  node_products["Products<br/>catalog browse<br/>[list_produk.dart]"]
  node_product_detail["Product Detail<br/>detail screen"]
  node_favorites["Favorites<br/>saved items<br/>[favorit_page.dart]"]
  node_cart["Cart<br/>checkout prep"]
  node_order["Order<br/>[page_order.dart]"]
  node_payment["Payment"]
  node_history["History<br/>transactions<br/>[page_riwayat.dart]"]
end

subgraph group_group_seller["Seller Flow"]
  node_seller_dash["Seller Dash<br/>merchant dashboard<br/>[dashboard.dart]"]
  node_seller_forms["Seller Forms<br/>content mgmt<br/>[form_kantin.dart]"]
  node_seller_orders["Seller Orders<br/>fulfillment<br/>[pesanan.dart]"]
end

subgraph group_group_data["Data Layer"]
  node_models[("Models<br/>domain objects")]
  node_services["Services<br/>API access"]
  node_api_base["API Base<br/>backend config<br/>[base_url.dart]"]
end

node_main -->|"boots"| node_auth
node_auth -->|"sign-in"| node_login
node_auth -->|"choose role"| node_role
node_auth -->|"enter app"| node_home
node_home -->|"profile"| node_account
node_home -->|"browse"| node_canteens
node_shared_ui -->|"supports"| node_auth
node_shared_ui -->|"supports"| node_canteens
node_shared_ui -->|"supports"| node_seller_dash
node_canteens -->|"explore"| node_products
node_products -->|"open"| node_product_detail
node_products -->|"save"| node_favorites
node_products -->|"add"| node_cart
node_cart -->|"checkout"| node_order
node_order -->|"pay"| node_payment
node_payment -->|"record"| node_history
node_seller_dash -->|"manage catalog"| node_seller_forms
node_seller_dash -->|"fulfill"| node_seller_orders
node_services -->|"returns"| node_models
node_services -->|"configures"| node_api_base
node_auth -.->|"auth api"| node_services
node_account -.->|"profile api"| node_services
node_canteens -.->|"catalog api"| node_services
node_cart -.->|"cart api"| node_services
node_payment -.->|"payment api"| node_services
node_seller_orders -.->|"order api"| node_services
node_history -.->|"history api"| node_services

click node_main "https://github.com/derisstrict/pnbfoods/blob/main/lib/main.dart"
click node_auth "https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/autentikasi.dart"
click node_login "https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/login_page.dart"
click node_role "https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/role_page.dart"
click node_account "https://github.com/derisstrict/pnbfoods/blob/main/lib/akun/akun_user.dart"
click node_home "https://github.com/derisstrict/pnbfoods/blob/main/lib/homepage/home.dart"
click node_shared_ui "https://github.com/derisstrict/pnbfoods/tree/main/lib/common"
click node_canteens "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_kantin/list_kantin.dart"
click node_products "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_produk/list_produk.dart"
click node_product_detail "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/deskripsi_makanan/deskripsi_makanan.dart"
click node_favorites "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/favorit/favorit_page.dart"
click node_cart "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/keranjang/page_keranjang.dart"
click node_order "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/order/page_order.dart"
click node_payment "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/pembayaran/page_pembayaran.dart"
click node_history "https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/riwayat/page_riwayat.dart"
click node_seller_dash "https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/dashboard/dashboard.dart"
click node_seller_forms "https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/form_kantin/form_kantin.dart"
click node_seller_orders "https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/pesanan/pesanan.dart"
click node_models "https://github.com/derisstrict/pnbfoods/tree/main/lib/models"
click node_services "https://github.com/derisstrict/pnbfoods/tree/main/lib/services"
click node_api_base "https://github.com/derisstrict/pnbfoods/blob/main/lib/services/base_url.dart"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_auth,node_login,node_role,node_account,node_home,node_shared_ui toneAmber
class node_canteens,node_products,node_product_detail,node_favorites,node_cart,node_order,node_payment,node_history toneMint
class node_seller_dash,node_seller_forms,node_seller_orders toneRose
class node_models,node_services,node_api_base toneIndigo
```

## Components

### App Shell

Cross-platform Flutter entrypoints and generated runners.

- [Main](https://github.com/derisstrict/pnbfoods/blob/main/lib/main.dart): Flutter entrypoint · Application bootstrap and startup routing. · `lib/main.dart`

### Core Client

Shared UI, auth, account, and home navigation.

- [Auth](https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/autentikasi.dart): login flow · Authentication and role selection boundary. · `lib/auth/autentikasi.dart`
- [Login](https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/login_page.dart): screen · User sign-in page. · `lib/auth/login_page.dart`
- [Role Select](https://github.com/derisstrict/pnbfoods/blob/main/lib/auth/role_page.dart): screen · Chooses buyer or seller experience. · `lib/auth/role_page.dart`
- [Account](https://github.com/derisstrict/pnbfoods/blob/main/lib/akun/akun_user.dart): profile mgmt · User profile editing and password change. · `lib/akun/akun_user.dart`
- [Home](https://github.com/derisstrict/pnbfoods/blob/main/lib/homepage/home.dart): navigation hub · Main landing screen after entry flow. · `lib/homepage/home.dart`
- [Shared UI](https://github.com/derisstrict/pnbfoods/tree/main/lib/common): widgets · Reusable forms, bars, buttons, and theme constants. · `lib/common`

### Buyer Flow

Customer-facing browsing, cart, checkout, payment, and history.

- [Canteens](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_kantin/list_kantin.dart): browse/catalog · Browse canteens and product listings. · `lib/pembeli/list_kantin/list_kantin.dart`
- [Products](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/list_produk/list_produk.dart): catalog browse · Product listing and product cards. · `lib/pembeli/list_produk/list_produk.dart`
- [Product Detail](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/deskripsi_makanan/deskripsi_makanan.dart): detail screen · Food description and item details. · `lib/pembeli/deskripsi_makanan/deskripsi_makanan.dart`
- [Favorites](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/favorit/favorit_page.dart): saved items · Buyer favorites and favorite toggle UI. · `lib/pembeli/favorit/favorit_page.dart`
- [Cart](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/keranjang/page_keranjang.dart): checkout prep · Cart review, pickup, payment method, and order summary. · `lib/pembeli/keranjang/page_keranjang.dart`
- [Order](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/order/page_order.dart): submit order · Order placement stage. · `lib/pembeli/order/page_order.dart`
- [Payment](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/pembayaran/page_pembayaran.dart): qris payment · QR payment, countdown expiry, and payment action. · `lib/pembeli/pembayaran/page_pembayaran.dart`
- [History](https://github.com/derisstrict/pnbfoods/blob/main/lib/pembeli/riwayat/page_riwayat.dart): transactions · Purchase history and receipt details. · `lib/pembeli/riwayat/page_riwayat.dart`

### Seller Flow

Merchant dashboard and fulfillment tools.

- [Seller Dash](https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/dashboard/dashboard.dart): merchant dashboard · Seller overview and operational hub. · `lib/penjual/dashboard/dashboard.dart`
- [Seller Forms](https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/form_kantin/form_kantin.dart): content mgmt · Canteen and product creation/editing screens. · `lib/penjual/form_kantin/form_kantin.dart`
- [Seller Orders](https://github.com/derisstrict/pnbfoods/blob/main/lib/penjual/pesanan/pesanan.dart): fulfillment · Incoming order inspection and order detail view. · `lib/penjual/pesanan/pesanan.dart`

### Data Layer

Shared domain models and API services.

- [Models](https://github.com/derisstrict/pnbfoods/tree/main/lib/models): domain objects · Shared entities for users, catalog, cart, orders, payments, and history. · `lib/models`
- [Services](https://github.com/derisstrict/pnbfoods/tree/main/lib/services): API access · Backend API boundary for all business capabilities. · `lib/services`
- [API Base](https://github.com/derisstrict/pnbfoods/blob/main/lib/services/base_url.dart): backend config · External backend endpoint configuration. · `lib/services/base_url.dart`

## Connections

- Main → Auth: boots · App starts in authentication and role routing.
- Auth → Login: sign-in · Authentication flow exposes login UI.
- Auth → Role Select: choose role · Routes users into buyer or seller experience.
- Auth → Home: enter app · Successful entry proceeds to main navigation.
- Home → Account: profile · Home connects to account management.
- Home → Canteens: browse · Buyer browsing starts from the home experience.
- Shared UI → Auth: supports · Shared widgets are used by authentication screens.
- Shared UI → Canteens: supports · Reusable UI supports buyer screens.
- Shared UI → Seller Dash: supports · Shared UI supports seller screens.
- Canteens → Products: explore · Canteen browsing leads into product lists.
- Products → Product Detail: open · Product list opens item detail views.
- Products → Favorites: save · Products can be added to favorites.
- Products → Cart: add · Products flow into cart and checkout.
- Cart → Order: checkout · Cart prepares and submits an order.
- Order → Payment: pay · Placed orders proceed to payment.
- Payment → History: record · Completed payments are reflected in history.
- Seller Dash → Seller Forms: manage catalog · Seller dashboard opens management forms.
- Seller Dash → Seller Orders: fulfill · Dashboard surfaces incoming orders.
- Services → Models: returns · API calls populate shared domain models.
- Services → API Base: configures · Services use the backend base URL.
- Auth → Services: auth api · Login and role flow depend on backend services.
- Account → Services: profile api · Account updates use service calls.
- Canteens → Services: catalog api · Buyer catalog screens fetch remote data.
- Cart → Services: cart api · Cart state is coordinated through services.
- Payment → Services: payment api · Payment stage talks to backend payment endpoints.
- Seller Orders → Services: order api · Seller fulfillment uses order services.
- History → Services: history api · History screens load transaction data from services.
