# thakkalisuresh/dddp-portal architecture

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

## Overview

DD Diamond Park is a resident and committee gas-billing portal. Residents sign in to view bills, pay by UPI, submit payment proofs, and use notices and polls; committee members manage readings, billing, residents, and reconciliation. The backend also runs scheduled late-fee and backup work. The excerpts show the request router, session handling, rate changes, statement parsing, and storage integrations; other feature connections are based on the README and module names, so uncertain call-level wiring is omitted.

Main entry points: [`functions/index.js`](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/index.js) (Request router), [`public/js/api.js`](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/api.js) (API client), [`functions/lib/backup.js`](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/backup.js) (Backup and export), [`functions/lib/cron.js`](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/cron.js) (Scheduled tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Resident experience"]
  node_web["Portal interface<br/>[home.js]"]
  node_clientapi["API client<br/>[api.js]"]
  node_residentui["Resident features<br/>[dashboard.js]"]
  node_noticesui["Notices and polls<br/>[notices.js]"]
end

subgraph group_operations["Committee operations"]
  node_adminui["Admin console<br/>[admin-console.js]"]
  node_billingui["Billing screens<br/>[admin-billing.js]"]
end

subgraph group_backend["Backend services"]
  node_router["Request router<br/>[index.js]"]
  node_sessions["Sessions and identity<br/>[session.js]"]
  node_billing["Billing and readings<br/>[billing.js]"]
  node_payments["UPI and proofs<br/>[proof.js]"]
  node_ocr["Proof recognition<br/>[vision.js]"]
  node_notices["Notices and polls<br/>[notices.js]"]
  node_polls["Poll voting<br/>[polls.js]"]
  node_roster["Roster and tenancy<br/>[roster.js]"]
  node_reconciliation["Statement reconciliation<br/>[statement.js]"]
  node_schedule["Scheduled tasks<br/>[cron.js]"]
  node_backup["Backup and export<br/>[backup.js]"]
end

subgraph group_platform["Data and integrations"]
  node_database[("D1 database")]
  node_files[("R2 file storage")]
  node_mail["Email service"]
  node_drive["Google Drive"]
  node_ocrservice["OCR providers"]
  node_telegram["Telegram alerts"]
end

node_residents(("Residents"))
node_committee(("Committee"))

node_residents -->|"use portal"| node_web
node_committee -->|"use portal"| node_web
node_web -->|"request data"| node_clientapi
node_clientapi -->|"send API request"| node_router
node_router -->|"resolve identity"| node_sessions
node_sessions -->|"read and write sessions"| node_database
node_router -->|"read and write records"| node_database
node_residentui -->|"request resident data"| node_clientapi
node_noticesui -->|"request notices and votes"| node_clientapi
node_adminui -->|"request admin actions"| node_clientapi
node_billingui -->|"request billing actions"| node_clientapi
node_router -->|"dispatch billing"| node_billing
node_router -->|"dispatch payment actions"| node_payments
node_router -->|"dispatch notice actions"| node_notices
node_router -->|"dispatch poll actions"| node_polls
node_router -->|"dispatch roster actions"| node_roster
node_router -->|"parse statement"| node_reconciliation
node_router -->|"parse proof image"| node_ocr
node_payments -->|"store proof files"| node_files
node_ocr -.->|"request image parsing"| node_ocrservice
node_router -.->|"send account email"| node_mail
node_schedule -->|"read and update scheduled records"| node_database
node_schedule -->|"run nightly backup"| node_backup
node_backup -->|"export records"| node_database
node_backup -->|"read stored files"| node_files
node_backup -.->|"copy backup files"| node_drive
node_schedule -.->|"send alerts"| node_telegram

click node_web "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/home.js"
click node_clientapi "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/api.js"
click node_residentui "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/dashboard.js"
click node_noticesui "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/notices.js"
click node_adminui "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/admin-console.js"
click node_billingui "https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/admin-billing.js"
click node_router "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/index.js"
click node_sessions "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/session.js"
click node_billing "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/billing.js"
click node_payments "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/proof.js"
click node_ocr "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/vision.js"
click node_notices "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/notices.js"
click node_polls "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/polls.js"
click node_roster "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/roster.js"
click node_reconciliation "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/statement.js"
click node_schedule "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/cron.js"
click node_backup "https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/backup.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_web,node_clientapi,node_residentui,node_noticesui toneBlue
class node_adminui,node_billingui toneAmber
class node_router,node_sessions,node_billing,node_payments,node_ocr,node_notices,node_polls,node_roster,node_reconciliation,node_schedule,node_backup toneMint
class node_database,node_files,node_mail,node_drive,node_ocrservice,node_telegram toneRose
class node_residents,node_committee toneIndigo
```

## Components

### Resident experience

- [Portal interface](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/home.js): `public/js/home.js`
- [API client](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/api.js): `public/js/api.js`
- [Resident features](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/dashboard.js): `public/js/dashboard.js`
- [Notices and polls](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/notices.js): `public/js/notices.js`

### Committee operations

- [Admin console](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/admin-console.js): `public/js/admin-console.js`
- [Billing screens](https://github.com/thakkalisuresh/dddp-portal/blob/main/public/js/admin-billing.js): `public/js/admin-billing.js`

### Backend services

- [Request router](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/index.js): `functions/index.js`
- [Sessions and identity](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/session.js): `functions/lib/session.js`
- [Billing and readings](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/billing.js): `functions/lib/billing.js`
- [UPI and proofs](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/proof.js): `functions/lib/proof.js`
- [Proof recognition](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/vision.js): `functions/lib/vision.js`
- [Notices and polls](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/notices.js): `functions/lib/notices.js`
- [Poll voting](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/polls.js): `functions/lib/polls.js`
- [Roster and tenancy](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/roster.js): `functions/lib/roster.js`
- [Statement reconciliation](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/statement.js): `functions/lib/statement.js`
- [Scheduled tasks](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/cron.js): `functions/lib/cron.js`
- [Backup and export](https://github.com/thakkalisuresh/dddp-portal/blob/main/functions/lib/backup.js): `functions/lib/backup.js`

### Data and integrations

- **D1 database**
- **R2 file storage**
- **Email service**
- **Google Drive**
- **OCR providers**
- **Telegram alerts**

### Other components

- **Residents**
- **Committee**

## Connections

- Residents → Portal interface: use portal
- Committee → Portal interface: use portal
- Portal interface → API client: request data
- API client → Request router: send API request
- Request router → Sessions and identity: resolve identity
- Sessions and identity → D1 database: read and write sessions
- Request router → D1 database: read and write records
- Resident features → API client: request resident data
- Notices and polls → API client: request notices and votes
- Admin console → API client: request admin actions
- Billing screens → API client: request billing actions
- Request router → Billing and readings: dispatch billing
- Request router → UPI and proofs: dispatch payment actions
- Request router → Notices and polls: dispatch notice actions
- Request router → Poll voting: dispatch poll actions
- Request router → Roster and tenancy: dispatch roster actions
- Request router → Statement reconciliation: parse statement
- Request router → Proof recognition: parse proof image
- UPI and proofs → R2 file storage: store proof files
- Proof recognition → OCR providers: request image parsing
- Request router → Email service: send account email
- Scheduled tasks → D1 database: read and update scheduled records
- Scheduled tasks → Backup and export: run nightly backup
- Backup and export → D1 database: export records
- Backup and export → R2 file storage: read stored files
- Backup and export → Google Drive: copy backup files
- Scheduled tasks → Telegram alerts: send alerts
