# mohd-azim/pharmaspot architecture

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

- Interactive diagram: https://gitdiagram.com/mohd-azim/pharmaspot
- Repository: https://github.com/mohd-azim/pharmaspot

## Overview

PharmaSpot is an Electron-based pharmacy point-of-sale application with an Express API and local NeDB persistence. The principal workflow is staff using the POS to find products, build and pay for a sale, record a transaction, and update stock; the README also describes customer orders, receipts, account permissions, transaction filtering, and stock/expiry alerts. API mounting and transaction-to-inventory calls are visible in the excerpts. The frontend-to-API connection and several README capabilities are represented at their documented subsystem level because their implementation was not sampled.

Main entry points: [`server.js`](https://github.com/mohd-azim/pharmaspot/blob/main/server.js) (HTTP API server), [`renderer.js`](https://github.com/mohd-azim/pharmaspot/blob/main/renderer.js) (UI bootstrap), [`assets/js/pos.js`](https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/pos.js) (Point of sale), [`start.js`](https://github.com/mohd-azim/pharmaspot/blob/main/start.js) (Electron window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop runtime"]
  node_electron["Electron window<br/>[start.js]"]
  node_squirrel["Install event handling<br/>[setupEvents.js]"]
  node_renderer["UI bootstrap<br/>[renderer.js]"]
end

subgraph group_sales["Sales experience"]
  node_pos["Point of sale<br/>[pos.js]"]
  node_product_filter["Product search<br/>[product-filter.js]"]
  node_checkout["Checkout and receipts<br/>[checkout.js]"]
end

subgraph group_domain["Business APIs"]
  node_server["HTTP API server<br/>[server.js]"]
  node_inventory["Inventory and alerts<br/>[inventory.js]"]
  node_transactions["Transactions and orders<br/>[transactions.js]"]
  node_customers["Customer records<br/>[customers.js]"]
  node_categories["Product categories<br/>[categories.js]"]
  node_users["Staff accounts<br/>[users.js]"]
  node_settings["Store settings<br/>[settings.js]"]
end

subgraph group_records["Local records"]
  node_inventory_db[("Inventory database<br/>[inventory.js]")]
  node_transactions_db[("Transaction database<br/>[transactions.js]")]
  node_customers_db[("Customer database<br/>[customers.js]")]
  node_categories_db[("Category database<br/>[categories.js]")]
  node_users_db[("User database<br/>[users.js]")]
  node_settings_db[("Settings database<br/>[settings.js]")]
end

node_staff(("Pharmacy staff"))

node_electron -->|"checks install events"| node_squirrel
node_electron -->|"starts"| node_server
node_electron -.->|"loads UI"| node_renderer
node_renderer -->|"loads"| node_pos
node_renderer -->|"loads"| node_product_filter
node_renderer -->|"loads"| node_checkout
node_staff -.->|"uses"| node_pos
node_pos -.->|"searches with"| node_product_filter
node_pos -.->|"initiates checkout"| node_checkout
node_checkout -.->|"submits sale"| node_server
node_server -->|"mounts route"| node_inventory
node_server -->|"mounts route"| node_customers
node_server -->|"mounts route"| node_categories
node_server -->|"mounts route"| node_settings
node_server -->|"mounts route"| node_users
node_server -->|"mounts route"| node_transactions
node_transactions -->|"decrements stock"| node_inventory
node_inventory -->|"reads and writes"| node_inventory_db
node_transactions -->|"reads and writes"| node_transactions_db
node_customers -->|"reads and writes"| node_customers_db
node_categories -->|"reads and writes"| node_categories_db
node_users -->|"reads and writes"| node_users_db
node_settings -->|"reads and writes"| node_settings_db

click node_electron "https://github.com/mohd-azim/pharmaspot/blob/main/start.js"
click node_squirrel "https://github.com/mohd-azim/pharmaspot/blob/main/installers/setupEvents.js"
click node_renderer "https://github.com/mohd-azim/pharmaspot/blob/main/renderer.js"
click node_pos "https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/pos.js"
click node_product_filter "https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/product-filter.js"
click node_checkout "https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/checkout.js"
click node_server "https://github.com/mohd-azim/pharmaspot/blob/main/server.js"
click node_inventory "https://github.com/mohd-azim/pharmaspot/blob/main/api/inventory.js"
click node_transactions "https://github.com/mohd-azim/pharmaspot/blob/main/api/transactions.js"
click node_customers "https://github.com/mohd-azim/pharmaspot/blob/main/api/customers.js"
click node_categories "https://github.com/mohd-azim/pharmaspot/blob/main/api/categories.js"
click node_users "https://github.com/mohd-azim/pharmaspot/blob/main/api/users.js"
click node_settings "https://github.com/mohd-azim/pharmaspot/blob/main/api/settings.js"
click node_inventory_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/inventory.js"
click node_transactions_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/transactions.js"
click node_customers_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/customers.js"
click node_categories_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/categories.js"
click node_users_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/users.js"
click node_settings_db "https://github.com/mohd-azim/pharmaspot/blob/main/api/settings.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_electron,node_squirrel,node_renderer toneBlue
class node_pos,node_product_filter,node_checkout toneAmber
class node_server,node_inventory,node_transactions,node_customers,node_categories,node_users,node_settings toneMint
class node_inventory_db,node_transactions_db,node_customers_db,node_categories_db,node_users_db,node_settings_db toneRose
class node_staff toneIndigo
```

## Components

### Desktop runtime

- [Electron window](https://github.com/mohd-azim/pharmaspot/blob/main/start.js): `start.js`
- [Install event handling](https://github.com/mohd-azim/pharmaspot/blob/main/installers/setupEvents.js): `installers/setupEvents.js`
- [UI bootstrap](https://github.com/mohd-azim/pharmaspot/blob/main/renderer.js): `renderer.js`

### Sales experience

- [Point of sale](https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/pos.js): `assets/js/pos.js`
- [Product search](https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/product-filter.js): `assets/js/product-filter.js`
- [Checkout and receipts](https://github.com/mohd-azim/pharmaspot/blob/main/assets/js/checkout.js): `assets/js/checkout.js`

### Business APIs

- [HTTP API server](https://github.com/mohd-azim/pharmaspot/blob/main/server.js): `server.js`
- [Inventory and alerts](https://github.com/mohd-azim/pharmaspot/blob/main/api/inventory.js): `api/inventory.js`
- [Transactions and orders](https://github.com/mohd-azim/pharmaspot/blob/main/api/transactions.js): `api/transactions.js`
- [Customer records](https://github.com/mohd-azim/pharmaspot/blob/main/api/customers.js): `api/customers.js`
- [Product categories](https://github.com/mohd-azim/pharmaspot/blob/main/api/categories.js): `api/categories.js`
- [Staff accounts](https://github.com/mohd-azim/pharmaspot/blob/main/api/users.js): `api/users.js`
- [Store settings](https://github.com/mohd-azim/pharmaspot/blob/main/api/settings.js): `api/settings.js`

### Local records

- [Inventory database](https://github.com/mohd-azim/pharmaspot/blob/main/api/inventory.js): `api/inventory.js`
- [Transaction database](https://github.com/mohd-azim/pharmaspot/blob/main/api/transactions.js): `api/transactions.js`
- [Customer database](https://github.com/mohd-azim/pharmaspot/blob/main/api/customers.js): `api/customers.js`
- [Category database](https://github.com/mohd-azim/pharmaspot/blob/main/api/categories.js): `api/categories.js`
- [User database](https://github.com/mohd-azim/pharmaspot/blob/main/api/users.js): `api/users.js`
- [Settings database](https://github.com/mohd-azim/pharmaspot/blob/main/api/settings.js): `api/settings.js`

### Other components

- **Pharmacy staff**

## Connections

- Electron window → Install event handling: checks install events (evidence: `start.js`)
- Electron window → HTTP API server: starts (evidence: `start.js`)
- Electron window → UI bootstrap: loads UI
- UI bootstrap → Point of sale: loads (evidence: `renderer.js`)
- UI bootstrap → Product search: loads (evidence: `renderer.js`)
- UI bootstrap → Checkout and receipts: loads (evidence: `renderer.js`)
- Pharmacy staff → Point of sale: uses
- Point of sale → Product search: searches with
- Point of sale → Checkout and receipts: initiates checkout
- Checkout and receipts → HTTP API server: submits sale
- HTTP API server → Inventory and alerts: mounts route (evidence: `server.js`)
- HTTP API server → Customer records: mounts route (evidence: `server.js`)
- HTTP API server → Product categories: mounts route (evidence: `server.js`)
- HTTP API server → Store settings: mounts route (evidence: `server.js`)
- HTTP API server → Staff accounts: mounts route (evidence: `server.js`)
- HTTP API server → Transactions and orders: mounts route (evidence: `server.js`)
- Transactions and orders → Inventory and alerts: decrements stock (evidence: `api/transactions.js`)
- Inventory and alerts → Inventory database: reads and writes (evidence: `api/inventory.js`)
- Transactions and orders → Transaction database: reads and writes (evidence: `api/transactions.js`)
- Customer records → Customer database: reads and writes (evidence: `api/customers.js`)
- Product categories → Category database: reads and writes (evidence: `api/categories.js`)
- Staff accounts → User database: reads and writes (evidence: `api/users.js`)
- Store settings → Settings database: reads and writes (evidence: `api/settings.js`)
