# rizwankharadi/backend architecture

> Architecture diagram of the GitHub repository rizwankharadi/backend, 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/rizwankharadi/backend
- Repository: https://github.com/rizwankharadi/backend

## Overview

FinSync360 is an Express ERP backend for company-scoped accounting, inventory, and related financial workflows. Users reach business operations through HTTP routes; controllers apply domain logic and persist records, while reporting and AI expose summaries. Tally synchronization is a distinct bidirectional integration, and payments, GST, communications, and licensing are additional capabilities documented in the README. The sampled files establish selected controller-to-service/model calls and database setup; unsampled route wiring and several integrations are represented only where documented, without asserting their internal call chains.

Main entry points: [`src/routes`](https://github.com/rizwankharadi/backend/tree/main/src/routes) (Business routes), [`src/server.js`](https://github.com/rizwankharadi/backend/blob/main/src/server.js) (Express server), [`src/models/index.js`](https://github.com/rizwankharadi/backend/blob/main/src/models/index.js) (Accounting and inventory records), [`src/services/tallyWebSocketService.js`](https://github.com/rizwankharadi/backend/blob/main/src/services/tallyWebSocketService.js) (Tally agent socket)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_server["Express server<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_business_routes["Business routes"]
end

subgraph group_business["ERP operations"]
  node_voucher_api["Voucher operations"]
  node_inventory_api["Inventory operations"]
  node_finance_api["Financial operations"]
  node_masters_api["Business masters"]
end

subgraph group_insights["Insights and assistance"]
  node_reports["Financial reports"]
  node_ai_api["AI questions<br/>[aiController.js]"]
  node_intent["Intent routing<br/>[aiQueryRouter.js]"]
  node_ai_handlers["Business summaries<br/>[aiQueryHandlers.js]"]
end

subgraph group_integrations["Integrations"]
  node_tally_api["Tally operations<br/>[tallyController.js]"]
  node_tally_sync["Tally sync"]
  node_tally_socket["Tally agent socket"]
  node_payments["Payment processing<br/>[paymentService.js]"]
  node_gst_api["GST compliance<br/>[gstController.mjs]"]
  node_communications["Notifications"]
end

subgraph group_persistence["Persistence"]
  node_company_data["Accounting and inventory records<br/>[index.js]"]
  node_sessions["Session management<br/>[sessionService.js]"]
  node_database[("MySQL database<br/>[database.js]")]
end

node_client(("ERP client"))
node_tally(("Tally system"))
node_payment_provider(("Razorpay"))
node_gst_network(("GSTN"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_auth
node_server -->|"mounts routes"| node_business_routes
node_auth -->|"manages sessions"| node_sessions
node_business_routes -->|"dispatches vouchers"| node_voucher_api
node_business_routes -->|"dispatches inventory"| node_inventory_api
node_business_routes -->|"dispatches finance"| node_finance_api
node_business_routes -->|"dispatches masters"| node_masters_api
node_business_routes -->|"dispatches reports"| node_reports
node_business_routes -->|"dispatches questions"| node_ai_api
node_voucher_api -->|"reads and writes"| node_company_data
node_inventory_api -->|"reads and writes"| node_company_data
node_finance_api -->|"reads and writes"| node_company_data
node_masters_api -->|"reads and writes"| node_company_data
node_reports -->|"queries records"| node_company_data
node_ai_api -->|"classifies questions"| node_intent
node_ai_api -->|"runs summaries"| node_ai_handlers
node_ai_handlers -->|"queries records"| node_company_data
node_server -->|"connects on startup"| node_database
node_database -->|"defines models"| node_company_data
node_server -->|"initializes sync"| node_tally_sync
node_server -->|"initializes socket"| node_tally_socket
node_voucher_api -->|"pushes vouchers"| node_tally_socket
node_inventory_api -->|"pushes items"| node_tally_socket
node_tally_api -->|"coordinates sync"| node_tally_sync
node_tally_socket -->|"exchanges data"| node_tally
node_tally_sync -->|"synchronizes"| node_tally
node_payments -.->|"processes payments"| node_payment_provider
node_gst_api -.->|"integrates"| node_gst_network

click node_server "https://github.com/rizwankharadi/backend/blob/main/src/server.js"
click node_auth "https://github.com/rizwankharadi/backend/blob/main/src/routes/auth.js"
click node_business_routes "https://github.com/rizwankharadi/backend/tree/main/src/routes"
click node_voucher_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/voucherController.js"
click node_inventory_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/inventoryController.js"
click node_finance_api "https://github.com/rizwankharadi/backend/tree/main/src/controllers"
click node_masters_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/masterController.js"
click node_reports "https://github.com/rizwankharadi/backend/blob/main/src/controllers/reportController.mjs"
click node_ai_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/aiController.js"
click node_intent "https://github.com/rizwankharadi/backend/blob/main/src/services/aiQueryRouter.js"
click node_ai_handlers "https://github.com/rizwankharadi/backend/blob/main/src/services/aiQueryHandlers.js"
click node_tally_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/tallyController.js"
click node_tally_sync "https://github.com/rizwankharadi/backend/blob/main/src/services/tallySyncService.js"
click node_tally_socket "https://github.com/rizwankharadi/backend/blob/main/src/services/tallyWebSocketService.js"
click node_payments "https://github.com/rizwankharadi/backend/blob/main/src/services/paymentService.js"
click node_gst_api "https://github.com/rizwankharadi/backend/blob/main/src/controllers/gstController.mjs"
click node_communications "https://github.com/rizwankharadi/backend/blob/main/src/services/notificationService.js"
click node_company_data "https://github.com/rizwankharadi/backend/blob/main/src/models/index.js"
click node_sessions "https://github.com/rizwankharadi/backend/blob/main/src/services/sessionService.js"
click node_database "https://github.com/rizwankharadi/backend/blob/main/src/config/database.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_auth,node_business_routes,node_client toneBlue
class node_voucher_api,node_inventory_api,node_finance_api,node_masters_api toneAmber
class node_reports,node_ai_api,node_intent,node_ai_handlers toneMint
class node_tally_api,node_tally_sync,node_tally_socket,node_payments,node_gst_api,node_communications toneRose
class node_company_data,node_sessions,node_database,node_tally,node_payment_provider,node_gst_network toneIndigo
```

## Components

### API and access

- [Express server](https://github.com/rizwankharadi/backend/blob/main/src/server.js): `src/server.js`
- [Authentication](https://github.com/rizwankharadi/backend/blob/main/src/routes/auth.js): `src/routes/auth.js`
- [Business routes](https://github.com/rizwankharadi/backend/tree/main/src/routes): `src/routes`

### ERP operations

- [Voucher operations](https://github.com/rizwankharadi/backend/blob/main/src/controllers/voucherController.js): `src/controllers/voucherController.js`
- [Inventory operations](https://github.com/rizwankharadi/backend/blob/main/src/controllers/inventoryController.js): `src/controllers/inventoryController.js`
- [Financial operations](https://github.com/rizwankharadi/backend/tree/main/src/controllers): `src/controllers`
- [Business masters](https://github.com/rizwankharadi/backend/blob/main/src/controllers/masterController.js): `src/controllers/masterController.js`

### Insights and assistance

- [Financial reports](https://github.com/rizwankharadi/backend/blob/main/src/controllers/reportController.mjs): `src/controllers/reportController.mjs`
- [AI questions](https://github.com/rizwankharadi/backend/blob/main/src/controllers/aiController.js): `src/controllers/aiController.js`
- [Intent routing](https://github.com/rizwankharadi/backend/blob/main/src/services/aiQueryRouter.js): `src/services/aiQueryRouter.js`
- [Business summaries](https://github.com/rizwankharadi/backend/blob/main/src/services/aiQueryHandlers.js): `src/services/aiQueryHandlers.js`

### Integrations

- [Tally operations](https://github.com/rizwankharadi/backend/blob/main/src/controllers/tallyController.js): `src/controllers/tallyController.js`
- [Tally sync](https://github.com/rizwankharadi/backend/blob/main/src/services/tallySyncService.js): `src/services/tallySyncService.js`
- [Tally agent socket](https://github.com/rizwankharadi/backend/blob/main/src/services/tallyWebSocketService.js): `src/services/tallyWebSocketService.js`
- [Payment processing](https://github.com/rizwankharadi/backend/blob/main/src/services/paymentService.js): `src/services/paymentService.js`
- [GST compliance](https://github.com/rizwankharadi/backend/blob/main/src/controllers/gstController.mjs): `src/controllers/gstController.mjs`
- [Notifications](https://github.com/rizwankharadi/backend/blob/main/src/services/notificationService.js): `src/services/notificationService.js`

### Persistence

- [Accounting and inventory records](https://github.com/rizwankharadi/backend/blob/main/src/models/index.js): `src/models/index.js`
- [Session management](https://github.com/rizwankharadi/backend/blob/main/src/services/sessionService.js): `src/services/sessionService.js`
- [MySQL database](https://github.com/rizwankharadi/backend/blob/main/src/config/database.js): `src/config/database.js`

### Other components

- **ERP client**
- **Tally system**
- **Razorpay**
- **GSTN**

## Connections

- ERP client → Express server: sends requests
- Express server → Authentication: mounts routes
- Express server → Business routes: mounts routes
- Authentication → Session management: manages sessions
- Business routes → Voucher operations: dispatches vouchers
- Business routes → Inventory operations: dispatches inventory
- Business routes → Financial operations: dispatches finance
- Business routes → Business masters: dispatches masters
- Business routes → Financial reports: dispatches reports
- Business routes → AI questions: dispatches questions
- Voucher operations → Accounting and inventory records: reads and writes
- Inventory operations → Accounting and inventory records: reads and writes
- Financial operations → Accounting and inventory records: reads and writes
- Business masters → Accounting and inventory records: reads and writes
- Financial reports → Accounting and inventory records: queries records
- AI questions → Intent routing: classifies questions
- AI questions → Business summaries: runs summaries
- Business summaries → Accounting and inventory records: queries records
- Express server → MySQL database: connects on startup
- MySQL database → Accounting and inventory records: defines models
- Express server → Tally sync: initializes sync
- Express server → Tally agent socket: initializes socket
- Voucher operations → Tally agent socket: pushes vouchers
- Inventory operations → Tally agent socket: pushes items
- Tally operations → Tally sync: coordinates sync
- Tally agent socket → Tally system: exchanges data
- Tally sync → Tally system: synchronizes
- Payment processing → Razorpay: processes payments
- GST compliance → GSTN: integrates
