# mkmehmood/sarim architecture

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

- Interactive diagram: https://gitdiagram.com/mkmehmood/sarim
- Repository: https://github.com/mkmehmood/sarim

## Overview

This repository implements a multi-store sales, production, customer, representative, and finance management app. Users enter operational records through the business modules; those modules validate links and balances, save records locally, and synchronize changes across devices. The graph preserves the major domain areas and the data/sync layer. Evidence is limited to the README (empty) and sampled excerpts plus the SOURCE INDEX; unsampled modules are represented only where the tree establishes their presence, without speculative call edges.

Main entry points: [`modules/main.js`](https://github.com/mkmehmood/sarim/blob/main/modules/main.js) (Module bootstrap), [`modules/sync.js`](https://github.com/mkmehmood/sarim/blob/main/modules/sync.js) (Cloud synchronization), [`modules/factory.js`](https://github.com/mkmehmood/sarim/blob/main/modules/factory.js) (Factory inventory), [`modules/customers.js`](https://github.com/mkmehmood/sarim/blob/main/modules/customers.js) (Customer records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry"]
  node_entrypoint["Module bootstrap<br/>[main.js]"]
end

subgraph group_operations["Business operations"]
  node_admin["Admin records<br/>[admin-data.js]"]
  node_sales["Sales and calculations<br/>[utilities-sales.js]"]
  node_payments["Payments and expenses"]
  node_customers["Customer records<br/>[customers.js]"]
  node_factory["Factory inventory<br/>[factory.js]"]
  node_representatives["Representative sales<br/>[rep-sales.js]"]
  node_photos["Production photos<br/>[prod-photos.js]"]
  node_finance["Finance rules<br/>[finance.js]"]
end

subgraph group_records["Record integrity"]
  node_graph["Record relationships<br/>[link-graph.js]"]
  node_guards["Link validation<br/>[link-guards.js]"]
  node_confirm["Save confirmation<br/>[confirm-guard.js]"]
  node_edit["Edit state<br/>[edit-mode.js]"]
  node_storekeys["Store identity<br/>[store-keys.js]"]
end

subgraph group_data["Data and sync"]
  node_business["Business context<br/>[business.js]"]
  node_sync["Cloud synchronization<br/>[sync.js]"]
  node_localdata["Local data and utilities<br/>[utilities-core.js]"]
  node_formula["Formula storage<br/>[formula-store.js]"]
end

subgraph group_experience["App experience"]
  node_notifications["Notifications<br/>[notify.js]"]
  node_dialogs["Dialogs and feedback<br/>[dialog.js]"]
  node_feedback["Feedback UI<br/>[feedback.js]"]
  node_datepicker["Date selection"]
  node_pdf["PDF rendering<br/>[pdf-canvas.js]"]
  node_native["Native capabilities<br/>[native.js]"]
end

node_user(("App user"))
node_cloud[("Cloud backend")]
node_localstore[("Local database")]

node_user -.->|"opens app"| node_entrypoint
node_entrypoint -->|"initializes"| node_business
node_entrypoint -->|"loads"| node_admin
node_entrypoint -->|"loads"| node_sync
node_entrypoint -->|"loads"| node_localdata
node_entrypoint -->|"loads"| node_sales
node_entrypoint -->|"loads"| node_payments
node_entrypoint -->|"loads"| node_customers
node_entrypoint -->|"loads"| node_formula
node_entrypoint -->|"loads"| node_factory
node_entrypoint -->|"loads"| node_representatives
node_entrypoint -->|"loads"| node_photos
node_entrypoint -->|"loads"| node_datepicker
node_sales -->|"serializes calls"| node_graph
node_payments -->|"plans settlements"| node_graph
node_payments -->|"checks settlement"| node_guards
node_sales -->|"emits updates"| node_sync
node_sales -->|"refreshes payments"| node_payments
node_sales -->|"syncs tabs"| node_localdata
node_sales -->|"reads business data"| node_business
node_payments -->|"reads business data"| node_business
node_payments -->|"refreshes views"| node_representatives
node_localdata -->|"pushes changes"| node_sync
node_localdata -->|"loads records"| node_business
node_localdata -->|"validates formula stock"| node_factory
node_localdata -->|"shows toast"| node_customers
node_sync -->|"loads data"| node_business
node_sync -->|"refreshes views"| node_payments
node_sync -->|"renders inventory"| node_factory
node_sync -->|"shows toast"| node_customers
node_sync -.->|"syncs data"| node_cloud
node_business -->|"loads UI state"| node_localdata
node_business -.->|"reads and writes"| node_localstore
node_customers -->|"checks sale deletion"| node_guards
node_customers -->|"uses balance rules"| node_business
node_customers -->|"gets sale values"| node_factory
node_customers -->|"uses blocking dialog"| node_dialogs
node_representatives -->|"saves transactions"| node_sync
node_representatives -->|"guards sale saves"| node_confirm
node_representatives -->|"gets sale price"| node_factory
node_representatives -->|"shows confirmation"| node_customers
node_representatives -->|"notifies changes"| node_localdata
node_factory -->|"saves inventory"| node_sync
node_factory -->|"finds payable links"| node_graph
node_factory -->|"refreshes payment view"| node_payments
node_factory -->|"calculates net cash"| node_sales
node_factory -->|"requests confirmation"| node_customers
node_guards -->|"remaps references"| node_graph

click node_entrypoint "https://github.com/mkmehmood/sarim/blob/main/modules/main.js"
click node_business "https://github.com/mkmehmood/sarim/blob/main/modules/business.js"
click node_admin "https://github.com/mkmehmood/sarim/blob/main/modules/admin-data.js"
click node_sales "https://github.com/mkmehmood/sarim/blob/main/modules/utilities-sales.js"
click node_payments "https://github.com/mkmehmood/sarim/blob/main/modules/utilities-payments.js"
click node_customers "https://github.com/mkmehmood/sarim/blob/main/modules/customers.js"
click node_factory "https://github.com/mkmehmood/sarim/blob/main/modules/factory.js"
click node_representatives "https://github.com/mkmehmood/sarim/blob/main/modules/rep-sales.js"
click node_photos "https://github.com/mkmehmood/sarim/blob/main/modules/prod-photos.js"
click node_finance "https://github.com/mkmehmood/sarim/blob/main/modules/finance.js"
click node_graph "https://github.com/mkmehmood/sarim/blob/main/modules/link-graph.js"
click node_guards "https://github.com/mkmehmood/sarim/blob/main/modules/link-guards.js"
click node_confirm "https://github.com/mkmehmood/sarim/blob/main/modules/confirm-guard.js"
click node_edit "https://github.com/mkmehmood/sarim/blob/main/modules/edit-mode.js"
click node_storekeys "https://github.com/mkmehmood/sarim/blob/main/modules/store-keys.js"
click node_sync "https://github.com/mkmehmood/sarim/blob/main/modules/sync.js"
click node_localdata "https://github.com/mkmehmood/sarim/blob/main/modules/utilities-core.js"
click node_formula "https://github.com/mkmehmood/sarim/blob/main/modules/formula-store.js"
click node_notifications "https://github.com/mkmehmood/sarim/blob/main/modules/notify.js"
click node_dialogs "https://github.com/mkmehmood/sarim/blob/main/modules/dialog.js"
click node_feedback "https://github.com/mkmehmood/sarim/blob/main/modules/feedback.js"
click node_datepicker "https://github.com/mkmehmood/sarim/blob/main/modules/custom-date-picker.js"
click node_pdf "https://github.com/mkmehmood/sarim/blob/main/modules/pdf-canvas.js"
click node_native "https://github.com/mkmehmood/sarim/blob/main/modules/native.js"

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_entrypoint,node_user toneBlue
class node_admin,node_sales,node_payments,node_customers,node_factory,node_representatives,node_photos,node_finance,node_cloud,node_localstore toneAmber
class node_graph,node_guards,node_confirm,node_edit,node_storekeys toneMint
class node_business,node_sync,node_localdata,node_formula toneRose
class node_notifications,node_dialogs,node_feedback,node_datepicker,node_pdf,node_native toneIndigo
```

## Components

### App entry

- [Module bootstrap](https://github.com/mkmehmood/sarim/blob/main/modules/main.js): `modules/main.js`

### Business operations

- [Admin records](https://github.com/mkmehmood/sarim/blob/main/modules/admin-data.js): `modules/admin-data.js`
- [Sales and calculations](https://github.com/mkmehmood/sarim/blob/main/modules/utilities-sales.js): `modules/utilities-sales.js`
- [Payments and expenses](https://github.com/mkmehmood/sarim/blob/main/modules/utilities-payments.js): `modules/utilities-payments.js`
- [Customer records](https://github.com/mkmehmood/sarim/blob/main/modules/customers.js): `modules/customers.js`
- [Factory inventory](https://github.com/mkmehmood/sarim/blob/main/modules/factory.js): `modules/factory.js`
- [Representative sales](https://github.com/mkmehmood/sarim/blob/main/modules/rep-sales.js): `modules/rep-sales.js`
- [Production photos](https://github.com/mkmehmood/sarim/blob/main/modules/prod-photos.js): `modules/prod-photos.js`
- [Finance rules](https://github.com/mkmehmood/sarim/blob/main/modules/finance.js): `modules/finance.js`

### Record integrity

- [Record relationships](https://github.com/mkmehmood/sarim/blob/main/modules/link-graph.js): `modules/link-graph.js`
- [Link validation](https://github.com/mkmehmood/sarim/blob/main/modules/link-guards.js): `modules/link-guards.js`
- [Save confirmation](https://github.com/mkmehmood/sarim/blob/main/modules/confirm-guard.js): `modules/confirm-guard.js`
- [Edit state](https://github.com/mkmehmood/sarim/blob/main/modules/edit-mode.js): `modules/edit-mode.js`
- [Store identity](https://github.com/mkmehmood/sarim/blob/main/modules/store-keys.js): `modules/store-keys.js`

### Data and sync

- [Business context](https://github.com/mkmehmood/sarim/blob/main/modules/business.js): `modules/business.js`
- [Cloud synchronization](https://github.com/mkmehmood/sarim/blob/main/modules/sync.js): `modules/sync.js`
- [Local data and utilities](https://github.com/mkmehmood/sarim/blob/main/modules/utilities-core.js): `modules/utilities-core.js`
- [Formula storage](https://github.com/mkmehmood/sarim/blob/main/modules/formula-store.js): `modules/formula-store.js`

### App experience

- [Notifications](https://github.com/mkmehmood/sarim/blob/main/modules/notify.js): `modules/notify.js`
- [Dialogs and feedback](https://github.com/mkmehmood/sarim/blob/main/modules/dialog.js): `modules/dialog.js`
- [Feedback UI](https://github.com/mkmehmood/sarim/blob/main/modules/feedback.js): `modules/feedback.js`
- [Date selection](https://github.com/mkmehmood/sarim/blob/main/modules/custom-date-picker.js): `modules/custom-date-picker.js`
- [PDF rendering](https://github.com/mkmehmood/sarim/blob/main/modules/pdf-canvas.js): `modules/pdf-canvas.js`
- [Native capabilities](https://github.com/mkmehmood/sarim/blob/main/modules/native.js): `modules/native.js`

### Other components

- **App user**
- **Cloud backend**
- **Local database**

## Connections

- App user → Module bootstrap: opens app
- Module bootstrap → Business context: initializes (evidence: `modules/main.js`)
- Module bootstrap → Admin records: loads (evidence: `modules/main.js`)
- Module bootstrap → Cloud synchronization: loads (evidence: `modules/main.js`)
- Module bootstrap → Local data and utilities: loads (evidence: `modules/main.js`)
- Module bootstrap → Sales and calculations: loads (evidence: `modules/main.js`)
- Module bootstrap → Payments and expenses: loads (evidence: `modules/main.js`)
- Module bootstrap → Customer records: loads (evidence: `modules/main.js`)
- Module bootstrap → Formula storage: loads (evidence: `modules/main.js`)
- Module bootstrap → Factory inventory: loads (evidence: `modules/main.js`)
- Module bootstrap → Representative sales: loads (evidence: `modules/main.js`)
- Module bootstrap → Production photos: loads (evidence: `modules/main.js`)
- Module bootstrap → Date selection: loads (evidence: `modules/main.js`)
- Sales and calculations → Record relationships: serializes calls (evidence: `modules/utilities-sales.js`)
- Payments and expenses → Record relationships: plans settlements (evidence: `modules/utilities-payments.js`)
- Payments and expenses → Link validation: checks settlement (evidence: `modules/utilities-payments.js`)
- Sales and calculations → Cloud synchronization: emits updates (evidence: `modules/utilities-sales.js`)
- Sales and calculations → Payments and expenses: refreshes payments (evidence: `modules/utilities-sales.js`)
- Sales and calculations → Local data and utilities: syncs tabs (evidence: `modules/utilities-sales.js`)
- Sales and calculations → Business context: reads business data (evidence: `modules/utilities-sales.js`)
- Payments and expenses → Business context: reads business data (evidence: `modules/utilities-payments.js`)
- Payments and expenses → Representative sales: refreshes views (evidence: `modules/utilities-payments.js`)
- Local data and utilities → Cloud synchronization: pushes changes (evidence: `modules/utilities-core.js`)
- Local data and utilities → Business context: loads records (evidence: `modules/utilities-core.js`)
- Local data and utilities → Factory inventory: validates formula stock (evidence: `modules/utilities-core.js`)
- Local data and utilities → Customer records: shows toast (evidence: `modules/utilities-core.js`)
- Cloud synchronization → Business context: loads data (evidence: `modules/sync.js`)
- Cloud synchronization → Payments and expenses: refreshes views (evidence: `modules/sync.js`)
- Cloud synchronization → Factory inventory: renders inventory (evidence: `modules/sync.js`)
- Cloud synchronization → Customer records: shows toast (evidence: `modules/sync.js`)
- Cloud synchronization → Cloud backend: syncs data
- Business context → Local data and utilities: loads UI state (evidence: `modules/business.js`)
- Business context → Local database: reads and writes
- Customer records → Link validation: checks sale deletion (evidence: `modules/customers.js`)
- Customer records → Business context: uses balance rules (evidence: `modules/customers.js`)
- Customer records → Factory inventory: gets sale values (evidence: `modules/customers.js`)
- Customer records → Dialogs and feedback: uses blocking dialog (evidence: `modules/customers.js`)
- Representative sales → Cloud synchronization: saves transactions (evidence: `modules/rep-sales.js`)
- Representative sales → Save confirmation: guards sale saves (evidence: `modules/rep-sales.js`)
- Representative sales → Factory inventory: gets sale price (evidence: `modules/rep-sales.js`)
- Representative sales → Customer records: shows confirmation (evidence: `modules/rep-sales.js`)
- Representative sales → Local data and utilities: notifies changes (evidence: `modules/rep-sales.js`)
- Factory inventory → Cloud synchronization: saves inventory (evidence: `modules/factory.js`)
- Factory inventory → Record relationships: finds payable links (evidence: `modules/factory.js`)
- Factory inventory → Payments and expenses: refreshes payment view (evidence: `modules/factory.js`)
- Factory inventory → Sales and calculations: calculates net cash (evidence: `modules/factory.js`)
- Factory inventory → Customer records: requests confirmation (evidence: `modules/factory.js`)
- Link validation → Record relationships: remaps references (evidence: `modules/link-guards.js`)
