# mritunjay20253162-code/weather-analytics architecture

> Architecture diagram of the GitHub repository mritunjay20253162-code/weather-analytics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mritunjay20253162-code/weather-analytics
- Repository: https://github.com/mritunjay20253162-code/weather-analytics

## Overview

NWBDAP collects citizen and external weather observations, processes them into classified and deduplicated reports, and exposes those reports for verification, mapping, and analytics. Users enter through the React dashboards; Firebase authentication and backend role checks protect identity-sensitive actions. The README also documents satellite/AWS data capabilities, though their ingestion implementation is not represented in the supplied tree. Edges are limited to excerpted calls, SOURCE INDEX references, or explicit README documentation; some UI-to-API links are therefore omitted or marked unverified.

Main entry points: [`backend/server.js`](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/server.js) (API server), [`backend/services/processWeatherReport.js`](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/processWeatherReport.js) (Report processing), [`backend/models/WeatherReport.js`](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/models/WeatherReport.js) (Weather report records), [`backend/routes/analyticsRoutes.js`](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/analyticsRoutes.js) (Analytics API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_app["Application router<br/>[App.jsx]"]
  node_userdash["User dashboard<br/>[UserDashboard.jsx]"]
  node_admindash["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_analyticscharts["Analytics charts"]
  node_weathermap["Weather map<br/>[WeatherMap.jsx]"]
  node_chatbot["Astra chatbot<br/>[GeminiChatbot.jsx]"]
  node_theme["Theme state<br/>[ThemeContext.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_authcontext["Auth state<br/>[AuthContext.jsx]"]
  node_firebaseclient["Firebase client<br/>[firebase.js]"]
  node_authmiddleware["Token and role checks<br/>[authMiddleware.js]"]
  node_userroute["User account API<br/>[userRoutes.js]"]
end

subgraph group_ingestion["Weather data processing"]
  node_citizenroute["Citizen report API<br/>[weatherRoutes.js]"]
  node_weatherapiroute["Weather API ingestion"]
  node_socialroute["External data ingestion"]
  node_processing["Report processing"]
  node_classifier["Weather classifier"]
  node_duplicates["Duplicate detection"]
end

subgraph group_insight["Mapping and analytics"]
  node_analyticsroute["Analytics API<br/>[analyticsRoutes.js]"]
  node_airoute["Weather AI API<br/>[aiRoutes.js]"]
end

subgraph group_persistence["Backend and records"]
  node_userstore[("User records<br/>[User.js]")]
  node_server["API server<br/>[server.js]"]
  node_reports[("Weather report records<br/>[WeatherReport.js]")]
end

node_citizen(("Citizen observer"))
node_administrator(("Administrator"))
node_openmeteo["Open-Meteo"]
node_gemini["Google Gemini"]

node_citizen -->|"submits reports"| node_userdash
node_administrator -->|"reviews reports"| node_admindash
node_app -->|"routes to"| node_userdash
node_app -->|"routes to"| node_admindash
node_app -->|"provides auth"| node_authcontext
node_authcontext -->|"uses"| node_firebaseclient
node_authcontext -.->|"syncs account"| node_userroute
node_server -->|"mounts"| node_userroute
node_server -->|"mounts"| node_citizenroute
node_server -->|"mounts"| node_weatherapiroute
node_server -->|"mounts"| node_socialroute
node_server -->|"mounts"| node_analyticsroute
node_server -->|"mounts"| node_airoute
node_userroute -->|"checks access"| node_authmiddleware
node_userroute -->|"reads and writes"| node_userstore
node_authmiddleware -->|"checks role"| node_userstore
node_citizenroute -->|"creates reports"| node_reports
node_citizenroute -->|"processes report"| node_processing
node_weatherapiroute -->|"fetches conditions"| node_openmeteo
node_weatherapiroute -->|"creates reports"| node_reports
node_weatherapiroute -->|"processes report"| node_processing
node_socialroute -->|"creates reports"| node_reports
node_socialroute -->|"processes report"| node_processing
node_processing -->|"updates report"| node_reports
node_processing -->|"classifies"| node_classifier
node_processing -->|"checks duplicates"| node_duplicates
node_analyticsroute -->|"queries reports"| node_reports
node_userdash -->|"renders"| node_analyticscharts
node_admindash -->|"renders"| node_analyticscharts
node_userdash -->|"renders"| node_weathermap
node_admindash -->|"renders"| node_weathermap
node_analyticscharts -.->|"fetches analytics"| node_analyticsroute
node_weathermap -.->|"fetches map data"| node_analyticsroute
node_chatbot -->|"requests AI answers"| node_gemini
node_app -->|"renders"| node_chatbot
node_weathermap -->|"reads theme"| node_theme
node_analyticsroute -->|"provides map and statistics"| node_reports

click node_app "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/App.jsx"
click node_userdash "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/pages/UserDashboard.jsx"
click node_admindash "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/pages/AdminDashboard.jsx"
click node_analyticscharts "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/AnalyticsCharts.jsx"
click node_weathermap "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/WeatherMap.jsx"
click node_chatbot "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/GeminiChatbot.jsx"
click node_theme "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/context/ThemeContext.jsx"
click node_authcontext "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/context/AuthContext.jsx"
click node_firebaseclient "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/services/firebase.js"
click node_authmiddleware "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/middleware/authMiddleware.js"
click node_userroute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/userRoutes.js"
click node_userstore "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/models/User.js"
click node_server "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/server.js"
click node_citizenroute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/weatherRoutes.js"
click node_weatherapiroute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/weatherApiRoutes.js"
click node_socialroute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/socialDataRoutes.js"
click node_processing "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/processWeatherReport.js"
click node_classifier "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/weatherClassifier.js"
click node_duplicates "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/duplicateDetector.js"
click node_reports "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/models/WeatherReport.js"
click node_analyticsroute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/analyticsRoutes.js"
click node_airoute "https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/aiRoutes.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_userdash,node_admindash,node_analyticscharts,node_weathermap,node_chatbot,node_theme toneBlue
class node_authcontext,node_firebaseclient,node_authmiddleware,node_userroute toneAmber
class node_citizenroute,node_weatherapiroute,node_socialroute,node_processing,node_classifier,node_duplicates,node_citizen toneMint
class node_analyticsroute,node_airoute toneRose
class node_userstore,node_server,node_reports,node_administrator,node_openmeteo,node_gemini toneIndigo
```

## Components

### Web experience

- [Application router](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/App.jsx): `src/App.jsx`
- [User dashboard](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/pages/UserDashboard.jsx): `src/pages/UserDashboard.jsx`
- [Admin dashboard](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/pages/AdminDashboard.jsx): `src/pages/AdminDashboard.jsx`
- [Analytics charts](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/AnalyticsCharts.jsx): `src/components/AnalyticsCharts.jsx`
- [Weather map](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/WeatherMap.jsx): `src/components/WeatherMap.jsx`
- [Astra chatbot](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/components/GeminiChatbot.jsx): `src/components/GeminiChatbot.jsx`
- [Theme state](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/context/ThemeContext.jsx): `src/context/ThemeContext.jsx`

### Identity and access

- [Auth state](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Firebase client](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/src/services/firebase.js): `src/services/firebase.js`
- [Token and role checks](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [User account API](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`

### Weather data processing

- [Citizen report API](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/weatherRoutes.js): `backend/routes/weatherRoutes.js`
- [Weather API ingestion](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/weatherApiRoutes.js): `backend/routes/weatherApiRoutes.js`
- [External data ingestion](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/socialDataRoutes.js): `backend/routes/socialDataRoutes.js`
- [Report processing](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/processWeatherReport.js): `backend/services/processWeatherReport.js`
- [Weather classifier](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/weatherClassifier.js): `backend/services/weatherClassifier.js`
- [Duplicate detection](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/services/duplicateDetector.js): `backend/services/duplicateDetector.js`

### Mapping and analytics

- [Analytics API](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/analyticsRoutes.js): `backend/routes/analyticsRoutes.js`
- [Weather AI API](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/routes/aiRoutes.js): `backend/routes/aiRoutes.js`

### Backend and records

- [User records](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/models/User.js): `backend/models/User.js`
- [API server](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/server.js): `backend/server.js`
- [Weather report records](https://github.com/mritunjay20253162-code/weather-analytics/blob/main/backend/models/WeatherReport.js): `backend/models/WeatherReport.js`

### Other components

- **Citizen observer**
- **Administrator**
- **Open-Meteo**
- **Google Gemini**

## Connections

- Citizen observer → User dashboard: submits reports
- Administrator → Admin dashboard: reviews reports
- Application router → User dashboard: routes to (evidence: `src/App.jsx`)
- Application router → Admin dashboard: routes to (evidence: `src/App.jsx`)
- Application router → Auth state: provides auth (evidence: `src/App.jsx`)
- Auth state → Firebase client: uses (evidence: `src/context/AuthContext.jsx`)
- Auth state → User account API: syncs account
- API server → User account API: mounts (evidence: `backend/server.js`)
- API server → Citizen report API: mounts (evidence: `backend/server.js`)
- API server → Weather API ingestion: mounts (evidence: `backend/server.js`)
- API server → External data ingestion: mounts (evidence: `backend/server.js`)
- API server → Analytics API: mounts (evidence: `backend/server.js`)
- API server → Weather AI API: mounts (evidence: `backend/server.js`)
- User account API → Token and role checks: checks access (evidence: `backend/routes/userRoutes.js`)
- User account API → User records: reads and writes (evidence: `backend/routes/userRoutes.js`)
- Token and role checks → User records: checks role (evidence: `backend/middleware/authMiddleware.js`)
- Citizen report API → Weather report records: creates reports (evidence: `backend/routes/weatherRoutes.js`)
- Citizen report API → Report processing: processes report (evidence: `backend/routes/weatherRoutes.js`)
- Weather API ingestion → Open-Meteo: fetches conditions (evidence: `backend/routes/weatherApiRoutes.js`)
- Weather API ingestion → Weather report records: creates reports (evidence: `backend/routes/weatherApiRoutes.js`)
- Weather API ingestion → Report processing: processes report (evidence: `backend/routes/weatherApiRoutes.js`)
- External data ingestion → Weather report records: creates reports (evidence: `backend/routes/socialDataRoutes.js`)
- External data ingestion → Report processing: processes report (evidence: `backend/routes/socialDataRoutes.js`)
- Report processing → Weather report records: updates report (evidence: `backend/services/processWeatherReport.js`)
- Report processing → Weather classifier: classifies (evidence: `backend/services/processWeatherReport.js`)
- Report processing → Duplicate detection: checks duplicates (evidence: `backend/services/processWeatherReport.js`)
- Analytics API → Weather report records: queries reports (evidence: `backend/routes/analyticsRoutes.js`)
- User dashboard → Analytics charts: renders (evidence: `src/pages/UserDashboard.jsx`)
- Admin dashboard → Analytics charts: renders (evidence: `src/pages/AdminDashboard.jsx`)
- User dashboard → Weather map: renders (evidence: `src/pages/UserDashboard.jsx`)
- Admin dashboard → Weather map: renders (evidence: `src/pages/AdminDashboard.jsx`)
- Analytics charts → Analytics API: fetches analytics
- Weather map → Analytics API: fetches map data
- Astra chatbot → Google Gemini: requests AI answers
- Application router → Astra chatbot: renders (evidence: `src/App.jsx`)
- Weather map → Theme state: reads theme (evidence: `src/components/WeatherMap.jsx`)
- Analytics API → Weather report records: provides map and statistics (evidence: `backend/routes/analyticsRoutes.js`)
