# shoaibfazeel/offline-billing-system architecture

> Architecture diagram of the GitHub repository shoaibfazeel/offline-billing-system, 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/shoaibfazeel/offline-billing-system
- Repository: https://github.com/shoaibfazeel/offline-billing-system

## Overview

#### Purpose and Runtime
Desktop, offline billing and inventory application. It manages products, clients, field officers/salesmen, invoices, history, reporting, and PDF export without an external database server. The runtime is Electron: the main process starts the desktop shell, while a React renderer provides the UI.
- `main.js`
- `preload.js`
- `src/index.js`

#### Application Entry and Process Boundary
`main.js` is the Electron entry point and owns native-window/application lifecycle concerns. `preload.js` is the renderer-to-Electron bridge boundary. The renderer mounts the React application from `src/index.js`, with the initial HTML shell in `index.html`.
- `main.js`
- `preload.js`
- `index.html`

#### Renderer Composition and Navigation
`src/App.js` is the top-level UI coordinator. It composes operational screens for dashboarding, billing, master-data administration, history, reports, and settings. `ErrorBoundary` contains renderer failures so a screen error does not necessarily terminate the desktop application.
- `src/App.js`
- `src/components/ErrorBoundary.js`
- `src/components/Dashboard.js`

#### Persistence and Data Access Layer
Business screens should access application state through the service layer rather than directly owning persistence mechanics. `DataService` is the central data-oriented abstraction; `StorageService` supports offline persistence across sessions; `ConfigService` handles application configuration. The stated database model is in-memory with persisted state, so durability is local-process/local-storage oriented rather than server-backed.
- `src/services/DataService.js`
- `src/services/StorageService.js`
- `src/services/ConfigService.js`

#### Master Data and Commercial Actors
Inventory and client records are the core inputs to billing. Dedicated components manage products, customers, and sales personnel/field officers; their updates feed bill creation and reporting flows.
- `src/components/InventoryManagement.js`
- `src/components/ClientManagement.js`
- `src/components/SalesmanManagement.js`
- `src/components/FieldOfficerManagement.js`

#### Billing Lifecycle
Bill generation selects a client and inventory items, captures quantities, rates, discounts, and non-totaling bonus items, then persists the resulting bill. Prior invoices are retrieved through history and can be viewed or edited. Client/product-specific prior pricing behavior belongs at the data-service boundary, not only in form state.
- `src/components/BillGeneration.js`
- `src/components/BillHistory.js`
- `src/components/ViewBill.js`

#### Documents, Reporting, and Distribution
Invoice document creation is separated into PDF rendering/generation and the user action that triggers export. Reports consume persisted operational data. Distribution is packaged as an Electron executable; Windows-specific build support and installer resources are present, with release automation in GitHub Actions.
- `src/components/PdfGenerator.js`
- `src/components/GeneratePdfButton.js`
- `src/components/Reports.js`
- `build-windows.js`
- `.github/workflows/release.yml`

Main entry points: [`src/services/DataService.js`](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/DataService.js) (Data Service), [`src/App.js`](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/App.js) (App Coordinator), [`src/components/BillHistory.js`](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/BillHistory.js) (Bill History), [`src/components/ViewBill.js`](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ViewBill.js) (View Bill)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Electron Runtime"]
  node_main{{"Electron Main<br/>Electron entry<br/>[main.js]"}}
  node_preload["Preload Bridge<br/>process bridge<br/>[preload.js]"]
  node_html["HTML Shell<br/>renderer shell<br/>[index.html]"]
end

subgraph group_renderer["React Renderer"]
  node_renderer_entry["Renderer Entry<br/>React entry<br/>[index.js]"]
  node_app["App Coordinator<br/>UI composition<br/>[App.js]"]
  node_error_boundary["Error Boundary<br/>failure boundary<br/>[ErrorBoundary.js]"]
  node_dashboard["Dashboard<br/>operational screen<br/>[Dashboard.js]"]
end

subgraph group_data["Local Data Layer"]
  node_data_service["Data Service<br/>data abstraction<br/>[DataService.js]"]
  node_storage_service[("Storage Service<br/>offline persistence<br/>[StorageService.js]")]
  node_config_service["Config Service<br/>configuration<br/>[ConfigService.js]"]
end

