# uti-sai/test-ims architecture

> Architecture diagram of the GitHub repository uti-sai/test-ims, 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/uti-sai/test-ims
- Repository: https://github.com/uti-sai/test-ims

## Overview

Billing Monitor is an Express/MongoDB application for user and billing administration, invoice/RPA processing, and email notifications. Its main operational path is API invoice handling: the API controller checks RPA logs, can look up invoice data from SQL Server and persist logs in MongoDB, then creates billing records and queues invoice email; callers can query email-task status. Separate web routes support authentication, billing review and rejection, and rejected-invoice email settings. Source evidence is partial, so unsampled route behavior and internal controller details are not expanded.

Main entry points: [`controllers/api.js`](https://github.com/uti-sai/test-ims/blob/main/controllers/api.js) (Invoice API handling), [`app.js`](https://github.com/uti-sai/test-ims/blob/main/app.js) (Express app), [`helpers/sendEmail.js`](https://github.com/uti-sai/test-ims/blob/main/helpers/sendEmail.js) (Email dispatch), [`controllers/billing.js`](https://github.com/uti-sai/test-ims/blob/main/controllers/billing.js) (Billing management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web access"]
  node_app["Express app<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_controller["Authentication<br/>[auth.js]"]
  node_auth_middleware["Access checks<br/>[auth.js]"]
  node_passport["Passport config<br/>[passport-config.js]"]
  node_users[("User model<br/>[User.js]")]
end

subgraph group_invoice["Invoice processing"]
  node_api_routes["Invoice API routes<br/>[api.js]"]
  node_api_controller["Invoice API handling<br/>[api.js]"]
  node_rpa_lookup["RPA invoice lookup<br/>[lookUpRPA.js]"]
  node_email_extract["Email extraction<br/>[extractEmails.js]"]
end

subgraph group_billing["Billing operations"]
  node_billing_routes["Billing routes<br/>[billing.js]"]
  node_billing_controller["Billing management<br/>[billing.js]"]
  node_billing_model[("Billing model<br/>[Billing.js]")]
  node_reject_routes["Rejected-email routes"]
  node_reject_controller["Rejected-email settings"]
  node_reject_model[("Rejected-email model")]
  node_settings_parser["Email settings parser"]
  node_query_string["Query string helper"]
end

subgraph group_messaging["Email delivery"]
  node_invoice_sender["Invoice email setup<br/>[sendInvoiceRPA.js]"]
  node_queue_helper["Queue management<br/>[emailQueue.js]"]
  node_email_sender["Email dispatch<br/>[sendEmail.js]"]
  node_email_queue["Mongo email queue<br/>[emailQueue.js]"]
  node_worker["Email worker<br/>[index.js]"]
end

node_user(("Web user"))
node_api_client(("API client"))
node_sql_server[("RPA SQL Server")]
node_mongo[("MongoDB")]
node_mail_service["SMTP service"]

node_app -->|"mounts"| node_auth_routes
node_app -->|"mounts"| node_api_routes
node_app -->|"mounts"| node_billing_routes
node_app -->|"mounts"| node_reject_routes
node_app -->|"starts manager"| node_queue_helper
node_user -.->|"uses"| node_auth_routes
node_api_client -->|"calls"| node_api_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"checks access"| node_auth_middleware
node_auth_controller -->|"reads and updates"| node_users
node_auth_controller -->|"authenticates"| node_passport
node_passport -->|"loads user"| node_users
node_api_routes -->|"checks keys and roles"| node_auth_middleware
node_api_routes -->|"dispatches"| node_api_controller
node_api_controller -->|"looks up missing logs"| node_rpa_lookup
node_rpa_lookup -->|"queries invoices"| node_sql_server
node_rpa_lookup -->|"stores RPA logs"| node_mongo
node_api_controller -->|"reads and updates logs"| node_mongo
node_api_controller -->|"extracts addresses"| node_email_extract
node_api_controller -->|"creates billing records"| node_billing_model
node_api_controller -->|"prepares invoice email"| node_invoice_sender
node_invoice_sender -->|"sends through"| node_email_sender
node_billing_routes -->|"checks access"| node_auth_middleware
node_billing_routes -->|"dispatches"| node_billing_controller
node_billing_controller -->|"queries billing data"| node_mongo
node_billing_controller -->|"builds filters"| node_query_string
node_billing_controller -->|"sends rejection notice"| node_email_sender
node_reject_routes -->|"checks access"| node_auth_middleware
node_reject_routes -->|"dispatches"| node_reject_controller
node_reject_controller -->|"reads and updates"| node_reject_model
node_reject_controller -->|"parses settings"| node_settings_parser
node_email_sender -->|"enqueues tasks"| node_queue_helper
node_email_sender -->|"delivers mail"| node_mail_service
node_queue_helper -->|"uses queue"| node_email_queue
node_worker -->|"consumes tasks"| node_email_queue
node_worker -->|"dispatches tasks"| node_email_sender

click node_app "https://github.com/uti-sai/test-ims/blob/main/app.js"
click node_auth_routes "https://github.com/uti-sai/test-ims/blob/main/routes/auth.js"
click node_auth_controller "https://github.com/uti-sai/test-ims/blob/main/controllers/auth.js"
click node_auth_middleware "https://github.com/uti-sai/test-ims/blob/main/middleware/auth.js"
click node_passport "https://github.com/uti-sai/test-ims/blob/main/passport-config.js"
click node_users "https://github.com/uti-sai/test-ims/blob/main/models/User.js"
click node_api_routes "https://github.com/uti-sai/test-ims/blob/main/routes/api.js"
click node_api_controller "https://github.com/uti-sai/test-ims/blob/main/controllers/api.js"
click node_rpa_lookup "https://github.com/uti-sai/test-ims/blob/main/helpers/logRPA/lookUpRPA.js"
click node_email_extract "https://github.com/uti-sai/test-ims/blob/main/helpers/extractEmails.js"
click node_invoice_sender "https://github.com/uti-sai/test-ims/blob/main/helpers/sendInvoiceRPA.js"
click node_billing_routes "https://github.com/uti-sai/test-ims/blob/main/routes/billing.js"
click node_billing_controller "https://github.com/uti-sai/test-ims/blob/main/controllers/billing.js"
click node_billing_model "https://github.com/uti-sai/test-ims/blob/main/models/Billing.js"
click node_reject_routes "https://github.com/uti-sai/test-ims/blob/main/routes/rejectedInvoiceEmail.js"
click node_reject_controller "https://github.com/uti-sai/test-ims/blob/main/controllers/rejectedInvoiceEmail.js"
click node_reject_model "https://github.com/uti-sai/test-ims/blob/main/models/RejectedInvoiceEmail.js"
click node_settings_parser "https://github.com/uti-sai/test-ims/blob/main/helpers/parseExcelEmailSettings.js"
click node_queue_helper "https://github.com/uti-sai/test-ims/blob/main/helpers/emailQueue.js"
click node_email_sender "https://github.com/uti-sai/test-ims/blob/main/helpers/sendEmail.js"
click node_email_queue "https://github.com/uti-sai/test-ims/blob/main/queue/emailQueue.js"
click node_worker "https://github.com/uti-sai/test-ims/blob/main/worker/index.js"
click node_query_string "https://github.com/uti-sai/test-ims/blob/main/helpers/createQueryString.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_app,node_auth_routes,node_auth_controller,node_auth_middleware,node_passport,node_users,node_user,node_api_client toneBlue
class node_api_routes,node_api_controller,node_rpa_lookup,node_email_extract,node_sql_server,node_mongo toneAmber
class node_billing_routes,node_billing_controller,node_billing_model,node_reject_routes,node_reject_controller,node_reject_model,node_settings_parser,node_query_string toneMint
class node_invoice_sender,node_queue_helper,node_email_sender,node_email_queue,node_worker toneRose
class node_mail_service toneIndigo
```

## Components

### Web access

- [Express app](https://github.com/uti-sai/test-ims/blob/main/app.js): `app.js`
- [Auth routes](https://github.com/uti-sai/test-ims/blob/main/routes/auth.js): `routes/auth.js`
- [Authentication](https://github.com/uti-sai/test-ims/blob/main/controllers/auth.js): `controllers/auth.js`
- [Access checks](https://github.com/uti-sai/test-ims/blob/main/middleware/auth.js): `middleware/auth.js`
- [Passport config](https://github.com/uti-sai/test-ims/blob/main/passport-config.js): `passport-config.js`
- [User model](https://github.com/uti-sai/test-ims/blob/main/models/User.js): `models/User.js`

### Invoice processing

- [Invoice API routes](https://github.com/uti-sai/test-ims/blob/main/routes/api.js): `routes/api.js`
- [Invoice API handling](https://github.com/uti-sai/test-ims/blob/main/controllers/api.js): `controllers/api.js`
- [RPA invoice lookup](https://github.com/uti-sai/test-ims/blob/main/helpers/logRPA/lookUpRPA.js): `helpers/logRPA/lookUpRPA.js`
- [Email extraction](https://github.com/uti-sai/test-ims/blob/main/helpers/extractEmails.js): `helpers/extractEmails.js`

### Billing operations

- [Billing routes](https://github.com/uti-sai/test-ims/blob/main/routes/billing.js): `routes/billing.js`
- [Billing management](https://github.com/uti-sai/test-ims/blob/main/controllers/billing.js): `controllers/billing.js`
- [Billing model](https://github.com/uti-sai/test-ims/blob/main/models/Billing.js): `models/Billing.js`
- [Rejected-email routes](https://github.com/uti-sai/test-ims/blob/main/routes/rejectedInvoiceEmail.js): `routes/rejectedInvoiceEmail.js`
- [Rejected-email settings](https://github.com/uti-sai/test-ims/blob/main/controllers/rejectedInvoiceEmail.js): `controllers/rejectedInvoiceEmail.js`
- [Rejected-email model](https://github.com/uti-sai/test-ims/blob/main/models/RejectedInvoiceEmail.js): `models/RejectedInvoiceEmail.js`
- [Email settings parser](https://github.com/uti-sai/test-ims/blob/main/helpers/parseExcelEmailSettings.js): `helpers/parseExcelEmailSettings.js`
- [Query string helper](https://github.com/uti-sai/test-ims/blob/main/helpers/createQueryString.js): `helpers/createQueryString.js`

### Email delivery

- [Invoice email setup](https://github.com/uti-sai/test-ims/blob/main/helpers/sendInvoiceRPA.js): `helpers/sendInvoiceRPA.js`
- [Queue management](https://github.com/uti-sai/test-ims/blob/main/helpers/emailQueue.js): `helpers/emailQueue.js`
- [Email dispatch](https://github.com/uti-sai/test-ims/blob/main/helpers/sendEmail.js): `helpers/sendEmail.js`
- [Mongo email queue](https://github.com/uti-sai/test-ims/blob/main/queue/emailQueue.js): `queue/emailQueue.js`
- [Email worker](https://github.com/uti-sai/test-ims/blob/main/worker/index.js): `worker/index.js`

### Other components

- **Web user**
- **API client**
- **RPA SQL Server**
- **MongoDB**
- **SMTP service**

## Connections

- Express app → Auth routes: mounts (evidence: `app.js`)
- Express app → Invoice API routes: mounts (evidence: `app.js`)
- Express app → Billing routes: mounts (evidence: `app.js`)
- Express app → Rejected-email routes: mounts (evidence: `app.js`)
- Express app → Queue management: starts manager (evidence: `app.js`)
- Web user → Auth routes: uses
- API client → Invoice API routes: calls (evidence: `routes/api.js`)
- Auth routes → Authentication: dispatches (evidence: `routes/auth.js`)
- Auth routes → Access checks: checks access (evidence: `routes/auth.js`)
- Authentication → User model: reads and updates (evidence: `controllers/auth.js`)
- Authentication → Passport config: authenticates (evidence: `controllers/auth.js`)
- Passport config → User model: loads user (evidence: `passport-config.js`)
- Invoice API routes → Access checks: checks keys and roles (evidence: `routes/api.js`)
- Invoice API routes → Invoice API handling: dispatches (evidence: `routes/api.js`)
- Invoice API handling → RPA invoice lookup: looks up missing logs (evidence: `controllers/api.js`)
- RPA invoice lookup → RPA SQL Server: queries invoices (evidence: `helpers/logRPA/lookUpRPA.js`)
- RPA invoice lookup → MongoDB: stores RPA logs (evidence: `helpers/logRPA/lookUpRPA.js`)
- Invoice API handling → MongoDB: reads and updates logs (evidence: `controllers/api.js`)
- Invoice API handling → Email extraction: extracts addresses (evidence: `controllers/api.js`)
- Invoice API handling → Billing model: creates billing records (evidence: `controllers/api.js`)
- Invoice API handling → Invoice email setup: prepares invoice email (evidence: `controllers/api.js`)
- Invoice email setup → Email dispatch: sends through (evidence: `helpers/sendInvoiceRPA.js`)
- Billing routes → Access checks: checks access (evidence: `routes/billing.js`)
- Billing routes → Billing management: dispatches (evidence: `routes/billing.js`)
- Billing management → MongoDB: queries billing data (evidence: `controllers/billing.js`)
- Billing management → Query string helper: builds filters (evidence: `controllers/billing.js`)
- Billing management → Email dispatch: sends rejection notice (evidence: `controllers/billing.js`)
- Rejected-email routes → Access checks: checks access (evidence: `routes/rejectedInvoiceEmail.js`)
- Rejected-email routes → Rejected-email settings: dispatches (evidence: `routes/rejectedInvoiceEmail.js`)
- Rejected-email settings → Rejected-email model: reads and updates (evidence: `controllers/rejectedInvoiceEmail.js`)
- Rejected-email settings → Email settings parser: parses settings (evidence: `controllers/rejectedInvoiceEmail.js`)
- Email dispatch → Queue management: enqueues tasks (evidence: `helpers/sendEmail.js`)
- Email dispatch → SMTP service: delivers mail (evidence: `helpers/sendEmail.js`)
- Queue management → Mongo email queue: uses queue (evidence: `queue/emailQueue.js`)
- Email worker → Mongo email queue: consumes tasks (evidence: `worker/index.js`)
- Email worker → Email dispatch: dispatches tasks (evidence: `worker/index.js`)
