# yandihanid/yandihan-app architecture

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

- Interactive diagram: https://gitdiagram.com/yandihanid/yandihan-app
- Repository: https://github.com/yandihanid/yandihan-app

## Overview

#### Purpose and Runtime
Yandihan Kasir is a Next.js App Router cashier/POS application with public checkout links, merchant dashboard management, payments, customer/loyalty support, receipts, and reporting. It runs as a Node/Next.js web application and can be packaged for Android through Capacitor.
- `app/layout.js`
- `app/page.js`
- `package.json`
- `capacitor.config.ts`

#### User-Facing Entry Points
The root page, login/signup, and guide establish the public web entry flow. Authenticated merchant functionality is grouped under the dashboard layout. Tokenized cashier pages appear intended for customer- or cashier-specific transaction entry, while receipt URLs expose a printable transaction result.
- `app/login/page.js`
- `app/signup/page.js`
- `app/dashboard/layout.js`
- `app/c/[token]/page.js`
- `app/r/[id]/page.js`

#### Cashier and Transaction Flow
The tokenized cashier route contains the transaction UI, cashier actions, and a waiting-list view. Its client flow calls the cashier API, then payment APIs for payment creation and verification. Payment webhook handling forms the asynchronous external-provider boundary; downstream transaction updates can be reflected on the dashboard in real time.
- `app/c/[token]/CashierForm.js`
- `app/c/[token]/actions.js`
- `app/api/cashier/route.js`
- `app/api/payment/route.js`
- `app/api/payment/verify/route.js`
- `app/api/payment/webhook/route.js`
- `app/dashboard/RealtimeTransactions.js`

#### Merchant Operations and Reporting
The dashboard is the merchant control plane: overview, transaction reporting, product management, customer management, cashier assignment, and store/receipt settings. Server-side action modules sit alongside dashboard forms, separating interactive administration from API endpoints.
- `app/dashboard/page.js`
- `app/dashboard/laporan/page.js`
- `app/dashboard/produk/page.js`
- `app/dashboard/produk/actions.js`
- `app/dashboard/pelanggan/page.js`
- `app/dashboard/settings/actions.js`

#### Data and Service Boundary
Supabase is the persistence and likely authentication/backend service boundary, accessed through separate browser, server, and privileged service clients. API routes provide controlled HTTP access for customers, store state, pricing, and settings. The loyalty-customer migration indicates schema evolution is stored with the repository.
- `utils/supabase/client.js`
- `utils/supabase/server.js`
- `utils/supabase/service.js`
- `supabase/migrations/add_loyalty_customers.sql`
- `app/api/pelanggan/route.js`
- `app/api/store/my/route.js`

#### Payments, Pricing, and Subscription Concerns
Payment lifecycle endpoints isolate initiation, verification, and provider callbacks. Pricing is represented both as API data and shared constants/UI, while the dashboard includes an upgrade prompt. The concrete payment provider is not identifiable from the supplied tree.
- `app/api/payment/route.js`
- `app/api/payment/verify/route.js`
- `app/api/payment/webhook/route.js`
- `app/api/pricing/route.js`
- `lib/pricingConstants.js`
- `app/dashboard/UpgradeBanner.js`

#### Integrations and Delivery Surfaces
Telegram is an inbound webhook integration. The web app includes manifest and service-worker assets for installable/offline-oriented browser delivery. Capacitor wraps the web bundle in a native Android host whose entry activity loads the Capacitor application.
- `app/api/telegram/webhook/route.js`
- `public/manifest.json`
- `public/sw.js`
- `android/app/src/main/java/com/yandihan/kasir/MainActivity.java`
- `android/app/src/main/AndroidManifest.xml`