subgraph group_operations["Business Workflows"]
  node_inventory["Inventory Management<br/>master-data screen"]
  node_clients["Client Management<br/>master-data screen"]
  node_salesmen["Salesman Management<br/>master-data screen"]
  node_field_officers["Field Officer Management<br/>master-data screen"]
  node_billing["Bill Generation<br/>billing screen<br/>[BillGeneration.js]"]
  node_history["Bill History<br/>invoice history<br/>[BillHistory.js]"]
  node_view_bill["View Bill<br/>invoice viewer<br/>[ViewBill.js]"]
end

subgraph group_delivery["Documents &amp; Delivery"]
  node_reports["Reports<br/>reporting screen<br/>[Reports.js]"]
  node_pdf_generator["PDF Generator<br/>document renderer<br/>[PdfGenerator.js]"]
  node_pdf_export["PDF Export Button<br/>export action"]
  node_windows_build["Windows Build<br/>packaging script<br/>[build-windows.js]"]
  node_release_workflow["Release Automation<br/>CI workflow<br/>[release.yml]"]
end

node_main -->|"loads"| node_preload
node_main -->|"hosts"| node_html
node_preload -->|"bridges APIs"| node_renderer_entry
node_html -->|"mounts"| node_renderer_entry
node_renderer_entry -->|"renders"| node_app
node_app -->|"contains"| node_error_boundary
node_error_boundary -->|"protects"| node_dashboard
node_app -->|"navigates to"| node_billing
node_app -->|"navigates to"| node_history
node_app -->|"navigates to"| node_reports
node_app -->|"navigates to"| node_inventory
node_app -->|"navigates to"| node_clients
node_inventory -->|"manages products"| node_data_service
node_clients -->|"manages clients"| node_data_service
node_salesmen -->|"manages salesmen"| node_data_service
node_field_officers -->|"manages officers"| node_data_service
node_billing -->|"creates bills"| node_data_service
node_history -->|"retrieves invoices"| node_data_service
node_view_bill -->|"views and edits"| node_data_service
node_reports -->|"consumes operational data"| node_data_service
node_data_service -->|"persists state"| node_storage_service
node_data_service -->|"uses configuration"| node_config_service
node_history -->|"opens invoice"| node_view_bill
node_view_bill -->|"renders invoice"| node_pdf_generator
node_pdf_export -->|"triggers export"| node_pdf_generator
node_windows_build -.->|"packages"| node_main
node_release_workflow -.->|"runs release build"| node_windows_build

