How shoaibfazeel/offline-billing-system works
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: DataService.js Data Service · App.js App Coordinator · BillHistory.js Bill History · ViewBill.js View Bill
Components 22
Electron Runtime
- Electron Main · Owns application lifecycle and native windows.
main.js - Preload Bridge · Boundary between renderer and Electron APIs.
preload.js - HTML Shell
index.html
React Renderer
- Renderer Entry · Mounts the React application.
src/index.js - App Coordinator · Composes navigation and operational screens.
src/App.js - Error Boundary · Contains renderer screen failures.
src/components/ErrorBoundary.js - Dashboard
src/components/Dashboard.js
Local Data Layer
- Data Service · Central business-data access and prior-pricing boundary.
src/services/DataService.js - Storage Service · Persists local state across sessions.
src/services/StorageService.js - Config Service
src/services/ConfigService.js
Business Workflows
- Inventory Management
src/components/InventoryManagement.js - Client Management
src/components/ClientManagement.js - Salesman Management
src/components/SalesmanManagement.js - Field Officer Management
src/components/FieldOfficerManagement.js - Bill Generation · Creates bills from clients, inventory, prices, discounts, and bonuses.
src/components/BillGeneration.js - Bill History
src/components/BillHistory.js - View Bill · Views or edits prior invoices.
src/components/ViewBill.js
Documents & Delivery
- Reports
src/components/Reports.js - PDF Generator · Renders invoice documents.
src/components/PdfGenerator.js - PDF Export Button · Triggers invoice PDF export.
src/components/GeneratePdfButton.js - Windows Build · Builds the Windows Electron distribution.
build-windows.js - Release Automation · Automates release delivery.
.github/workflows/release.yml
Connections 27
- 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