# prateek004/dormbook-tested architecture

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

## Overview

DormBook is a PG/hostel operations system for property staff and owners. The principal workflow is staff setting up floors, rooms and beds, checking residents in and out, recording payments and managing balances, then reviewing operational and financial reports. The SPA calls an Express API whose routes apply authentication and property/role checks before dispatching to domain controllers; those controllers use SQLite-backed state. The README also documents receipts, exports, audit history, staff management and optional messaging. Some subsystem links are based on documented capabilities and the file tree; unsampled controller wiring is not asserted.

Main entry points: [`src/routes/index.js`](https://github.com/prateek004/dormbook-tested/blob/main/src/routes/index.js) (API routes), [`src/db/connection.js`](https://github.com/prateek004/dormbook-tested/blob/main/src/db/connection.js) (SQLite database), [`src/controllers/checkinController.js`](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/checkinController.js) (Resident stays), [`src/controllers/paymentsController.js`](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/paymentsController.js) (Payments and balances)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User and API"]
  node_spa["Web application<br/>[app.js]"]
  node_server["HTTP server<br/>[server.js]"]
  node_routes["API routes<br/>[index.js]"]
end

subgraph group_operations["Property Operations"]
  node_auth["Sign-in and accounts<br/>[authController.js]"]
  node_access["Staff access"]
  node_beds["Property and beds<br/>[bedsController.js]"]
  node_checkin["Resident stays"]
  node_bookings["Bookings"]
  node_documents["Resident documents"]
end

subgraph group_finance["Finance and Records"]
  node_addons["Add-on charges"]
  node_payments["Payments and balances"]
  node_ledger["Ledger operations<br/>[ledger.js]"]
  node_receipts["Receipt generation<br/>[receiptService.js]"]
  node_financectrl["Finance and exports"]
  node_daily["Daily reports"]
  node_registers["Report registers"]
  node_reconcile["Reconciliation"]
end

subgraph group_platform["Shared Platform"]
  node_authmw["Access controls<br/>[auth.js]"]
  node_audit["Audit history<br/>[auditLog.js]"]
  node_scheduler["Scheduled tasks<br/>[scheduler.js]"]
  node_whatsapp["WhatsApp messaging<br/>[whatsappService.js]"]
  node_sms["Login-code SMS<br/>[smsService.js]"]
  node_db[("SQLite database<br/>[connection.js]")]
end

node_staff(("Property staff"))
node_whatsapp_api["WhatsApp provider"]
node_msg91["MSG91"]

node_staff -->|"uses"| node_spa
node_spa -->|"sends API requests"| node_server
node_server -->|"mounts API"| node_routes
node_server -->|"serves app"| node_spa
node_routes -->|"guards routes"| node_authmw
node_routes -->|"dispatches"| node_auth
node_routes -->|"dispatches"| node_access
node_routes -->|"dispatches"| node_beds
node_routes -->|"dispatches"| node_checkin
node_routes -->|"dispatches"| node_bookings
node_routes -->|"dispatches"| node_addons
node_routes -->|"dispatches"| node_payments
node_routes -->|"dispatches"| node_financectrl
node_routes -->|"dispatches"| node_daily
node_routes -->|"dispatches"| node_registers
node_routes -->|"dispatches"| node_reconcile
node_routes -->|"dispatches"| node_documents
node_auth -->|"reads and writes"| node_db
node_beds -->|"reads and writes"| node_db
node_checkin -->|"reads and writes"| node_db
node_checkin -->|"records actions"| node_audit
node_checkin -.->|"schedules message"| node_whatsapp
node_payments -->|"reads and writes"| node_db
node_payments -->|"records transactions"| node_ledger
node_payments -->|"creates receipts"| node_receipts
node_ledger -->|"reads and writes"| node_db
node_receipts -->|"stores receipt"| node_db
node_financectrl -->|"reads and writes"| node_db
node_financectrl -->|"uses balances"| node_ledger
node_daily -->|"reads reports data"| node_db
node_daily -->|"uses ledger data"| node_ledger
node_registers -->|"reads report data"| node_db
node_reconcile -->|"reads and writes"| node_db
node_documents -->|"reads and writes"| node_db
node_documents -->|"records access"| node_audit
node_scheduler -->|"reads and writes"| node_db
node_scheduler -.->|"queues notifications"| node_whatsapp
node_whatsapp -.->|"sends messages"| node_whatsapp_api
node_sms -.->|"sends login codes"| node_msg91
node_auth -.->|"sends login code"| node_sms

click node_spa "https://github.com/prateek004/dormbook-tested/blob/main/public/js/app.js"
click node_server "https://github.com/prateek004/dormbook-tested/blob/main/src/server.js"
click node_routes "https://github.com/prateek004/dormbook-tested/blob/main/src/routes/index.js"
click node_authmw "https://github.com/prateek004/dormbook-tested/blob/main/src/middleware/auth.js"
click node_auth "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/authController.js"
click node_access "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/accessController.js"
click node_beds "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/bedsController.js"
click node_checkin "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/checkinController.js"
click node_bookings "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/bookingsController.js"
click node_addons "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/addonsController.js"
click node_payments "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/paymentsController.js"
click node_ledger "https://github.com/prateek004/dormbook-tested/blob/main/src/services/ledger.js"
click node_receipts "https://github.com/prateek004/dormbook-tested/blob/main/src/services/receiptService.js"
click node_financectrl "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/financeController.js"
click node_daily "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/dailyReportsController.js"
click node_registers "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/registersController.js"
click node_reconcile "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/reconciliationController.js"
click node_documents "https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/documentsController.js"
click node_audit "https://github.com/prateek004/dormbook-tested/blob/main/src/middleware/auditLog.js"
click node_scheduler "https://github.com/prateek004/dormbook-tested/blob/main/src/services/scheduler.js"
click node_whatsapp "https://github.com/prateek004/dormbook-tested/blob/main/src/services/whatsappService.js"
click node_sms "https://github.com/prateek004/dormbook-tested/blob/main/src/services/smsService.js"
click node_db "https://github.com/prateek004/dormbook-tested/blob/main/src/db/connection.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_spa,node_server,node_routes toneBlue
class node_auth,node_access,node_beds,node_checkin,node_bookings,node_documents toneAmber
class node_addons,node_payments,node_ledger,node_receipts,node_financectrl,node_daily,node_registers,node_reconcile toneMint
class node_authmw,node_audit,node_scheduler,node_whatsapp,node_sms,node_db toneRose
class node_staff,node_whatsapp_api,node_msg91 toneIndigo
```

## Components

### User and API

- [Web application](https://github.com/prateek004/dormbook-tested/blob/main/public/js/app.js): `public/js/app.js`
- [HTTP server](https://github.com/prateek004/dormbook-tested/blob/main/src/server.js): `src/server.js`
- [API routes](https://github.com/prateek004/dormbook-tested/blob/main/src/routes/index.js): `src/routes/index.js`

### Property Operations

- [Sign-in and accounts](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/authController.js): `src/controllers/authController.js`
- [Staff access](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/accessController.js): `src/controllers/accessController.js`
- [Property and beds](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/bedsController.js): `src/controllers/bedsController.js`
- [Resident stays](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/checkinController.js): `src/controllers/checkinController.js`
- [Bookings](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/bookingsController.js): `src/controllers/bookingsController.js`
- [Resident documents](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/documentsController.js): `src/controllers/documentsController.js`

### Finance and Records

- [Add-on charges](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/addonsController.js): `src/controllers/addonsController.js`
- [Payments and balances](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/paymentsController.js): `src/controllers/paymentsController.js`
- [Ledger operations](https://github.com/prateek004/dormbook-tested/blob/main/src/services/ledger.js): `src/services/ledger.js`
- [Receipt generation](https://github.com/prateek004/dormbook-tested/blob/main/src/services/receiptService.js): `src/services/receiptService.js`
- [Finance and exports](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/financeController.js): `src/controllers/financeController.js`
- [Daily reports](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/dailyReportsController.js): `src/controllers/dailyReportsController.js`
- [Report registers](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/registersController.js): `src/controllers/registersController.js`
- [Reconciliation](https://github.com/prateek004/dormbook-tested/blob/main/src/controllers/reconciliationController.js): `src/controllers/reconciliationController.js`

### Shared Platform

- [Access controls](https://github.com/prateek004/dormbook-tested/blob/main/src/middleware/auth.js): `src/middleware/auth.js`
- [Audit history](https://github.com/prateek004/dormbook-tested/blob/main/src/middleware/auditLog.js): `src/middleware/auditLog.js`
- [Scheduled tasks](https://github.com/prateek004/dormbook-tested/blob/main/src/services/scheduler.js): `src/services/scheduler.js`
- [WhatsApp messaging](https://github.com/prateek004/dormbook-tested/blob/main/src/services/whatsappService.js): `src/services/whatsappService.js`
- [Login-code SMS](https://github.com/prateek004/dormbook-tested/blob/main/src/services/smsService.js): `src/services/smsService.js`
- [SQLite database](https://github.com/prateek004/dormbook-tested/blob/main/src/db/connection.js): `src/db/connection.js`

### Other components

- **Property staff**
- **WhatsApp provider**
- **MSG91**

## Connections

- Property staff → Web application: uses
- Web application → HTTP server: sends API requests
- HTTP server → API routes: mounts API
- HTTP server → Web application: serves app
- API routes → Access controls: guards routes
- API routes → Sign-in and accounts: dispatches
- API routes → Staff access: dispatches
- API routes → Property and beds: dispatches
- API routes → Resident stays: dispatches
- API routes → Bookings: dispatches
- API routes → Add-on charges: dispatches
- API routes → Payments and balances: dispatches
- API routes → Finance and exports: dispatches
- API routes → Daily reports: dispatches
- API routes → Report registers: dispatches
- API routes → Reconciliation: dispatches
- API routes → Resident documents: dispatches
- Sign-in and accounts → SQLite database: reads and writes
- Property and beds → SQLite database: reads and writes
- Resident stays → SQLite database: reads and writes
- Resident stays → Audit history: records actions
- Resident stays → WhatsApp messaging: schedules message
- Payments and balances → SQLite database: reads and writes
- Payments and balances → Ledger operations: records transactions
- Payments and balances → Receipt generation: creates receipts
- Ledger operations → SQLite database: reads and writes
- Receipt generation → SQLite database: stores receipt
- Finance and exports → SQLite database: reads and writes
- Finance and exports → Ledger operations: uses balances
- Daily reports → SQLite database: reads reports data
- Daily reports → Ledger operations: uses ledger data
- Report registers → SQLite database: reads report data
- Reconciliation → SQLite database: reads and writes
- Resident documents → SQLite database: reads and writes
- Resident documents → Audit history: records access
- Scheduled tasks → SQLite database: reads and writes
- Scheduled tasks → WhatsApp messaging: queues notifications
- WhatsApp messaging → WhatsApp provider: sends messages
- Login-code SMS → MSG91: sends login codes
- Sign-in and accounts → Login-code SMS: sends login code
