# nayi-disha-org/nayi-disha architecture

> Architecture diagram of the GitHub repository nayi-disha-org/nayi-disha, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nayi-disha-org/nayi-disha
- Repository: https://github.com/nayi-disha-org/nayi-disha

## Overview

Nayi-Disha is a family and care-support platform with React role-based portals, an Express/PostgreSQL API, and an ESP32 hardware component. The main flow is a user selecting a role, authenticating, then using care workflows that exchange data with backend routes and database controllers. The README documents additional routines, hardware, AI-notification and weather capabilities; their source excerpts are limited, so those links are shown only where documented or marked unverified.

Main entry points: [`frontend/src/App.jsx`](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/App.jsx) (Role portals), [`backend/server.js`](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/server.js) (Express API server), [`frontend/src/pages/features/WeatherEngine.jsx`](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/features/WeatherEngine.jsx) (Weather dashboard), [`frontend/src/components/PortalLayout.jsx`](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/PortalLayout.jsx) (Portal layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["Role portals<br/>[App.jsx]"]
  node_authpage["Role sign-in<br/>[RoleAuth.jsx]"]
  node_authstate["Session context<br/>[AuthContext.jsx]"]
  node_account["Account settings"]
  node_api["API client<br/>[api.js]"]
  node_layout["Portal layout<br/>[PortalLayout.jsx]"]
  node_branding["Brand identity<br/>[BrandLogo.jsx]"]
  node_icons["Interface icons<br/>[Icons.jsx]"]
end

subgraph group_backend["Backend API"]
  node_health_routes["Health routes<br/>[healthRoutes.js]"]
  node_health_controller["Health and care data"]
  node_auth_routes["Authentication routes<br/>[authRoutes.js]"]
  node_auth_controller["Authentication and profiles<br/>[authController.js]"]
  node_server["Express API server<br/>[server.js]"]
  node_other_routes["Routine and hardware routes"]
end

subgraph group_care["Care workflows"]
  node_care_ui["Care and role pages"]
  node_weather_ui["Weather dashboard<br/>[WeatherEngine.jsx]"]
end

subgraph group_platform["Platform services"]
  node_db_pool[("PostgreSQL pool<br/>[db.js]")]
  node_weather_service["Weather engine<br/>[weatherEngine.js]"]
  node_notifier["LLM notifier<br/>[llmNotifier.js]"]
  node_hardware["ESP32 band<br/>[config.h]"]
  node_cloudinary["Cloudinary integration<br/>[cloudinary.js]"]
end

node_families(("Families and staff"))
node_postgres[("PostgreSQL service")]

node_families -->|"select role"| node_app
node_app -->|"routes to"| node_authpage
node_authpage -->|"submits credentials"| node_api
node_authpage -->|"updates session"| node_authstate
node_authstate -->|"provides session"| node_app
node_app -->|"routes to"| node_account
node_app -->|"routes to"| node_care_ui
node_account -->|"requests profile"| node_api
node_care_ui -.->|"requests care data"| node_api
node_care_ui -.->|"renders pages"| node_layout
node_weather_ui -->|"renders within"| node_layout
node_weather_ui -->|"renders icon"| node_icons
node_layout -->|"renders logo"| node_branding
node_layout -->|"renders icon"| node_icons
node_api -->|"calls API"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_health_routes
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_health_routes -->|"dispatches requests"| node_health_controller
node_auth_controller -->|"queries users"| node_db_pool
node_health_controller -->|"queries care data"| node_db_pool
node_db_pool -->|"connects to"| node_postgres
node_server -.->|"mounts routes"| node_other_routes
node_families -.->|"views forecasts"| node_weather_ui
node_weather_ui -.->|"syncs warnings"| node_hardware
node_weather_service -.->|"supports forecasts"| node_weather_ui
node_notifier -.->|"notifies users"| node_families
node_cloudinary -.->|"optional media integration"| node_server

click node_app "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/App.jsx"
click node_authpage "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/auth/RoleAuth.jsx"
click node_authstate "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/context/AuthContext.jsx"
click node_account "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/AccountSettings.jsx"
click node_api "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/services/api.js"
click node_layout "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/PortalLayout.jsx"
click node_branding "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/BrandLogo.jsx"
click node_icons "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/Icons.jsx"
click node_care_ui "https://github.com/nayi-disha-org/nayi-disha/tree/main/frontend/src/pages"
click node_weather_ui "https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/features/WeatherEngine.jsx"
click node_health_routes "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/routes/healthRoutes.js"
click node_health_controller "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/controllers/healthController.js"
click node_auth_routes "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/routes/authRoutes.js"
click node_auth_controller "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/controllers/authController.js"
click node_server "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/server.js"
click node_db_pool "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/config/db.js"
click node_other_routes "https://github.com/nayi-disha-org/nayi-disha/tree/main/backend/routes"
click node_weather_service "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/utils/weatherEngine.js"
click node_notifier "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/utils/llmNotifier.js"
click node_hardware "https://github.com/nayi-disha-org/nayi-disha/blob/main/hardware/esp32_band/config.h"
click node_cloudinary "https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/config/cloudinary.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_authpage,node_authstate,node_account,node_api,node_layout,node_branding,node_icons toneBlue
class node_health_routes,node_health_controller,node_auth_routes,node_auth_controller,node_server,node_other_routes,node_postgres toneAmber
class node_care_ui,node_weather_ui toneMint
class node_db_pool,node_weather_service,node_notifier,node_hardware,node_cloudinary toneRose
class node_families toneIndigo
```

## Components

### Frontend

- [Role portals](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Role sign-in](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/auth/RoleAuth.jsx): `frontend/src/pages/auth/RoleAuth.jsx`
- [Session context](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Account settings](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/AccountSettings.jsx): `frontend/src/pages/AccountSettings.jsx`
- [API client](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Portal layout](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/PortalLayout.jsx): `frontend/src/components/PortalLayout.jsx`
- [Brand identity](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/BrandLogo.jsx): `frontend/src/components/BrandLogo.jsx`
- [Interface icons](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/components/Icons.jsx): `frontend/src/components/Icons.jsx`

### Backend API

- [Health routes](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/routes/healthRoutes.js): `backend/routes/healthRoutes.js`
- [Health and care data](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/controllers/healthController.js): `backend/controllers/healthController.js`
- [Authentication routes](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Authentication and profiles](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Express API server](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/server.js): `backend/server.js`
- [Routine and hardware routes](https://github.com/nayi-disha-org/nayi-disha/tree/main/backend/routes): `backend/routes`

### Care workflows

- [Care and role pages](https://github.com/nayi-disha-org/nayi-disha/tree/main/frontend/src/pages): `frontend/src/pages`
- [Weather dashboard](https://github.com/nayi-disha-org/nayi-disha/blob/main/frontend/src/pages/features/WeatherEngine.jsx): `frontend/src/pages/features/WeatherEngine.jsx`

### Platform services

- [PostgreSQL pool](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/config/db.js): `backend/config/db.js`
- [Weather engine](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/utils/weatherEngine.js): `backend/utils/weatherEngine.js`
- [LLM notifier](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/utils/llmNotifier.js): `backend/utils/llmNotifier.js`
- [ESP32 band](https://github.com/nayi-disha-org/nayi-disha/blob/main/hardware/esp32_band/config.h): `hardware/esp32_band/config.h`
- [Cloudinary integration](https://github.com/nayi-disha-org/nayi-disha/blob/main/backend/config/cloudinary.js): `backend/config/cloudinary.js`

### Other components

- **Families and staff**
- **PostgreSQL service**

## Connections

- Families and staff → Role portals: select role
- Role portals → Role sign-in: routes to (evidence: `frontend/src/App.jsx`)
- Role sign-in → API client: submits credentials (evidence: `frontend/src/pages/auth/RoleAuth.jsx`)
- Role sign-in → Session context: updates session (evidence: `frontend/src/pages/auth/RoleAuth.jsx`)
- Session context → Role portals: provides session (evidence: `frontend/src/App.jsx`)
- Role portals → Account settings: routes to (evidence: `frontend/src/App.jsx`)
- Role portals → Care and role pages: routes to (evidence: `frontend/src/App.jsx`)
- Account settings → API client: requests profile (evidence: `frontend/src/pages/AccountSettings.jsx`)
- Care and role pages → API client: requests care data (evidence: `frontend/src/pages/auth/RoleAuth.jsx`)
- Care and role pages → Portal layout: renders pages (evidence: `frontend/src/pages/features/WeatherEngine.jsx`)
- Weather dashboard → Portal layout: renders within (evidence: `frontend/src/pages/features/WeatherEngine.jsx`)
- Weather dashboard → Interface icons: renders icon (evidence: `frontend/src/pages/features/WeatherEngine.jsx`)
- Portal layout → Brand identity: renders logo (evidence: `frontend/src/components/PortalLayout.jsx`)
- Portal layout → Interface icons: renders icon (evidence: `frontend/src/components/PortalLayout.jsx`)
- API client → Express API server: calls API
- Express API server → Authentication routes: mounts routes (evidence: `backend/server.js`)
- Express API server → Health routes: mounts routes (evidence: `backend/server.js`)
- Authentication routes → Authentication and profiles: dispatches requests (evidence: `backend/routes/authRoutes.js`)
- Health routes → Health and care data: dispatches requests (evidence: `backend/routes/healthRoutes.js`)
- Authentication and profiles → PostgreSQL pool: queries users (evidence: `backend/controllers/authController.js`)
- Health and care data → PostgreSQL pool: queries care data (evidence: `backend/controllers/healthController.js`)
- PostgreSQL pool → PostgreSQL service: connects to (evidence: `backend/config/db.js`)
- Express API server → Routine and hardware routes: mounts routes (evidence: `backend/server.js`)
- Families and staff → Weather dashboard: views forecasts
- Weather dashboard → ESP32 band: syncs warnings
- Weather engine → Weather dashboard: supports forecasts
- LLM notifier → Families and staff: notifies users
- Cloudinary integration → Express API server: optional media integration
