# dextarfinity/elishen-agrivance architecture

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

- Interactive diagram: https://gitdiagram.com/dextarfinity/elishen-agrivance
- Repository: https://github.com/dextarfinity/elishen-agrivance

## Overview

Elishen Agrivance is a sales and inventory management system: staff use a shared web UI to record sales and purchasing, manage inventory and customer records, track payments, and produce operational documents and reports. The web UI and packaged Electron/Capacitor clients call a Node API backed by PostgreSQL. The README also documents Customer Information Sheets, store visits, receivables, pricing, and stocktake capabilities; several are represented at the UI or API subsystem level because their implementation excerpts are incomplete. Relationships are limited to calls or architecture explicitly evidenced by excerpts and README statements.

Main entry points: [`backend/index.js`](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js) (Node API), [`app/index.html`](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/index.html) (Web application), [`app/views.js`](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/views.js) (View rendering), [`app/app.js`](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/app.js) (UI workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web["Web application<br/>[index.html]"]
  node_views["View rendering<br/>[views.js]"]
  node_events["UI workflows<br/>[app.js]"]
  node_api_client["API client<br/>[api.js]"]
  node_desktop["Desktop client<br/>[main.js]"]
  node_mobile["Mobile client<br/>[MainActivity.java]"]
end

subgraph group_operations["Sales operations"]
  node_sales["Sales and orders<br/>[index.js]"]
  node_purchasing["Purchasing<br/>[index.js]"]
  node_inventory["Inventory and stocktake<br/>[index.js]"]
  node_pricing["Price management<br/>[index.js]"]
  node_fulfillment["Deliveries and receipts<br/>[index.js]"]
  node_print["Print documents<br/>[print.js]"]
end

subgraph group_records["Customer and finance"]
  node_customers["Customers and CIS<br/>[index.js]"]
  node_visits["Store visits<br/>[index.js]"]
  node_receivables["Receivables and payments<br/>[index.js]"]
  node_finance["Accounts and expenses<br/>[index.js]"]
  node_reports["Reports<br/>[index.js]"]
end

subgraph group_server["API and persistence"]
  node_server["Node API<br/>[index.js]"]
  node_database[("PostgreSQL<br/>[schema.sql]")]
end

node_staff(("Staff users"))
node_lan(("LAN / domain clients"))

node_staff -->|"uses"| node_web
node_web -->|"renders"| node_views
node_web -->|"wires actions"| node_events
node_events -->|"calls"| node_api_client
node_desktop -->|"loads UI"| node_web
node_mobile -->|"wraps UI"| node_web
node_web -->|"HTTP requests"| node_server
node_desktop -->|"API requests"| node_server
node_mobile -->|"API requests"| node_server
node_lan -->|"connects"| node_server
node_server -->|"queries"| node_database
node_events -->|"submits sales"| node_sales
node_events -->|"records visits"| node_visits
node_views -->|"loads sales"| node_sales
node_views -->|"loads customers"| node_customers
node_views -->|"loads stock"| node_inventory
node_views -->|"loads accounts"| node_finance
node_print -->|"reads delivery data"| node_fulfillment
node_print -->|"prints sheets"| node_customers
node_print -->|"prints statements"| node_receivables
node_server -->|"serves price history"| node_pricing
node_server -->|"handles sales"| node_sales
node_server -->|"serves deliveries"| node_fulfillment
node_purchasing -.->|"updates stock"| node_inventory
node_reports -.->|"summarizes stock"| node_inventory
node_receivables -.->|"tracks balances"| node_sales
node_server -.->|"handles purchasing"| node_purchasing
node_server -.->|"handles inventory"| node_inventory
node_server -.->|"handles customer sheets"| node_customers
node_server -.->|"handles visits"| node_visits
node_server -.->|"handles payments"| node_receivables
node_server -.->|"handles finance"| node_finance
node_server -.->|"serves reports"| node_reports

click node_web "https://github.com/dextarfinity/elishen-agrivance/blob/main/app/index.html"
click node_views "https://github.com/dextarfinity/elishen-agrivance/blob/main/app/views.js"
click node_events "https://github.com/dextarfinity/elishen-agrivance/blob/main/app/app.js"
click node_api_client "https://github.com/dextarfinity/elishen-agrivance/blob/main/app/api.js"
click node_desktop "https://github.com/dextarfinity/elishen-agrivance/blob/main/electron/main.js"
click node_mobile "https://github.com/dextarfinity/elishen-agrivance/blob/main/capacitor/android/app/src/main/java/com/elishen/agrivance/MainActivity.java"
click node_sales "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_purchasing "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_inventory "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_pricing "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_fulfillment "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_print "https://github.com/dextarfinity/elishen-agrivance/blob/main/app/print.js"
click node_customers "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_visits "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_receivables "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_finance "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_reports "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_server "https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js"
click node_database "https://github.com/dextarfinity/elishen-agrivance/blob/main/db/schema.sql"

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_web,node_views,node_events,node_api_client,node_desktop,node_mobile,node_staff,node_lan toneBlue
class node_sales,node_purchasing,node_inventory,node_pricing,node_fulfillment,node_print toneAmber
class node_customers,node_visits,node_receivables,node_finance,node_reports toneMint
class node_server,node_database toneRose
```

## Components

### User clients

- [Web application](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/index.html): `app/index.html`
- [View rendering](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/views.js): `app/views.js`
- [UI workflows](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/app.js): `app/app.js`
- [API client](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/api.js): `app/api.js`
- [Desktop client](https://github.com/dextarfinity/elishen-agrivance/blob/main/electron/main.js): `electron/main.js`
- [Mobile client](https://github.com/dextarfinity/elishen-agrivance/blob/main/capacitor/android/app/src/main/java/com/elishen/agrivance/MainActivity.java): `capacitor/android/app/src/main/java/com/elishen/agrivance/MainActivity.java`

### Sales operations

- [Sales and orders](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Purchasing](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Inventory and stocktake](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Price management](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Deliveries and receipts](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Print documents](https://github.com/dextarfinity/elishen-agrivance/blob/main/app/print.js): `app/print.js`

### Customer and finance

- [Customers and CIS](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Store visits](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Receivables and payments](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Accounts and expenses](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [Reports](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`

### API and persistence

- [Node API](https://github.com/dextarfinity/elishen-agrivance/blob/main/backend/index.js): `backend/index.js`
- [PostgreSQL](https://github.com/dextarfinity/elishen-agrivance/blob/main/db/schema.sql): `db/schema.sql`

### Other components

- **Staff users**
- **LAN / domain clients**

## Connections

- Staff users → Web application: uses (evidence: `README.md`)
- Web application → View rendering: renders (evidence: `app/views.js`)
- Web application → UI workflows: wires actions (evidence: `app/app.js`)
- UI workflows → API client: calls (evidence: `app/app.js`)
- Desktop client → Web application: loads UI (evidence: `electron/main.js`)
- Mobile client → Web application: wraps UI (evidence: `README.md`)
- Web application → Node API: HTTP requests (evidence: `README.md`)
- Desktop client → Node API: API requests (evidence: `README.md`)
- Mobile client → Node API: API requests (evidence: `README.md`)
- LAN / domain clients → Node API: connects (evidence: `README.md`)
- Node API → PostgreSQL: queries (evidence: `backend/index.js`)
- UI workflows → Sales and orders: submits sales (evidence: `app/app.js`)
- UI workflows → Store visits: records visits (evidence: `app/app.js`)
- View rendering → Sales and orders: loads sales (evidence: `app/views.js`)
- View rendering → Customers and CIS: loads customers (evidence: `app/views.js`)
- View rendering → Inventory and stocktake: loads stock (evidence: `app/views.js`)
- View rendering → Accounts and expenses: loads accounts (evidence: `app/views.js`)
- Print documents → Deliveries and receipts: reads delivery data (evidence: `app/print.js`)
- Print documents → Customers and CIS: prints sheets (evidence: `app/print.js`)
- Print documents → Receivables and payments: prints statements (evidence: `app/print.js`)
- Node API → Price management: serves price history (evidence: `backend/index.js`)
- Node API → Sales and orders: handles sales (evidence: `backend/index.js`)
- Node API → Deliveries and receipts: serves deliveries (evidence: `backend/index.js`)
- Purchasing → Inventory and stocktake: updates stock (evidence: `backend/index.js`)
- Reports → Inventory and stocktake: summarizes stock (evidence: `backend/index.js`)
- Receivables and payments → Sales and orders: tracks balances (evidence: `backend/index.js`)
- Node API → Purchasing: handles purchasing (evidence: `backend/index.js`)
- Node API → Inventory and stocktake: handles inventory (evidence: `backend/index.js`)
- Node API → Customers and CIS: handles customer sheets (evidence: `backend/index.js`)
- Node API → Store visits: handles visits (evidence: `backend/index.js`)
- Node API → Receivables and payments: handles payments (evidence: `backend/index.js`)
- Node API → Accounts and expenses: handles finance (evidence: `backend/index.js`)
- Node API → Reports: serves reports (evidence: `backend/index.js`)
