# med-mohamedb/betterstore architecture

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

- Interactive diagram: https://gitdiagram.com/med-mohamedb/betterstore
- Repository: https://github.com/med-mohamedb/betterstore
- Video tour (about a minute): https://gitdiagram.com/med-mohamedb/betterstore/video

## Overview

Better Store is a mobile-friendly store-management and point-of-sale app: staff navigate its web app to manage products, stock, sales, and purchasing, with business data persisted locally. The workflow spans checkout and receipts as well as inventory and reporting; supporting capabilities include backup, scanning, language settings, promotions, and native printing. The tree and excerpts establish the app shell, product persistence, and printer bridge; several other modules are represented by their listed paths, but their internal wiring was not sampled.

Main entry points: [`www/app.js`](https://github.com/med-mohamedb/betterstore/blob/main/www/app.js) (App shell), [`android/app/src/main/java/com/mohaab/storeapp/MainActivity.kt`](https://github.com/med-mohamedb/betterstore/blob/main/android/app/src/main/java/com/mohaab/storeapp/MainActivity.kt) (Android host), [`www/printer.js`](https://github.com/med-mohamedb/betterstore/blob/main/www/printer.js) (Receipt printing), [`www/products.js`](https://github.com/med-mohamedb/betterstore/blob/main/www/products.js) (Products)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_shell["App shell<br/>[app.js]"]
  node_onboarding["Onboarding<br/>[onboarding.js]"]
  node_language["Language<br/>[i18n.js]"]
end

subgraph group_commerce["Store operations"]
  node_pos["Point of sale<br/>[pos.js]"]
  node_products["Products<br/>[products.js]"]
  node_inventory["Inventory<br/>[inventory.js]"]
  node_sales["Sales<br/>[sales.js]"]
  node_customers["Customers<br/>[customers.js]"]
  node_suppliers["Suppliers<br/>[suppliers.js]"]
  node_purchases["Purchase orders<br/>[purchaseorders.js]"]
end

subgraph group_data["Data and insights"]
  node_accounting["Accounting<br/>[accounting.js]"]
  node_reports["Reports<br/>[reports.js]"]
  node_stats["Statistics<br/>[stats.js]"]
  node_database[("Local data<br/>[db.js]")]
  node_backup["Backup and restore<br/>[backup.js]"]
end

subgraph group_support["Device and support"]
  node_scanner["Barcode scanning<br/>[scanner.js]"]
  node_settings["Settings<br/>[settings.js]"]
  node_promotions["Promotions<br/>[shopPromo.js]"]
  node_admob["AdMob<br/>[adMob.js]"]
  node_adnotify["Ad notifications<br/>[adNotify.js]"]
  node_update["Self update<br/>[selfUpdate.js]"]
  node_printer["Receipt printing<br/>[printer.js]"]
end

subgraph group_native["Android services"]
  node_android["Android host<br/>[MainActivity.kt]"]
  node_thermal["Thermal printer bridge"]
end

node_staff(("Store staff"))
node_firebase["Firebase messaging"]

node_staff -->|"uses"| node_shell
node_shell -->|"shows"| node_onboarding
node_shell -->|"initializes"| node_language
node_shell -->|"reads"| node_settings
node_shell -->|"routes to"| node_pos
node_shell -->|"routes to"| node_products
node_shell -->|"routes to"| node_sales
node_products -->|"reads and writes"| node_database
node_android -->|"hosts web app"| node_shell
node_android -->|"registers"| node_thermal
node_printer -->|"reads config"| node_settings
node_printer -->|"sends print jobs"| node_thermal
node_android -->|"subscribes to topics"| node_firebase

click node_shell "https://github.com/med-mohamedb/betterstore/blob/main/www/app.js"
click node_onboarding "https://github.com/med-mohamedb/betterstore/blob/main/www/onboarding.js"
click node_language "https://github.com/med-mohamedb/betterstore/blob/main/www/i18n.js"
click node_pos "https://github.com/med-mohamedb/betterstore/blob/main/www/pos.js"
click node_products "https://github.com/med-mohamedb/betterstore/blob/main/www/products.js"
click node_inventory "https://github.com/med-mohamedb/betterstore/blob/main/www/inventory.js"
click node_sales "https://github.com/med-mohamedb/betterstore/blob/main/www/sales.js"
click node_customers "https://github.com/med-mohamedb/betterstore/blob/main/www/customers.js"
click node_suppliers "https://github.com/med-mohamedb/betterstore/blob/main/www/suppliers.js"
click node_purchases "https://github.com/med-mohamedb/betterstore/blob/main/www/purchaseorders.js"
click node_accounting "https://github.com/med-mohamedb/betterstore/blob/main/www/accounting.js"
click node_reports "https://github.com/med-mohamedb/betterstore/blob/main/www/reports.js"
click node_stats "https://github.com/med-mohamedb/betterstore/blob/main/www/stats.js"
click node_database "https://github.com/med-mohamedb/betterstore/blob/main/www/db.js"
click node_backup "https://github.com/med-mohamedb/betterstore/blob/main/www/backup.js"
click node_scanner "https://github.com/med-mohamedb/betterstore/blob/main/www/scanner.js"
click node_settings "https://github.com/med-mohamedb/betterstore/blob/main/www/settings.js"
click node_promotions "https://github.com/med-mohamedb/betterstore/blob/main/www/shopPromo.js"
click node_admob "https://github.com/med-mohamedb/betterstore/blob/main/www/adMob.js"
click node_adnotify "https://github.com/med-mohamedb/betterstore/blob/main/www/adNotify.js"
click node_update "https://github.com/med-mohamedb/betterstore/blob/main/www/selfUpdate.js"
click node_printer "https://github.com/med-mohamedb/betterstore/blob/main/www/printer.js"
click node_android "https://github.com/med-mohamedb/betterstore/blob/main/android/app/src/main/java/com/mohaab/storeapp/MainActivity.kt"
click node_thermal "https://github.com/med-mohamedb/betterstore/blob/main/android/app/src/main/java/com/mohaab/storeapp/ThermalPrinterPlugin.kt"

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_shell,node_onboarding,node_language toneBlue
class node_pos,node_products,node_inventory,node_sales,node_customers,node_suppliers,node_purchases toneAmber
class node_accounting,node_reports,node_stats,node_database,node_backup toneMint
class node_scanner,node_settings,node_promotions,node_admob,node_adnotify,node_update,node_printer toneRose
class node_android,node_thermal,node_staff,node_firebase toneIndigo
```

## Components

### App experience

- [App shell](https://github.com/med-mohamedb/betterstore/blob/main/www/app.js): `www/app.js`
- [Onboarding](https://github.com/med-mohamedb/betterstore/blob/main/www/onboarding.js): `www/onboarding.js`
- [Language](https://github.com/med-mohamedb/betterstore/blob/main/www/i18n.js): `www/i18n.js`

### Store operations

- [Point of sale](https://github.com/med-mohamedb/betterstore/blob/main/www/pos.js): `www/pos.js`
- [Products](https://github.com/med-mohamedb/betterstore/blob/main/www/products.js): `www/products.js`
- [Inventory](https://github.com/med-mohamedb/betterstore/blob/main/www/inventory.js): `www/inventory.js`
- [Sales](https://github.com/med-mohamedb/betterstore/blob/main/www/sales.js): `www/sales.js`
- [Customers](https://github.com/med-mohamedb/betterstore/blob/main/www/customers.js): `www/customers.js`
- [Suppliers](https://github.com/med-mohamedb/betterstore/blob/main/www/suppliers.js): `www/suppliers.js`
- [Purchase orders](https://github.com/med-mohamedb/betterstore/blob/main/www/purchaseorders.js): `www/purchaseorders.js`

### Data and insights

- [Accounting](https://github.com/med-mohamedb/betterstore/blob/main/www/accounting.js): `www/accounting.js`
- [Reports](https://github.com/med-mohamedb/betterstore/blob/main/www/reports.js): `www/reports.js`
- [Statistics](https://github.com/med-mohamedb/betterstore/blob/main/www/stats.js): `www/stats.js`
- [Local data](https://github.com/med-mohamedb/betterstore/blob/main/www/db.js): `www/db.js`
- [Backup and restore](https://github.com/med-mohamedb/betterstore/blob/main/www/backup.js): `www/backup.js`

### Device and support

- [Barcode scanning](https://github.com/med-mohamedb/betterstore/blob/main/www/scanner.js): `www/scanner.js`
- [Settings](https://github.com/med-mohamedb/betterstore/blob/main/www/settings.js): `www/settings.js`
- [Promotions](https://github.com/med-mohamedb/betterstore/blob/main/www/shopPromo.js): `www/shopPromo.js`
- [AdMob](https://github.com/med-mohamedb/betterstore/blob/main/www/adMob.js): `www/adMob.js`
- [Ad notifications](https://github.com/med-mohamedb/betterstore/blob/main/www/adNotify.js): `www/adNotify.js`
- [Self update](https://github.com/med-mohamedb/betterstore/blob/main/www/selfUpdate.js): `www/selfUpdate.js`
- [Receipt printing](https://github.com/med-mohamedb/betterstore/blob/main/www/printer.js): `www/printer.js`

### Android services

- [Android host](https://github.com/med-mohamedb/betterstore/blob/main/android/app/src/main/java/com/mohaab/storeapp/MainActivity.kt): `android/app/src/main/java/com/mohaab/storeapp/MainActivity.kt`
- [Thermal printer bridge](https://github.com/med-mohamedb/betterstore/blob/main/android/app/src/main/java/com/mohaab/storeapp/ThermalPrinterPlugin.kt): `android/app/src/main/java/com/mohaab/storeapp/ThermalPrinterPlugin.kt`

### Other components

- **Store staff**
- **Firebase messaging**

## Connections

- Store staff → App shell: uses
- App shell → Onboarding: shows
- App shell → Language: initializes
- App shell → Settings: reads
- App shell → Point of sale: routes to
- App shell → Products: routes to
- App shell → Sales: routes to
- Products → Local data: reads and writes
- Android host → App shell: hosts web app
- Android host → Thermal printer bridge: registers
- Receipt printing → Settings: reads config
- Receipt printing → Thermal printer bridge: sends print jobs
- Android host → Firebase messaging: subscribes to topics
