# gwentechsolutions-dev/ajay-enterprises architecture

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

- Interactive diagram: https://gitdiagram.com/gwentechsolutions-dev/ajay-enterprises
- Repository: https://github.com/gwentechsolutions-dev/ajay-enterprises

## Overview

INVENTRA is a business operations platform spanning inventory, rentals, billing/accounting, fleet, labour, and reporting. A representative workflow starts with an authenticated user creating an operational or financial record through an API route; the route checks access, validates input, and invokes domain logic that persists changes and may post ledger or inventory movements. The tree and excerpts establish these backend relationships, but do not show the UI-to-API wiring. Many feature areas are present in the tree but their internal connections are not sampled.

Main entry points: [`src/app/api/v1/return-notes/route.ts`](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/return-notes/route.ts) (Material returns API), [`src/app/api/v1/invoices/route.ts`](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/invoices/route.ts) (Invoice API), [`src/lib/db.ts`](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/db.ts) (Application database), [`src/app/api/v1/customers/route.ts`](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/customers/route.ts) (Customer records API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and platform"]
  node_auth["Session authentication<br/>[auth.ts]"]
  node_permissions["Role permissions<br/>[permissions.ts]"]
  node_database[("Application database<br/>[db.ts]")]
end

subgraph group_operations["Operational workflows"]
  node_customer_api["Customer records API<br/>[route.ts]"]
  node_return_api["Material returns API<br/>[route.ts]"]
  node_inventory["Inventory ledger<br/>[ledger.ts]"]
  node_fleet["Fleet services<br/>[service.ts]"]
  node_materials_import["Bulk materials import"]
end

subgraph group_finance["Finance and accounting"]
  node_invoice_api["Invoice API<br/>[route.ts]"]
  node_gst["GST calculations<br/>[gst-engine.ts]"]
  node_ledger["Accounting ledger<br/>[ledger.ts]"]
  node_accounts["Chart of accounts"]
end

subgraph group_rental["Rental lifecycle"]
  node_rentals["Rental agreements"]
  node_storage["Private file storage<br/>[storage.ts]"]
  node_whatsapp["WhatsApp notifications<br/>[whatsapp.ts]"]
end

subgraph group_insight["Reporting and integrations"]
  node_reports["Dashboard reporting"]
end

node_user(("Business user"))
node_external_storage[("Supabase Storage")]

node_user -.->|"submits records"| node_customer_api
node_user -.->|"submits returns"| node_return_api
node_user -.->|"creates invoices"| node_invoice_api
node_customer_api -->|"checks session"| node_auth
node_customer_api -->|"checks access"| node_permissions
node_customer_api -->|"reads and writes"| node_database
node_return_api -->|"checks session"| node_auth
node_return_api -->|"checks access"| node_permissions
node_return_api -->|"posts movements"| node_inventory
node_return_api -->|"validates vehicle"| node_fleet
node_return_api -->|"allocates batches"| node_rentals
node_return_api -->|"reads and writes"| node_database
node_invoice_api -->|"checks session"| node_auth
node_invoice_api -->|"checks access"| node_permissions
node_invoice_api -->|"calculates tax"| node_gst
node_invoice_api -->|"resolves accounts"| node_accounts
node_invoice_api -->|"posts journal"| node_ledger
node_invoice_api -->|"reads and writes"| node_database
node_inventory -->|"persists movements"| node_database
node_fleet -->|"reads and writes"| node_database
node_materials_import -->|"imports materials"| node_database
node_rentals -->|"saves agreements"| node_storage
node_rentals -->|"sends notifications"| node_whatsapp
node_storage -->|"uploads files"| node_external_storage
node_reports -->|"queries reporting data"| node_database
node_reports -->|"uses accounting reports"| node_ledger

click node_auth "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/auth.ts"
click node_permissions "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/permissions.ts"
click node_database "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/db.ts"
click node_customer_api "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/customers/route.ts"
click node_return_api "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/return-notes/route.ts"
click node_inventory "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/inventory/ledger.ts"
click node_fleet "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/fleet/service.ts"
click node_materials_import "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/materials/bulk-import-service.ts"
click node_invoice_api "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/invoices/route.ts"
click node_gst "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/gst-engine.ts"
click node_ledger "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/ledger.ts"
click node_accounts "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/chart-of-accounts.ts"
click node_rentals "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/rentals/agreement-service.ts"
click node_storage "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/storage.ts"
click node_whatsapp "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/notifications/whatsapp.ts"
click node_reports "https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/reports/dashboard-service.ts"

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_auth,node_permissions,node_database,node_user toneBlue
class node_customer_api,node_return_api,node_inventory,node_fleet,node_materials_import,node_external_storage toneAmber
class node_invoice_api,node_gst,node_ledger,node_accounts toneMint
class node_rentals,node_storage,node_whatsapp toneRose
class node_reports toneIndigo
```

## Components

### Access and platform

- [Session authentication](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Role permissions](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/permissions.ts): `src/lib/permissions.ts`
- [Application database](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Operational workflows

- [Customer records API](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/customers/route.ts): `src/app/api/v1/customers/route.ts`
- [Material returns API](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/return-notes/route.ts): `src/app/api/v1/return-notes/route.ts`
- [Inventory ledger](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/inventory/ledger.ts): `src/lib/inventory/ledger.ts`
- [Fleet services](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/fleet/service.ts): `src/lib/fleet/service.ts`
- [Bulk materials import](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/materials/bulk-import-service.ts): `src/lib/materials/bulk-import-service.ts`

### Finance and accounting

- [Invoice API](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/app/api/v1/invoices/route.ts): `src/app/api/v1/invoices/route.ts`
- [GST calculations](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/gst-engine.ts): `src/lib/accounting/gst-engine.ts`
- [Accounting ledger](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/ledger.ts): `src/lib/accounting/ledger.ts`
- [Chart of accounts](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/accounting/chart-of-accounts.ts): `src/lib/accounting/chart-of-accounts.ts`

### Rental lifecycle

- [Rental agreements](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/rentals/agreement-service.ts): `src/lib/rentals/agreement-service.ts`
- [Private file storage](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [WhatsApp notifications](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/notifications/whatsapp.ts): `src/lib/notifications/whatsapp.ts`

### Reporting and integrations

- [Dashboard reporting](https://github.com/gwentechsolutions-dev/ajay-enterprises/blob/main/src/lib/reports/dashboard-service.ts): `src/lib/reports/dashboard-service.ts`

### Other components

- **Business user**
- **Supabase Storage**

## Connections

- Business user → Customer records API: submits records
- Business user → Material returns API: submits returns
- Business user → Invoice API: creates invoices
- Customer records API → Session authentication: checks session (evidence: `src/app/api/v1/customers/route.ts`)
- Customer records API → Role permissions: checks access (evidence: `src/app/api/v1/customers/route.ts`)
- Customer records API → Application database: reads and writes (evidence: `src/app/api/v1/customers/route.ts`)
- Material returns API → Session authentication: checks session (evidence: `src/app/api/v1/return-notes/route.ts`)
- Material returns API → Role permissions: checks access (evidence: `src/app/api/v1/return-notes/route.ts`)
- Material returns API → Inventory ledger: posts movements (evidence: `src/app/api/v1/return-notes/route.ts`)
- Material returns API → Fleet services: validates vehicle (evidence: `src/app/api/v1/return-notes/route.ts`)
- Material returns API → Rental agreements: allocates batches (evidence: `src/app/api/v1/return-notes/route.ts`)
- Material returns API → Application database: reads and writes (evidence: `src/app/api/v1/return-notes/route.ts`)
- Invoice API → Session authentication: checks session (evidence: `src/app/api/v1/invoices/route.ts`)
- Invoice API → Role permissions: checks access (evidence: `src/app/api/v1/invoices/route.ts`)
- Invoice API → GST calculations: calculates tax (evidence: `src/app/api/v1/invoices/route.ts`)
- Invoice API → Chart of accounts: resolves accounts (evidence: `src/app/api/v1/invoices/route.ts`)
- Invoice API → Accounting ledger: posts journal (evidence: `src/app/api/v1/invoices/route.ts`)
- Invoice API → Application database: reads and writes (evidence: `src/app/api/v1/invoices/route.ts`)
- Inventory ledger → Application database: persists movements (evidence: `src/lib/inventory/ledger.ts`)
- Fleet services → Application database: reads and writes (evidence: `src/lib/fleet/service.ts`)
- Bulk materials import → Application database: imports materials (evidence: `src/lib/materials/bulk-import-service.ts`)
- Rental agreements → Private file storage: saves agreements (evidence: `src/lib/rentals/agreement-service.ts`)
- Rental agreements → WhatsApp notifications: sends notifications (evidence: `src/lib/rentals/agreement-service.ts`)
- Private file storage → Supabase Storage: uploads files (evidence: `src/lib/storage.ts`)
- Dashboard reporting → Application database: queries reporting data (evidence: `src/lib/reports/dashboard-service.ts`)
- Dashboard reporting → Accounting ledger: uses accounting reports (evidence: `src/lib/reports/dashboard-service.ts`)
