# sandipmbhosale18-netizen/agri-erp architecture

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

- Interactive diagram: https://gitdiagram.com/sandipmbhosale18-netizen/agri-erp
- Repository: https://github.com/sandipmbhosale18-netizen/agri-erp

## Overview

agri-erp is a desktop ERP for agricultural shops, built as an Electron application with a React interface and a local Prisma-backed database. The principal workflow is shop setup or sign-in, then role-gated shop operations: manage products and stock, record purchases or sales, track payments, and review accounting and reports. The main process registers IPC handlers and creates the desktop window; the preload exposes renderer-facing APIs. The tree also shows synchronization modules, but their runtime wiring is not established by the sampled excerpts.

Main entry points: [`src/preload/index.ts`](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/preload/index.ts) (Preload API), [`src/renderer/src`](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src) (React application), [`src/main/db/client.ts`](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/db/client.ts) (Prisma database), [`src/main/index.ts`](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/index.ts) (Electron main)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop interface"]
  node_renderer["React application"]
  node_authui["Setup and login"]
  node_shell["Role-gated shell"]
  node_preload["Preload API<br/>[index.ts]"]
  node_main["Electron main<br/>[index.ts]"]
  node_authipc["Auth IPC<br/>[auth.ts]"]
end

subgraph group_operations["Shop operations"]
  node_inventoryui["Inventory screens"]
  node_inventoryipc["Inventory IPC<br/>[inventory.ts]"]
  node_inventory["Inventory service<br/>[service.ts]"]
  node_purchaseui["Purchases and suppliers"]
  node_purchaseipc["Purchase IPC<br/>[purchases.ts]"]
  node_purchases["Purchases service<br/>[service.ts]"]
  node_customerui["Customer screens"]
  node_customers["Customer service<br/>[service.ts]"]
end

subgraph group_finance["Finance and insights"]
  node_billingui["Billing screens"]
  node_billingipc["Billing IPC<br/>[billing.ts]"]
  node_billing["Billing service<br/>[service.ts]"]
  node_payments["Payment service<br/>[service.ts]"]
  node_accounting["Accounting and expenses<br/>[service.ts]"]
  node_reportsui["Reports and analytics"]
  node_reports["GST reports<br/>[service.ts]"]
  node_analytics["Sales analytics<br/>[service.ts]"]
end

subgraph group_platform["Persistence and sync"]
  node_db[("Prisma database<br/>[client.ts]")]
  node_sync["Synchronization"]
end

node_staff(("Shop staff"))

node_staff -->|"uses"| node_renderer
node_renderer -->|"routes"| node_authui
node_renderer -->|"routes"| node_shell
node_renderer -->|"routes"| node_inventoryui
node_renderer -->|"routes"| node_purchaseui
node_renderer -->|"routes"| node_customerui
node_renderer -->|"routes"| node_billingui
node_renderer -->|"routes"| node_reportsui
node_authui -->|"calls API"| node_preload
node_inventoryui -->|"calls API"| node_preload
node_purchaseui -->|"calls API"| node_preload
node_customerui -->|"calls API"| node_preload
node_billingui -->|"calls API"| node_preload
node_reportsui -->|"calls API"| node_preload
node_preload -->|"invokes IPC"| node_authipc
node_preload -->|"invokes IPC"| node_inventoryipc
node_preload -->|"invokes IPC"| node_purchaseipc
node_preload -->|"invokes IPC"| node_billingipc
node_main -->|"registers"| node_authipc
node_main -->|"registers"| node_inventoryipc
node_main -->|"registers"| node_purchaseipc
node_main -->|"registers"| node_billingipc
node_inventory -->|"reads and writes"| node_db
node_purchases -->|"reads and writes"| node_db
node_customers -->|"reads and writes"| node_db
node_billing -->|"reads and writes"| node_db
node_payments -->|"reads and writes"| node_db
node_accounting -->|"uses"| node_db
node_reports -->|"reads"| node_db
node_analytics -->|"reads"| node_db