click node_main "https://github.com/shoaibfazeel/offline-billing-system/blob/main/main.js"
click node_preload "https://github.com/shoaibfazeel/offline-billing-system/blob/main/preload.js"
click node_html "https://github.com/shoaibfazeel/offline-billing-system/blob/main/index.html"
click node_renderer_entry "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/index.js"
click node_app "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/App.js"
click node_error_boundary "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ErrorBoundary.js"
click node_dashboard "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/Dashboard.js"
click node_data_service "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/DataService.js"
click node_storage_service "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/StorageService.js"
click node_config_service "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/ConfigService.js"
click node_inventory "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/InventoryManagement.js"
click node_clients "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ClientManagement.js"
click node_salesmen "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/SalesmanManagement.js"
click node_field_officers "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/FieldOfficerManagement.js"
click node_billing "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/BillGeneration.js"
click node_history "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/BillHistory.js"
click node_view_bill "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ViewBill.js"
click node_reports "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/Reports.js"
click node_pdf_generator "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/PdfGenerator.js"
click node_pdf_export "https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/GeneratePdfButton.js"
click node_windows_build "https://github.com/shoaibfazeel/offline-billing-system/blob/main/build-windows.js"
click node_release_workflow "https://github.com/shoaibfazeel/offline-billing-system/blob/main/.github/workflows/release.yml"

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,node_preload,node_html toneBlue
class node_renderer_entry,node_app,node_error_boundary,node_dashboard toneAmber
class node_data_service,node_storage_service,node_config_service toneMint
class node_inventory,node_clients,node_salesmen,node_field_officers,node_billing,node_history,node_view_bill toneRose
class node_reports,node_pdf_generator,node_pdf_export,node_windows_build,node_release_workflow toneIndigo
```

## Components

### Electron Runtime

- [Electron Main](https://github.com/shoaibfazeel/offline-billing-system/blob/main/main.js): Electron entry · Owns application lifecycle and native windows. · `main.js`
- [Preload Bridge](https://github.com/shoaibfazeel/offline-billing-system/blob/main/preload.js): process bridge · Boundary between renderer and Electron APIs. · `preload.js`
- [HTML Shell](https://github.com/shoaibfazeel/offline-billing-system/blob/main/index.html): renderer shell · `index.html`

### React Renderer

- [Renderer Entry](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/index.js): React entry · Mounts the React application. · `src/index.js`
- [App Coordinator](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/App.js): UI composition · Composes navigation and operational screens. · `src/App.js`
- [Error Boundary](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ErrorBoundary.js): failure boundary · Contains renderer screen failures. · `src/components/ErrorBoundary.js`
- [Dashboard](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/Dashboard.js): operational screen · `src/components/Dashboard.js`

### Local Data Layer

- [Data Service](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/DataService.js): data abstraction · Central business-data access and prior-pricing boundary. · `src/services/DataService.js`
- [Storage Service](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/StorageService.js): offline persistence · Persists local state across sessions. · `src/services/StorageService.js`
- [Config Service](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/services/ConfigService.js): configuration · `src/services/ConfigService.js`

### Business Workflows

- [Inventory Management](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/InventoryManagement.js): master-data screen · `src/components/InventoryManagement.js`
- [Client Management](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ClientManagement.js): master-data screen · `src/components/ClientManagement.js`
- [Salesman Management](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/SalesmanManagement.js): master-data screen · `src/components/SalesmanManagement.js`
- [Field Officer Management](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/FieldOfficerManagement.js): master-data screen · `src/components/FieldOfficerManagement.js`
- [Bill Generation](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/BillGeneration.js): billing screen · Creates bills from clients, inventory, prices, discounts, and bonuses. · `src/components/BillGeneration.js`
- [Bill History](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/BillHistory.js): invoice history · `src/components/BillHistory.js`
- [View Bill](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/ViewBill.js): invoice viewer · Views or edits prior invoices. · `src/components/ViewBill.js`

### Documents & Delivery

- [Reports](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/Reports.js): reporting screen · `src/components/Reports.js`
- [PDF Generator](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/PdfGenerator.js): document renderer · Renders invoice documents. · `src/components/PdfGenerator.js`
- [PDF Export Button](https://github.com/shoaibfazeel/offline-billing-system/blob/main/src/components/GeneratePdfButton.js): export action · Triggers invoice PDF export. · `src/components/GeneratePdfButton.js`
- [Windows Build](https://github.com/shoaibfazeel/offline-billing-system/blob/main/build-windows.js): packaging script · Builds the Windows Electron distribution. · `build-windows.js`
- [Release Automation](https://github.com/shoaibfazeel/offline-billing-system/blob/main/.github/workflows/release.yml): CI workflow · Automates release delivery. · `.github/workflows/release.yml`

## Connections

- Electron Main → Preload Bridge: loads
- Electron Main → HTML Shell: hosts
- Preload Bridge → Renderer Entry: bridges APIs
- HTML Shell → Renderer Entry: mounts
- Renderer Entry → App Coordinator: renders
- App Coordinator → Error Boundary: contains
- Error Boundary → Dashboard: protects
- App Coordinator → Bill Generation: navigates to
- App Coordinator → Bill History: navigates to
- App Coordinator → Reports: navigates to
- App Coordinator → Inventory Management: navigates to
- App Coordinator → Client Management: navigates to
- Inventory Management → Data Service: manages products
- Client Management → Data Service: manages clients
- Salesman Management → Data Service: manages salesmen
- Field Officer Management → Data Service: manages officers
- Bill Generation → Data Service: creates bills
- Bill History → Data Service: retrieves invoices
- View Bill → Data Service: views and edits
- Reports → Data Service: consumes operational data
- Data Service → Storage Service: persists state
- Data Service → Config Service: uses configuration
- Bill History → View Bill: opens invoice
- View Bill → PDF Generator: renders invoice
- PDF Export Button → PDF Generator: triggers export
- Windows Build → Electron Main: packages
- Release Automation → Windows Build: runs release build
