# agila-learning/weighment-gst-desktop-app architecture

> Architecture diagram of the GitHub repository agila-learning/weighment-gst-desktop-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agila-learning/weighment-gst-desktop-app
- Repository: https://github.com/agila-learning/weighment-gst-desktop-app

## Overview

This repository contains a GST billing desktop app and a weighbridge desktop app backed by a shared API and database. The GST workflow covers customer and vehicle setup, billing, invoices, payments, and reports. The weighbridge workflow captures device readings, manages weighments and pending records, and supports history and reporting, with offline caching and synchronization. The backend also exposes shared master-data, audit, import/export, permit-card, and reporting capabilities. Connections for unsampled route implementations are limited to backend registration and documented module references.

Main entry points: [`frontend-gst/src/App.tsx`](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/App.tsx) (GST app routing), [`frontend-weighbridge/src/App.tsx`](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/App.tsx) (Weighbridge app routing), [`frontend-weighbridge/src/pages/Weighment.tsx`](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/Weighment.tsx) (Weighment capture), [`backend/src/routes`](https://github.com/agila-learning/weighment-gst-desktop-app/tree/main/backend/src/routes) (Domain API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gst["GST billing"]
  node_gst_app["GST app routing<br/>[App.tsx]"]
  node_gst_masters["Customer and vehicle setup<br/>[Customers.tsx]"]
  node_gst_billing["Billing<br/>[Billing.tsx]"]
  node_gst_invoices["Invoices<br/>[Invoices.tsx]"]
  node_gst_reports["Reports and payments<br/>[Reports.tsx]"]
  node_gst_settings["Settings and data<br/>[Settings.tsx]"]
  node_gst_client["API client<br/>[client.ts]"]
end

subgraph group_wb["Weighbridge operations"]
  node_wb_app["Weighbridge app routing<br/>[App.tsx]"]
  node_wb_device["Scale device service"]
  node_wb_hardware["Device implementations"]
  node_wb_capture["Weighment capture<br/>[Weighment.tsx]"]
  node_wb_history["History and pending<br/>[History.tsx]"]
  node_wb_masters["Weighbridge masters<br/>[Customers.tsx]"]
  node_wb_reports["Weighbridge reports<br/>[Reports.tsx]"]
  node_wb_sync["Offline synchronization<br/>[SyncService.ts]"]
  node_wb_api["API service<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_backend_entry["HTTP application<br/>[index.ts]"]
  node_backend_auth["Authentication<br/>[auth.ts]"]
  node_backend_routes["Domain API routes"]
  node_permit["Permit cards"]
end

subgraph group_data["Persistence and output"]
  node_prisma["Prisma data access<br/>[prisma.ts]"]
  node_db[("PostgreSQL database")]
  node_offline_db[("Local SQLite cache<br/>[database.ts]")]
  node_pdf["PDF generation<br/>[pdfGenerator.ts]"]
end

node_gst_user(("Billing user"))
node_wb_user(("Weighbridge operator"))

node_gst_user -->|"uses"| node_gst_app
node_gst_app -->|"routes to"| node_gst_masters
node_gst_app -->|"routes to"| node_gst_billing
node_gst_app -->|"routes to"| node_gst_invoices
node_gst_app -->|"routes to"| node_gst_reports
node_gst_app -->|"routes to"| node_gst_settings
node_gst_masters -->|"calls"| node_gst_client
node_gst_billing -->|"calls"| node_gst_client
node_gst_billing -->|"uses preview"| node_pdf
node_gst_client -.->|"sends API requests"| node_backend_entry
node_wb_user -->|"uses"| node_wb_app
node_wb_app -->|"routes to"| node_wb_capture
node_wb_app -->|"routes to"| node_wb_history
node_wb_app -->|"routes to"| node_wb_masters
node_wb_app -->|"routes to"| node_wb_reports
node_wb_capture -->|"reads weights"| node_wb_device
node_wb_device -->|"instantiates"| node_wb_hardware
node_wb_capture -->|"uses"| node_wb_sync
node_wb_capture -->|"calls"| node_wb_api
node_wb_masters -->|"calls"| node_wb_api
node_wb_sync -->|"syncs through"| node_wb_api
node_wb_sync -->|"reads and writes"| node_offline_db
node_wb_api -.->|"sends API requests"| node_backend_entry
node_backend_entry -->|"mounts"| node_backend_routes
node_backend_routes -.->|"uses"| node_backend_auth
node_backend_routes -.->|"queries"| node_prisma
node_backend_routes -->|"routes permit requests"| node_permit
node_permit -->|"reads and writes"| node_prisma
node_permit -->|"generates permit PDF"| node_pdf
node_prisma -->|"accesses"| node_db

click node_gst_app "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/App.tsx"
click node_gst_masters "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Customers.tsx"
click node_gst_billing "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Billing.tsx"
click node_gst_invoices "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Invoices.tsx"
click node_gst_reports "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Reports.tsx"
click node_gst_settings "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Settings.tsx"
click node_gst_client "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/api/client.ts"
click node_wb_app "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/App.tsx"
click node_wb_device "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/WeighbridgeDeviceService.ts"
click node_wb_hardware "https://github.com/agila-learning/weighment-gst-desktop-app/tree/main/frontend-weighbridge/src/services/hardware/devices"
click node_wb_capture "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/Weighment.tsx"
click node_wb_history "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/History.tsx"
click node_wb_masters "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/masters/Customers.tsx"
click node_wb_reports "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/reports/Reports.tsx"
click node_wb_sync "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/SyncService.ts"
click node_wb_api "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/api.ts"
click node_backend_entry "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/index.ts"
click node_backend_auth "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/middleware/auth.ts"
click node_backend_routes "https://github.com/agila-learning/weighment-gst-desktop-app/tree/main/backend/src/routes"
click node_permit "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/controllers/permitCardController.ts"
click node_prisma "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/prisma.ts"
click node_offline_db "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/electron/database.ts"
click node_pdf "https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/utils/pdfGenerator.ts"

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_gst_app,node_gst_masters,node_gst_billing,node_gst_invoices,node_gst_reports,node_gst_settings,node_gst_client,node_gst_user toneBlue
class node_wb_app,node_wb_device,node_wb_hardware,node_wb_capture,node_wb_history,node_wb_masters,node_wb_reports,node_wb_sync,node_wb_api toneAmber
class node_backend_entry,node_backend_auth,node_backend_routes,node_permit toneMint
class node_prisma,node_db,node_offline_db,node_pdf toneRose
class node_wb_user toneIndigo
```

## Components

### GST billing

- [GST app routing](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/App.tsx): `frontend-gst/src/App.tsx`
- [Customer and vehicle setup](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Customers.tsx): `frontend-gst/src/pages/Customers.tsx`
- [Billing](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Billing.tsx): `frontend-gst/src/pages/Billing.tsx`
- [Invoices](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Invoices.tsx): `frontend-gst/src/pages/Invoices.tsx`
- [Reports and payments](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Reports.tsx): `frontend-gst/src/pages/Reports.tsx`
- [Settings and data](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/pages/Settings.tsx): `frontend-gst/src/pages/Settings.tsx`
- [API client](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-gst/src/api/client.ts): `frontend-gst/src/api/client.ts`

### Weighbridge operations

- [Weighbridge app routing](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/App.tsx): `frontend-weighbridge/src/App.tsx`
- [Scale device service](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/WeighbridgeDeviceService.ts): `frontend-weighbridge/src/services/WeighbridgeDeviceService.ts`
- [Device implementations](https://github.com/agila-learning/weighment-gst-desktop-app/tree/main/frontend-weighbridge/src/services/hardware/devices): `frontend-weighbridge/src/services/hardware/devices`
- [Weighment capture](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/Weighment.tsx): `frontend-weighbridge/src/pages/Weighment.tsx`
- [History and pending](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/History.tsx): `frontend-weighbridge/src/pages/History.tsx`
- [Weighbridge masters](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/masters/Customers.tsx): `frontend-weighbridge/src/pages/masters/Customers.tsx`
- [Weighbridge reports](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/pages/reports/Reports.tsx): `frontend-weighbridge/src/pages/reports/Reports.tsx`
- [Offline synchronization](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/SyncService.ts): `frontend-weighbridge/src/services/SyncService.ts`
- [API service](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/src/services/api.ts): `frontend-weighbridge/src/services/api.ts`

### Backend API

- [HTTP application](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Authentication](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [Domain API routes](https://github.com/agila-learning/weighment-gst-desktop-app/tree/main/backend/src/routes): `backend/src/routes`
- [Permit cards](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/controllers/permitCardController.ts): `backend/src/controllers/permitCardController.ts`

### Persistence and output

- [Prisma data access](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/prisma.ts): `backend/src/prisma.ts`
- **PostgreSQL database**
- [Local SQLite cache](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/frontend-weighbridge/electron/database.ts): `frontend-weighbridge/electron/database.ts`
- [PDF generation](https://github.com/agila-learning/weighment-gst-desktop-app/blob/main/backend/src/utils/pdfGenerator.ts): `backend/src/utils/pdfGenerator.ts`

### Other components

- **Billing user**
- **Weighbridge operator**

## Connections

- Billing user → GST app routing: uses
- GST app routing → Customer and vehicle setup: routes to (evidence: `frontend-gst/src/App.tsx`)
- GST app routing → Billing: routes to (evidence: `frontend-gst/src/App.tsx`)
- GST app routing → Invoices: routes to (evidence: `frontend-gst/src/App.tsx`)
- GST app routing → Reports and payments: routes to (evidence: `frontend-gst/src/App.tsx`)
- GST app routing → Settings and data: routes to (evidence: `frontend-gst/src/App.tsx`)
- Customer and vehicle setup → API client: calls (evidence: `frontend-gst/src/pages/Customers.tsx`)
- Billing → API client: calls (evidence: `frontend-gst/src/pages/Billing.tsx`)
- Billing → PDF generation: uses preview (evidence: `frontend-gst/src/pages/Billing.tsx`)
- API client → HTTP application: sends API requests
- Weighbridge operator → Weighbridge app routing: uses
- Weighbridge app routing → Weighment capture: routes to (evidence: `frontend-weighbridge/src/App.tsx`)
- Weighbridge app routing → History and pending: routes to (evidence: `frontend-weighbridge/src/App.tsx`)
- Weighbridge app routing → Weighbridge masters: routes to (evidence: `frontend-weighbridge/src/App.tsx`)
- Weighbridge app routing → Weighbridge reports: routes to (evidence: `frontend-weighbridge/src/App.tsx`)
- Weighment capture → Scale device service: reads weights (evidence: `frontend-weighbridge/src/pages/Weighment.tsx`)
- Scale device service → Device implementations: instantiates (evidence: `frontend-weighbridge/src/services/WeighbridgeDeviceService.ts`)
- Weighment capture → Offline synchronization: uses (evidence: `frontend-weighbridge/src/pages/Weighment.tsx`)
- Weighment capture → API service: calls (evidence: `frontend-weighbridge/src/pages/Weighment.tsx`)
- Weighbridge masters → API service: calls (evidence: `frontend-weighbridge/src/pages/masters/Customers.tsx`)
- Offline synchronization → API service: syncs through (evidence: `frontend-weighbridge/src/services/SyncService.ts`)
- Offline synchronization → Local SQLite cache: reads and writes (evidence: `frontend-weighbridge/src/services/SyncService.ts`)
- API service → HTTP application: sends API requests
- HTTP application → Domain API routes: mounts (evidence: `backend/src/index.ts`)
- Domain API routes → Authentication: uses (evidence: `backend/src/routes/permitCardRoutes.ts`)
- Domain API routes → Prisma data access: queries (evidence: `backend/src/routes/auth.ts`)
- Domain API routes → Permit cards: routes permit requests (evidence: `backend/src/routes/permitCardRoutes.ts`)
- Permit cards → Prisma data access: reads and writes (evidence: `backend/src/controllers/permitCardController.ts`)
- Permit cards → PDF generation: generates permit PDF (evidence: `backend/src/controllers/permitCardController.ts`)
- Prisma data access → PostgreSQL database: accesses (evidence: `backend/src/prisma.ts`)