click node_renderer "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src"
click node_authui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/auth"
click node_shell "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/shared"
click node_preload "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/preload/index.ts"
click node_main "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/index.ts"
click node_authipc "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/auth.ts"
click node_inventoryui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/inventory"
click node_inventoryipc "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/inventory.ts"
click node_inventory "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/inventory/service.ts"
click node_purchaseui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/purchases"
click node_purchaseipc "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/purchases.ts"
click node_purchases "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/purchases/service.ts"
click node_customerui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/customers"
click node_customers "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/customers/service.ts"
click node_billingui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/billing"
click node_billingipc "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/billing.ts"
click node_billing "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/billing/service.ts"
click node_payments "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/payments/service.ts"
click node_accounting "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/accounting/service.ts"
click node_reportsui "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/reports"
click node_reports "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/reports/service.ts"
click node_analytics "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/analytics/service.ts"
click node_db "https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/db/client.ts"
click node_sync "https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/main/sync"

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_renderer,node_authui,node_shell,node_preload,node_main,node_authipc toneBlue
class node_inventoryui,node_inventoryipc,node_inventory,node_purchaseui,node_purchaseipc,node_purchases,node_customerui,node_customers toneAmber
class node_billingui,node_billingipc,node_billing,node_payments,node_accounting,node_reportsui,node_reports,node_analytics toneMint
class node_db,node_sync toneRose
class node_staff toneIndigo
```

## Components

### Desktop interface

- [React application](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src): `src/renderer/src`
- [Setup and login](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/auth): `src/renderer/src/features/auth`
- [Role-gated shell](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/shared): `src/renderer/src/shared`
- [Preload API](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/preload/index.ts): `src/preload/index.ts`
- [Electron main](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/index.ts): `src/main/index.ts`
- [Auth IPC](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/auth.ts): `src/main/ipc/auth.ts`

### Shop operations

- [Inventory screens](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/inventory): `src/renderer/src/features/inventory`
- [Inventory IPC](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/inventory.ts): `src/main/ipc/inventory.ts`
- [Inventory service](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/inventory/service.ts): `src/main/inventory/service.ts`
- [Purchases and suppliers](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/purchases): `src/renderer/src/features/purchases`
- [Purchase IPC](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/purchases.ts): `src/main/ipc/purchases.ts`
- [Purchases service](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/purchases/service.ts): `src/main/purchases/service.ts`
- [Customer screens](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/customers): `src/renderer/src/features/customers`
- [Customer service](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/customers/service.ts): `src/main/customers/service.ts`

### Finance and insights

- [Billing screens](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/billing): `src/renderer/src/features/billing`
- [Billing IPC](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/ipc/billing.ts): `src/main/ipc/billing.ts`
- [Billing service](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/billing/service.ts): `src/main/billing/service.ts`
- [Payment service](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/payments/service.ts): `src/main/payments/service.ts`
- [Accounting and expenses](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/accounting/service.ts): `src/main/accounting/service.ts`
- [Reports and analytics](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/renderer/src/features/reports): `src/renderer/src/features/reports`
- [GST reports](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/reports/service.ts): `src/main/reports/service.ts`
- [Sales analytics](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/analytics/service.ts): `src/main/analytics/service.ts`

### Persistence and sync

- [Prisma database](https://github.com/sandipmbhosale18-netizen/agri-erp/blob/main/src/main/db/client.ts): `src/main/db/client.ts`
- [Synchronization](https://github.com/sandipmbhosale18-netizen/agri-erp/tree/main/src/main/sync): `src/main/sync`

### Other components

- **Shop staff**

## Connections

- Shop staff → React application: uses
- React application → Setup and login: routes
- React application → Role-gated shell: routes
- React application → Inventory screens: routes
- React application → Purchases and suppliers: routes
- React application → Customer screens: routes
- React application → Billing screens: routes
- React application → Reports and analytics: routes
- Setup and login → Preload API: calls API
- Inventory screens → Preload API: calls API
- Purchases and suppliers → Preload API: calls API
- Customer screens → Preload API: calls API
- Billing screens → Preload API: calls API
- Reports and analytics → Preload API: calls API
- Preload API → Auth IPC: invokes IPC
- Preload API → Inventory IPC: invokes IPC
- Preload API → Purchase IPC: invokes IPC
- Preload API → Billing IPC: invokes IPC
- Electron main → Auth IPC: registers
- Electron main → Inventory IPC: registers
- Electron main → Purchase IPC: registers
- Electron main → Billing IPC: registers
- Inventory service → Prisma database: reads and writes
- Purchases service → Prisma database: reads and writes
- Customer service → Prisma database: reads and writes
- Billing service → Prisma database: reads and writes
- Payment service → Prisma database: reads and writes
- Accounting and expenses → Prisma database: uses
- GST reports → Prisma database: reads
- Sales analytics → Prisma database: reads
