# vaishak08-nayak/rainsmart architecture

> Architecture diagram of the GitHub repository vaishak08-nayak/rainsmart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vaishak08-nayak/rainsmart
- Repository: https://github.com/vaishak08-nayak/rainsmart

## Overview

RainSmart’s main workflow is location selection, live and historical rainfall retrieval, catchment and tank calculations, then dashboard guidance and AI advice. The browser application also supports authentication and administration through the Node backend and persistent user/settings/audit storage. The README documents the meteorological, hydrological, and advisor capabilities; the sampled excerpts show selected implementation paths, so unsampled feature links are omitted where their callers are not evidenced.

Main entry points: [`script.js`](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js) (Dashboard logic), [`server.js`](https://github.com/vaishak08-nayak/rainsmart/blob/main/server.js) (HTTP API and AI proxy), [`index.html`](https://github.com/vaishak08-nayak/rainsmart/blob/main/index.html) (Main dashboard), [`auth.html`](https://github.com/vaishak08-nayak/rainsmart/blob/main/auth.html) (Sign-in and registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["RainSmart browser"]
  node_dashboard["Main dashboard<br/>[index.html]"]
  node_client["Dashboard logic<br/>[script.js]"]
  node_api_config["API endpoint config<br/>[api-config.js]"]
  node_auth_pages["Sign-in and registration<br/>[auth.html]"]
  node_user_pages["User dashboard"]
  node_admin_pages["Admin dashboard"]
  node_welcome["Welcome page<br/>[welcome.html]"]
end

subgraph group_hydrology["Hydrology services"]
  node_geocoding["Location geocoding<br/>[script.js]"]
  node_weather["Live weather forecast<br/>[script.js]"]
  node_archive["Historical rainfall<br/>[script.js]"]
  node_catchment["Catchment and tank model<br/>[script.js]"]
  node_advisor["Rule-based water advisor<br/>[script.js]"]
end

subgraph group_backend["Backend services"]
  node_server["HTTP API and AI proxy<br/>[server.js]"]
end

subgraph group_persistence["Persistent data"]
  node_database[("User and settings store<br/>[db.js]")]
end

node_user(("RainSmart user"))
node_openmeteo_geo["Open-Meteo geocoding"]
node_openmeteo_weather["Open-Meteo forecast"]
node_openmeteo_archive["Open-Meteo archive"]
node_gemini["Google Gemini"]
node_openai["OpenAI fallback"]

node_user -->|"opens"| node_dashboard
node_dashboard -->|"runs"| node_client
node_client -->|"searches locations"| node_geocoding
node_geocoding -->|"queries"| node_openmeteo_geo
node_client -->|"fetches forecast"| node_weather
node_weather -->|"queries"| node_openmeteo_weather
node_client -->|"fetches history"| node_archive
node_archive -->|"queries"| node_openmeteo_archive
node_client -->|"recalculates"| node_catchment
node_client -->|"fallback advice"| node_advisor
node_client -->|"resolves endpoints"| node_api_config
node_client -->|"requests chat"| node_server
node_server -->|"queries models"| node_gemini
node_server -->|"fallback query"| node_openai
node_auth_pages -.->|"uses auth API"| node_server
node_user_pages -.->|"uses user API"| node_server
node_admin_pages -.->|"uses admin API"| node_server
node_welcome -.->|"continues to"| node_dashboard
node_server -->|"reads and writes"| node_database

click node_dashboard "https://github.com/vaishak08-nayak/rainsmart/blob/main/index.html"
click node_client "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_api_config "https://github.com/vaishak08-nayak/rainsmart/blob/main/api-config.js"
click node_auth_pages "https://github.com/vaishak08-nayak/rainsmart/blob/main/auth.html"
click node_user_pages "https://github.com/vaishak08-nayak/rainsmart/blob/main/user-dashboard.html"
click node_admin_pages "https://github.com/vaishak08-nayak/rainsmart/blob/main/admin-dashboard.html"
click node_welcome "https://github.com/vaishak08-nayak/rainsmart/blob/main/welcome.html"
click node_geocoding "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_weather "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_archive "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_catchment "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_advisor "https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js"
click node_server "https://github.com/vaishak08-nayak/rainsmart/blob/main/server.js"
click node_database "https://github.com/vaishak08-nayak/rainsmart/blob/main/db.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_dashboard,node_client,node_api_config,node_auth_pages,node_user_pages,node_admin_pages,node_welcome,node_user toneBlue
class node_geocoding,node_weather,node_archive,node_catchment,node_advisor toneAmber
class node_server toneMint
class node_database toneRose
class node_openmeteo_geo,node_openmeteo_weather,node_openmeteo_archive,node_gemini,node_openai toneIndigo
```

## Components

### RainSmart browser

- [Main dashboard](https://github.com/vaishak08-nayak/rainsmart/blob/main/index.html): `index.html`
- [Dashboard logic](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`
- [API endpoint config](https://github.com/vaishak08-nayak/rainsmart/blob/main/api-config.js): `api-config.js`
- [Sign-in and registration](https://github.com/vaishak08-nayak/rainsmart/blob/main/auth.html): `auth.html`
- [User dashboard](https://github.com/vaishak08-nayak/rainsmart/blob/main/user-dashboard.html): `user-dashboard.html`
- [Admin dashboard](https://github.com/vaishak08-nayak/rainsmart/blob/main/admin-dashboard.html): `admin-dashboard.html`
- [Welcome page](https://github.com/vaishak08-nayak/rainsmart/blob/main/welcome.html): `welcome.html`

### Hydrology services

- [Location geocoding](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`
- [Live weather forecast](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`
- [Historical rainfall](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`
- [Catchment and tank model](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`
- [Rule-based water advisor](https://github.com/vaishak08-nayak/rainsmart/blob/main/script.js): `script.js`

### Backend services

- [HTTP API and AI proxy](https://github.com/vaishak08-nayak/rainsmart/blob/main/server.js): `server.js`

### Persistent data

- [User and settings store](https://github.com/vaishak08-nayak/rainsmart/blob/main/db.js): `db.js`

### Other components

- **RainSmart user**
- **Open-Meteo geocoding**
- **Open-Meteo forecast**
- **Open-Meteo archive**
- **Google Gemini**
- **OpenAI fallback**

## Connections

- RainSmart user → Main dashboard: opens (evidence: `README.md`)
- Main dashboard → Dashboard logic: runs (evidence: `README.md`)
- Dashboard logic → Location geocoding: searches locations (evidence: `README.md`)
- Location geocoding → Open-Meteo geocoding: queries (evidence: `README.md`)
- Dashboard logic → Live weather forecast: fetches forecast (evidence: `README.md`)
- Live weather forecast → Open-Meteo forecast: queries (evidence: `README.md`)
- Dashboard logic → Historical rainfall: fetches history (evidence: `script.js`)
- Historical rainfall → Open-Meteo archive: queries (evidence: `README.md`)
- Dashboard logic → Catchment and tank model: recalculates (evidence: `README.md`)
- Dashboard logic → Rule-based water advisor: fallback advice (evidence: `script.js`)
- Dashboard logic → API endpoint config: resolves endpoints (evidence: `api-config.js`)
- Dashboard logic → HTTP API and AI proxy: requests chat (evidence: `script.js`)
- HTTP API and AI proxy → Google Gemini: queries models (evidence: `server.js`)
- HTTP API and AI proxy → OpenAI fallback: fallback query (evidence: `server.js`)
- Sign-in and registration → HTTP API and AI proxy: uses auth API (evidence: `README.md`)
- User dashboard → HTTP API and AI proxy: uses user API
- Admin dashboard → HTTP API and AI proxy: uses admin API (evidence: `server.js`)
- Welcome page → Main dashboard: continues to
- HTTP API and AI proxy → User and settings store: reads and writes (evidence: `server.js`)
