# janiya-99/test-a architecture

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

- Interactive diagram: https://gitdiagram.com/janiya-99/test-a
- Repository: https://github.com/janiya-99/test-a

## Overview

Asipiya Asipbook is a Node.js/Express backend for a business-management platform. Its principal workflow is an authenticated client request entering the API, being dispatched to a domain controller, and reading or changing business data in MySQL before returning a result. The repository also exposes accounting, sales, inventory, purchasing, workforce, reporting, and customer-management capabilities. The graph uses explicit routing and service references where available; broader feature branches are documented by the README or indicated by the route/controller tree, so their internal links are intentionally limited.

Main entry points: [`server.js`](https://github.com/janiya-99/test-a/blob/main/server.js) (Express server), [`services/productDBService.js`](https://github.com/janiya-99/test-a/blob/main/services/productDBService.js) (Product data), [`controllers/authController.js`](https://github.com/janiya-99/test-a/blob/main/controllers/authController.js) (Authentication), [`controllers/invoiceController.js`](https://github.com/janiya-99/test-a/blob/main/controllers/invoiceController.js) (Invoice workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_server["Express server<br/>[server.js]"]
  node_authroutes["Identity routes<br/>[authRoutes.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_branch["Branch services<br/>[branchDBService.js]"]
end

subgraph group_commerce["Sales and finance"]
  node_invoices["Invoice workflow"]
  node_invoice_store["Invoice data"]
  node_installments["Installment payments"]
  node_installment_store["Installment data"]
  node_accounting["Accounting"]
end

subgraph group_operations["Inventory operations"]
  node_product["Product catalog"]
  node_product_store["Product data"]
  node_receiving["Goods receiving<br/>[grnController.js]"]
  node_warehouses["Warehouse operations"]
  node_stock["Stock records"]
end

subgraph group_business["Business services"]
  node_customer["Customer management"]
  node_reports["Reports and dashboard<br/>[reportDBService.js]"]
  node_approval["Approvals<br/>[approvalService.js]"]
end

subgraph group_platform["Runtime and integrations"]
  node_db[("Business database<br/>[db.js]")]
  node_db2[("Account-center database<br/>[db2.js]")]
  node_realtime["Socket.IO updates<br/>[server.js]"]
  node_email["Email service"]
  node_excel["File and Excel handling<br/>[multerConfig.js]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_authroutes
node_authroutes -->|"dispatches to"| node_auth
node_auth -->|"uses branch data"| node_branch
node_auth -->|"uses customer data"| node_customer
node_auth -->|"uses product data"| node_product_store
node_auth -->|"queries account data"| node_db2
node_server -->|"mounts API routes"| node_invoices
node_invoices -->|"uses invoice data"| node_invoice_store
node_invoices -->|"uses product data"| node_product_store
node_invoices -->|"uses stock records"| node_stock
node_invoices -->|"emits updates"| node_realtime
node_server -->|"mounts routes"| node_installments
node_installments -->|"calls data service"| node_installment_store
node_installments -->|"updates invoice balance"| node_invoice_store
node_installments -.->|"recalculates credit logs"| node_db
node_server -->|"mounts API routes"| node_product
node_product -->|"uses product data"| node_product_store
node_server -->|"mounts API routes"| node_receiving
node_receiving -->|"uses product data"| node_product_store
node_receiving -->|"uses stock records"| node_stock
node_receiving -->|"calls accounting"| node_accounting
node_server -->|"mounts API routes"| node_warehouses
node_warehouses -->|"uses product data"| node_product_store
node_warehouses -->|"uses stock records"| node_stock
node_warehouses -->|"queries company data"| node_db2
node_product_store -->|"queries business data"| node_db
node_product_store -->|"queries branch data"| node_db2
node_invoice_store -->|"queries business data"| node_db
node_installment_store -->|"queries payment data"| node_db
node_branch -->|"queries branch data"| node_db2
node_server -->|"attaches Socket.IO"| node_realtime
node_server -->|"uses dashboard service"| node_reports
node_server -.->|"exposes accounting"| node_accounting
node_server -.->|"exposes approval flows"| node_approval
node_auth -->|"sends email"| node_email
node_server -.->|"supports uploads"| node_excel

click node_server "https://github.com/janiya-99/test-a/blob/main/server.js"
click node_authroutes "https://github.com/janiya-99/test-a/blob/main/routes/authRoutes.js"
click node_auth "https://github.com/janiya-99/test-a/blob/main/controllers/authController.js"
click node_branch "https://github.com/janiya-99/test-a/blob/main/services/branchDBService.js"
click node_invoices "https://github.com/janiya-99/test-a/blob/main/controllers/invoiceController.js"
click node_invoice_store "https://github.com/janiya-99/test-a/blob/main/services/invoiceDBService.js"
click node_installments "https://github.com/janiya-99/test-a/blob/main/controllers/installmentController.js"
click node_installment_store "https://github.com/janiya-99/test-a/blob/main/services/installmentDBService.js"
click node_accounting "https://github.com/janiya-99/test-a/blob/main/controllers/accountingController.js"
click node_product "https://github.com/janiya-99/test-a/blob/main/controllers/productController.js"
click node_product_store "https://github.com/janiya-99/test-a/blob/main/services/productDBService.js"
click node_receiving "https://github.com/janiya-99/test-a/blob/main/controllers/grnController.js"
click node_warehouses "https://github.com/janiya-99/test-a/blob/main/controllers/warehouseController.js"
click node_stock "https://github.com/janiya-99/test-a/blob/main/services/stockCardDBService.js"
click node_customer "https://github.com/janiya-99/test-a/blob/main/services/customerDBService.js"
click node_reports "https://github.com/janiya-99/test-a/blob/main/services/reportDBService.js"
click node_approval "https://github.com/janiya-99/test-a/blob/main/services/approvalService.js"
click node_db "https://github.com/janiya-99/test-a/blob/main/db/db.js"
click node_db2 "https://github.com/janiya-99/test-a/blob/main/db/db2.js"
click node_realtime "https://github.com/janiya-99/test-a/blob/main/server.js"
click node_email "https://github.com/janiya-99/test-a/blob/main/utils/emailTransporter.js"
click node_excel "https://github.com/janiya-99/test-a/blob/main/utils/multerConfig.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_server,node_authroutes,node_auth,node_branch,node_client toneBlue
class node_invoices,node_invoice_store,node_installments,node_installment_store,node_accounting toneAmber
class node_product,node_product_store,node_receiving,node_warehouses,node_stock toneMint
class node_customer,node_reports,node_approval toneRose
class node_db,node_db2,node_realtime,node_email,node_excel toneIndigo
```

## Components

### API and identity

- [Express server](https://github.com/janiya-99/test-a/blob/main/server.js): `server.js`
- [Identity routes](https://github.com/janiya-99/test-a/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [Authentication](https://github.com/janiya-99/test-a/blob/main/controllers/authController.js): `controllers/authController.js`
- [Branch services](https://github.com/janiya-99/test-a/blob/main/services/branchDBService.js): `services/branchDBService.js`

### Sales and finance

- [Invoice workflow](https://github.com/janiya-99/test-a/blob/main/controllers/invoiceController.js): `controllers/invoiceController.js`
- [Invoice data](https://github.com/janiya-99/test-a/blob/main/services/invoiceDBService.js): `services/invoiceDBService.js`
- [Installment payments](https://github.com/janiya-99/test-a/blob/main/controllers/installmentController.js): `controllers/installmentController.js`
- [Installment data](https://github.com/janiya-99/test-a/blob/main/services/installmentDBService.js): `services/installmentDBService.js`
- [Accounting](https://github.com/janiya-99/test-a/blob/main/controllers/accountingController.js): `controllers/accountingController.js`

### Inventory operations

- [Product catalog](https://github.com/janiya-99/test-a/blob/main/controllers/productController.js): `controllers/productController.js`
- [Product data](https://github.com/janiya-99/test-a/blob/main/services/productDBService.js): `services/productDBService.js`
- [Goods receiving](https://github.com/janiya-99/test-a/blob/main/controllers/grnController.js): `controllers/grnController.js`
- [Warehouse operations](https://github.com/janiya-99/test-a/blob/main/controllers/warehouseController.js): `controllers/warehouseController.js`
- [Stock records](https://github.com/janiya-99/test-a/blob/main/services/stockCardDBService.js): `services/stockCardDBService.js`

### Business services

- [Customer management](https://github.com/janiya-99/test-a/blob/main/services/customerDBService.js): `services/customerDBService.js`
- [Reports and dashboard](https://github.com/janiya-99/test-a/blob/main/services/reportDBService.js): `services/reportDBService.js`
- [Approvals](https://github.com/janiya-99/test-a/blob/main/services/approvalService.js): `services/approvalService.js`

### Runtime and integrations

- [Business database](https://github.com/janiya-99/test-a/blob/main/db/db.js): `db/db.js`
- [Account-center database](https://github.com/janiya-99/test-a/blob/main/db/db2.js): `db/db2.js`
- [Socket.IO updates](https://github.com/janiya-99/test-a/blob/main/server.js): `server.js`
- [Email service](https://github.com/janiya-99/test-a/blob/main/utils/emailTransporter.js): `utils/emailTransporter.js`
- [File and Excel handling](https://github.com/janiya-99/test-a/blob/main/utils/multerConfig.js): `utils/multerConfig.js`

### Other components

- **API client**

## Connections

- API client → Express server: sends requests (evidence: `README.md`)
- Express server → Identity routes: mounts routes (evidence: `server.js`)
- Identity routes → Authentication: dispatches to (evidence: `routes/authRoutes.js`)
- Authentication → Branch services: uses branch data (evidence: `controllers/authController.js`)
- Authentication → Customer management: uses customer data (evidence: `controllers/authController.js`)
- Authentication → Product data: uses product data (evidence: `controllers/authController.js`)
- Authentication → Account-center database: queries account data (evidence: `controllers/authController.js`)
- Express server → Invoice workflow: mounts API routes (evidence: `server.js`)
- Invoice workflow → Invoice data: uses invoice data (evidence: `controllers/invoiceController.js`)
- Invoice workflow → Product data: uses product data (evidence: `controllers/invoiceController.js`)
- Invoice workflow → Stock records: uses stock records (evidence: `controllers/invoiceController.js`)
- Invoice workflow → Socket.IO updates: emits updates (evidence: `controllers/invoiceController.js`)
- Express server → Installment payments: mounts routes (evidence: `server.js`)
- Installment payments → Installment data: calls data service (evidence: `controllers/installmentController.js`)
- Installment payments → Invoice data: updates invoice balance (evidence: `controllers/installmentController.js`)
- Installment payments → Business database: recalculates credit logs (evidence: `controllers/installmentController.js`)
- Express server → Product catalog: mounts API routes (evidence: `server.js`)
- Product catalog → Product data: uses product data (evidence: `routes/productRoutes.js`)
- Express server → Goods receiving: mounts API routes (evidence: `server.js`)
- Goods receiving → Product data: uses product data (evidence: `controllers/grnController.js`)
- Goods receiving → Stock records: uses stock records (evidence: `controllers/grnController.js`)
- Goods receiving → Accounting: calls accounting (evidence: `controllers/grnController.js`)
- Express server → Warehouse operations: mounts API routes (evidence: `server.js`)
- Warehouse operations → Product data: uses product data (evidence: `controllers/warehouseController.js`)
- Warehouse operations → Stock records: uses stock records (evidence: `controllers/warehouseController.js`)
- Warehouse operations → Account-center database: queries company data (evidence: `controllers/warehouseController.js`)
- Product data → Business database: queries business data (evidence: `services/productDBService.js`)
- Product data → Account-center database: queries branch data (evidence: `services/productDBService.js`)
- Invoice data → Business database: queries business data (evidence: `services/invoiceDBService.js`)
- Installment data → Business database: queries payment data (evidence: `services/installmentDBService.js`)
- Branch services → Account-center database: queries branch data (evidence: `services/branchDBService.js`)
- Express server → Socket.IO updates: attaches Socket.IO (evidence: `server.js`)
- Express server → Reports and dashboard: uses dashboard service (evidence: `server.js`)
- Express server → Accounting: exposes accounting
- Express server → Approvals: exposes approval flows
- Authentication → Email service: sends email (evidence: `controllers/authController.js`)
- Express server → File and Excel handling: supports uploads