Main entry points: [`utils/supabase/server.js`](https://github.com/yandihanid/yandihan-app/blob/main/utils/supabase/server.js) (Supabase backend), [`app/dashboard/layout.js`](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/layout.js) (Dashboard shell), [`app/layout.js`](https://github.com/yandihanid/yandihan-app/blob/main/app/layout.js) (App shell), [`app/api/payment/route.js`](https://github.com/yandihanid/yandihan-app/blob/main/app/api/payment/route.js) (Payment lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js Web App"]
  node_app_shell["App shell<br/>Next.js layout<br/>[layout.js]"]
  node_public_entry["Public entry<br/>landing page<br/>[page.js]"]
  node_auth_pages["Login &amp; signup<br/>auth pages<br/>[page.js]"]
  node_cashier_route["Tokenized cashier<br/>checkout route<br/>[page.js]"]
  node_cashier_form["Cashier transaction UI<br/>client form<br/>[CashierForm.js]"]
  node_receipt["Printable receipt<br/>receipt route<br/>[page.js]"]
end

subgraph group_dashboard["Merchant Dashboard"]
  node_dashboard_layout["Dashboard shell<br/>authenticated layout<br/>[layout.js]"]
  node_dashboard_overview["Dashboard overview<br/>merchant console<br/>[page.js]"]
  node_reports["Transaction reports<br/>reporting page<br/>[page.js]"]
  node_catalog_admin["Product management<br/>dashboard module<br/>[actions.js]"]
  node_customer_admin["Customer management<br/>dashboard page<br/>[page.js]"]
  node_realtime_transactions["Realtime transactions<br/>dashboard component"]
end

subgraph group_backend["Backend Services"]
  node_cashier_api{{"Cashier API<br/>route handler<br/>[route.js]"}}
  node_payment_lifecycle{{"Payment lifecycle<br/>payment APIs<br/>[route.js]"}}
  node_merchant_apis{{"Merchant state APIs<br/>route handlers<br/>[route.js]"}}
  node_supabase[("Supabase backend<br/>auth &amp; persistence<br/>[server.js]")]
end

subgraph group_integrations["External &amp; Delivery"]
  node_payment_provider(("Payment provider<br/>external provider"))
  node_telegram{{"Telegram webhook<br/>inbound integration<br/>[route.js]"}}
  node_pwa["PWA delivery<br/>manifest &amp; service worker<br/>[manifest.json]"]
  node_android["Android host<br/>Capacitor activity<br/>[MainActivity.java]"]
end

node_app_shell -->|"renders"| node_public_entry
node_public_entry -->|"sign-in flow"| node_auth_pages
node_app_shell -->|"serves"| node_cashier_route
node_cashier_route -->|"hosts"| node_cashier_form
node_cashier_form -->|"submits transaction"| node_cashier_api
node_cashier_form -->|"initiates payment"| node_payment_lifecycle
node_payment_lifecycle -->|"creates/verifies"| node_payment_provider
node_payment_provider -.->|"webhook callback"| node_payment_lifecycle
node_cashier_api -->|"reads/writes"| node_supabase
node_payment_lifecycle -->|"updates transaction"| node_supabase
node_supabase -.->|"transaction updates"| node_realtime_transactions
node_dashboard_layout -->|"contains"| node_dashboard_overview
node_dashboard_layout -->|"contains"| node_reports
node_dashboard_layout -->|"contains"| node_catalog_admin
node_dashboard_layout -->|"contains"| node_customer_admin
node_dashboard_overview -->|"shows"| node_realtime_transactions
node_catalog_admin -->|"manages catalog"| node_supabase
node_customer_admin -->|"uses"| node_merchant_apis
node_merchant_apis -->|"accesses state"| node_supabase
node_cashier_api -.->|"produces transaction"| node_receipt
node_telegram -->|"processes inbound events"| node_supabase
node_pwa -.->|"installs web app"| node_app_shell
node_android -.->|"wraps web bundle"| node_app_shell

click node_app_shell "https://github.com/yandihanid/yandihan-app/blob/main/app/layout.js"
click node_public_entry "https://github.com/yandihanid/yandihan-app/blob/main/app/page.js"
click node_auth_pages "https://github.com/yandihanid/yandihan-app/blob/main/app/login/page.js"
click node_cashier_route "https://github.com/yandihanid/yandihan-app/blob/main/app/c/%5Btoken%5D/page.js"
click node_cashier_form "https://github.com/yandihanid/yandihan-app/blob/main/app/c/%5Btoken%5D/CashierForm.js"
click node_receipt "https://github.com/yandihanid/yandihan-app/blob/main/app/r/%5Bid%5D/page.js"
click node_dashboard_layout "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/layout.js"
click node_dashboard_overview "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/page.js"
click node_reports "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/laporan/page.js"
click node_catalog_admin "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/produk/actions.js"
click node_customer_admin "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/pelanggan/page.js"
click node_realtime_transactions "https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/RealtimeTransactions.js"
click node_cashier_api "https://github.com/yandihanid/yandihan-app/blob/main/app/api/cashier/route.js"
click node_payment_lifecycle "https://github.com/yandihanid/yandihan-app/blob/main/app/api/payment/route.js"
click node_merchant_apis "https://github.com/yandihanid/yandihan-app/blob/main/app/api/pelanggan/route.js"
click node_supabase "https://github.com/yandihanid/yandihan-app/blob/main/utils/supabase/server.js"
click node_telegram "https://github.com/yandihanid/yandihan-app/blob/main/app/api/telegram/webhook/route.js"
click node_pwa "https://github.com/yandihanid/yandihan-app/blob/main/public/manifest.json"
click node_android "https://github.com/yandihanid/yandihan-app/blob/main/android/app/src/main/java/com/yandihan/kasir/MainActivity.java"

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_app_shell,node_public_entry,node_auth_pages,node_cashier_route,node_cashier_form,node_receipt toneBlue
class node_dashboard_layout,node_dashboard_overview,node_reports,node_catalog_admin,node_customer_admin,node_realtime_transactions toneAmber
class node_cashier_api,node_payment_lifecycle,node_merchant_apis,node_supabase toneMint
class node_payment_provider,node_telegram,node_pwa,node_android toneRose
```

## Components

### Next.js Web App

Public, cashier, and merchant App Router surfaces.

- [App shell](https://github.com/yandihanid/yandihan-app/blob/main/app/layout.js): Next.js layout · `app/layout.js`
- [Public entry](https://github.com/yandihanid/yandihan-app/blob/main/app/page.js): landing page · Links users into sign-in and merchant flows. · `app/page.js`
- [Login & signup](https://github.com/yandihanid/yandihan-app/blob/main/app/login/page.js): auth pages · `app/login/page.js`
- [Tokenized cashier](https://github.com/yandihanid/yandihan-app/blob/main/app/c/%5Btoken%5D/page.js): checkout route · Transaction entry is scoped by a cashier token. · `app/c/[token]/page.js`
- [Cashier transaction UI](https://github.com/yandihanid/yandihan-app/blob/main/app/c/%5Btoken%5D/CashierForm.js): client form · `app/c/[token]/CashierForm.js`
- [Printable receipt](https://github.com/yandihanid/yandihan-app/blob/main/app/r/%5Bid%5D/page.js): receipt route · `app/r/[id]/page.js`

### Merchant Dashboard

Authenticated operations and reporting.

- [Dashboard shell](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/layout.js): authenticated layout · `app/dashboard/layout.js`
- [Dashboard overview](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/page.js): merchant console · `app/dashboard/page.js`
- [Transaction reports](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/laporan/page.js): reporting page · `app/dashboard/laporan/page.js`
- [Product management](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/produk/actions.js): dashboard module · Uses colocated server actions for catalog changes. · `app/dashboard/produk/actions.js`
- [Customer management](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/pelanggan/page.js): dashboard page · `app/dashboard/pelanggan/page.js`
- [Realtime transactions](https://github.com/yandihanid/yandihan-app/blob/main/app/dashboard/RealtimeTransactions.js): dashboard component · Reflects downstream transaction updates. · `app/dashboard/RealtimeTransactions.js`

### Backend Services

HTTP boundaries and Supabase-backed state.

- [Cashier API](https://github.com/yandihanid/yandihan-app/blob/main/app/api/cashier/route.js): route handler · `app/api/cashier/route.js`
- [Payment lifecycle](https://github.com/yandihanid/yandihan-app/blob/main/app/api/payment/route.js): payment APIs · Creates and verifies payments; receives provider callbacks. · `app/api/payment/route.js`
- [Merchant state APIs](https://github.com/yandihanid/yandihan-app/blob/main/app/api/pelanggan/route.js): route handlers · Controlled access to customer and store state. · `app/api/pelanggan/route.js`
- [Supabase backend](https://github.com/yandihanid/yandihan-app/blob/main/utils/supabase/server.js): auth & persistence · Browser, server, and privileged clients access the backend. · `utils/supabase/server.js`

### External & Delivery

Provider callbacks and installable/native delivery.

- **Payment provider**: external provider · Concrete provider is not identified.
- [Telegram webhook](https://github.com/yandihanid/yandihan-app/blob/main/app/api/telegram/webhook/route.js): inbound integration · `app/api/telegram/webhook/route.js`
- [PWA delivery](https://github.com/yandihanid/yandihan-app/blob/main/public/manifest.json): manifest & service worker · Installable browser delivery surface. · `public/manifest.json`
- [Android host](https://github.com/yandihanid/yandihan-app/blob/main/android/app/src/main/java/com/yandihan/kasir/MainActivity.java): Capacitor activity · Native wrapper loads the Capacitor application. · `android/app/src/main/java/com/yandihan/kasir/MainActivity.java`

## Connections

- App shell → Public entry: renders
- Public entry → Login & signup: sign-in flow
- App shell → Tokenized cashier: serves
- Tokenized cashier → Cashier transaction UI: hosts
- Cashier transaction UI → Cashier API: submits transaction
- Cashier transaction UI → Payment lifecycle: initiates payment
- Payment lifecycle → Payment provider: creates/verifies
- Payment provider → Payment lifecycle: webhook callback
- Cashier API → Supabase backend: reads/writes
- Payment lifecycle → Supabase backend: updates transaction
- Supabase backend → Realtime transactions: transaction updates
- Dashboard shell → Dashboard overview: contains
- Dashboard shell → Transaction reports: contains
- Dashboard shell → Product management: contains
- Dashboard shell → Customer management: contains
- Dashboard overview → Realtime transactions: shows
- Product management → Supabase backend: manages catalog
- Customer management → Merchant state APIs: uses
- Merchant state APIs → Supabase backend: accesses state
- Cashier API → Printable receipt: produces transaction
- Telegram webhook → Supabase backend: processes inbound events
- PWA delivery → App shell: installs web app
- Android host → App shell: wraps web bundle
