# sgs-mythili/weatherapp architecture

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

- Interactive diagram: https://gitdiagram.com/sgs-mythili/weatherapp
- Repository: https://github.com/sgs-mythili/weatherapp

## Overview

This is a multi-tenant weather dashboard with current conditions, five-day forecasts, and searchable, paginated, editable city favorites. Users browse weather or favorites in the frontend; query hooks and the API client send tenant-tagged requests to the Hapi backend, which validates tenants, obtains weather data or manages favorites in PostgreSQL, and returns results for display. The graph reflects sampled calls and SOURCE INDEX references; frontend-to-backend HTTP links are dashed because no excerpt shows the full route wiring.

Main entry points: [`frontend/src/App.tsx`](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/App.tsx) (App routing), [`frontend/src/services/weatherApi.ts`](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/services/weatherApi.ts) (Frontend API adapter), [`frontend/src/pages/DashboardPage.tsx`](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/DashboardPage.tsx) (Dashboard page), [`frontend/src/pages/FavoritesPage.tsx`](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/FavoritesPage.tsx) (Favorites page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard frontend"]
  node_app["App routing<br/>[App.tsx]"]
  node_dashboard["Dashboard page<br/>[DashboardPage.tsx]"]
  node_citydetails["City details"]
  node_favoritespage["Favorites page<br/>[FavoritesPage.tsx]"]
  node_favoritecities["Favorite cities view<br/>[FavoriteCities.tsx]"]
  node_weatherqueries["Weather queries<br/>[useWeather.ts]"]
  node_forecastquery["Forecast query"]
  node_favoritequeries["Favorite queries<br/>[useFavorites.ts]"]
  node_addmutation["Add favorite mutation"]
  node_weatherapi["Frontend API adapter<br/>[weatherApi.ts]"]
  node_apiclient["HTTP API client<br/>[ApiService.ts]"]
  node_store["Tenant and units<br/>[weatherStore.ts]"]
end

subgraph group_api["Backend API"]
  node_backend["Hapi server<br/>[server.ts]"]
  node_weatherroutes["Weather routes<br/>[weather.ts]"]
  node_favoriteroutes["Favorite routes<br/>[favorites.ts]"]
  node_weatherhandler["Weather handlers<br/>[weatherHandler.ts]"]
  node_favoritehandlers["Favorite handlers"]
  node_tenantvalidation["Tenant validation<br/>[validateTenant.ts]"]
end

subgraph group_weather["Weather service"]
  node_weatherservice["Weather and forecast<br/>[weatherService.ts]"]
end

subgraph group_favorites["Favorites and data"]
  node_favoriteservice["Favorite service<br/>[favoriteService.ts]"]
  node_repository["Favorite repository"]
  node_favoritemodel["Favorite model<br/>[favoriteModel.ts]"]
  node_tenantmodel["Tenant model<br/>[tenantModel.ts]"]
  node_database[("PostgreSQL<br/>[db.ts]")]
end

node_user(("Dashboard user"))
node_weatherprovider["Geocoding and weather APIs"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_favoritespage
node_app -->|"routes to"| node_citydetails
node_app -->|"reads and updates"| node_store
node_dashboard -->|"loads weather"| node_weatherqueries
node_dashboard -->|"adds favorite"| node_addmutation
node_citydetails -->|"loads forecast"| node_forecastquery
node_favoritespage -->|"loads favorites"| node_favoritequeries
node_favoritespage -->|"renders"| node_favoritecities
node_favoritequeries -->|"requests favorites"| node_weatherapi
node_addmutation -->|"adds favorite"| node_weatherapi
node_weatherqueries -->|"requests weather"| node_weatherapi
node_forecastquery -->|"requests forecast"| node_weatherapi
node_weatherapi -->|"delegates requests"| node_apiclient
node_apiclient -->|"reads tenant"| node_store
node_apiclient -.->|"sends HTTP requests"| node_backend
node_backend -->|"registers routes"| node_weatherroutes
node_backend -->|"registers routes"| node_favoriteroutes
node_weatherroutes -->|"dispatches"| node_weatherhandler
node_favoriteroutes -->|"dispatches"| node_favoritehandlers
node_weatherhandler -->|"validates tenant"| node_tenantvalidation
node_weatherhandler -->|"gets weather"| node_weatherservice
node_favoritehandlers -->|"validates tenant"| node_tenantvalidation
node_favoritehandlers -->|"manages favorites"| node_favoriteservice
node_weatherservice -->|"fetches conditions"| node_weatherprovider
node_tenantvalidation -->|"checks tenant"| node_tenantmodel
node_favoriteservice -->|"delegates persistence"| node_repository
node_repository -->|"queries records"| node_favoritemodel
node_favoritemodel -->|"uses connection"| node_database
node_tenantmodel -->|"uses connection"| node_database

click node_app "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/App.tsx"
click node_dashboard "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/DashboardPage.tsx"
click node_citydetails "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/CityDetailsPage.tsx"
click node_favoritespage "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/FavoritesPage.tsx"
click node_favoritecities "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/components/FavoriteCities.tsx"
click node_weatherqueries "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/weather/useWeather.ts"
click node_forecastquery "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/weather/useFiveDayForecast.ts"
click node_favoritequeries "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/favorites/useFavorites.ts"
click node_addmutation "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/favorites/useAddFavoriteMutation.ts"
click node_weatherapi "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/services/weatherApi.ts"
click node_apiclient "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/services/ApiService.ts"
click node_store "https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/store/weatherStore.ts"
click node_backend "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/server.ts"
click node_weatherroutes "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/routes/weather.ts"
click node_favoriteroutes "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/routes/favorites.ts"
click node_weatherhandler "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/handlers/weatherHandler.ts"
click node_favoritehandlers "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/handlers/favoriteHandlers.ts"
click node_tenantvalidation "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/utils/validateTenant.ts"
click node_weatherservice "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/services/weatherService.ts"
click node_favoriteservice "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/services/favoriteService.ts"
click node_repository "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/repositories/favoritesRepository.ts"
click node_favoritemodel "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/models/favoriteModel.ts"
click node_tenantmodel "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/models/tenantModel.ts"
click node_database "https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/database/db.ts"

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_dashboard,node_citydetails,node_favoritespage,node_favoritecities,node_weatherqueries,node_forecastquery,node_favoritequeries,node_addmutation,node_weatherapi,node_apiclient,node_store,node_user toneBlue
class node_backend,node_weatherroutes,node_favoriteroutes,node_weatherhandler,node_favoritehandlers,node_tenantvalidation toneAmber
class node_weatherservice,node_weatherprovider toneMint
class node_favoriteservice,node_repository,node_favoritemodel,node_tenantmodel,node_database toneRose
```

## Components

### Dashboard frontend

- [App routing](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard page](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [City details](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/CityDetailsPage.tsx): `frontend/src/pages/CityDetailsPage.tsx`
- [Favorites page](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/pages/FavoritesPage.tsx): `frontend/src/pages/FavoritesPage.tsx`
- [Favorite cities view](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/components/FavoriteCities.tsx): `frontend/src/components/FavoriteCities.tsx`
- [Weather queries](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/weather/useWeather.ts): `frontend/src/queries/weather/useWeather.ts`
- [Forecast query](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/weather/useFiveDayForecast.ts): `frontend/src/queries/weather/useFiveDayForecast.ts`
- [Favorite queries](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/favorites/useFavorites.ts): `frontend/src/queries/favorites/useFavorites.ts`
- [Add favorite mutation](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/queries/favorites/useAddFavoriteMutation.ts): `frontend/src/queries/favorites/useAddFavoriteMutation.ts`
- [Frontend API adapter](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/services/weatherApi.ts): `frontend/src/services/weatherApi.ts`
- [HTTP API client](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/services/ApiService.ts): `frontend/src/services/ApiService.ts`
- [Tenant and units](https://github.com/sgs-mythili/weatherapp/blob/master/frontend/src/store/weatherStore.ts): `frontend/src/store/weatherStore.ts`

### Backend API

- [Hapi server](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/server.ts): `backend/src/server.ts`
- [Weather routes](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/routes/weather.ts): `backend/src/routes/weather.ts`
- [Favorite routes](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/routes/favorites.ts): `backend/src/routes/favorites.ts`
- [Weather handlers](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/handlers/weatherHandler.ts): `backend/src/handlers/weatherHandler.ts`
- [Favorite handlers](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/handlers/favoriteHandlers.ts): `backend/src/handlers/favoriteHandlers.ts`
- [Tenant validation](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/utils/validateTenant.ts): `backend/src/utils/validateTenant.ts`

### Weather service

- [Weather and forecast](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/services/weatherService.ts): `backend/src/services/weatherService.ts`

### Favorites and data

- [Favorite service](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/services/favoriteService.ts): `backend/src/services/favoriteService.ts`
- [Favorite repository](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/repositories/favoritesRepository.ts): `backend/src/repositories/favoritesRepository.ts`
- [Favorite model](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/models/favoriteModel.ts): `backend/src/models/favoriteModel.ts`
- [Tenant model](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/models/tenantModel.ts): `backend/src/models/tenantModel.ts`
- [PostgreSQL](https://github.com/sgs-mythili/weatherapp/blob/master/backend/src/database/db.ts): `backend/src/database/db.ts`

### Other components

- **Dashboard user**
- **Geocoding and weather APIs**

## Connections

- Dashboard user → App routing: uses (evidence: `frontend/src/App.tsx`)
- App routing → Dashboard page: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Favorites page: routes to (evidence: `frontend/src/App.tsx`)
- App routing → City details: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Tenant and units: reads and updates (evidence: `frontend/src/App.tsx`)
- Dashboard page → Weather queries: loads weather (evidence: `frontend/src/pages/DashboardPage.tsx`)
- Dashboard page → Add favorite mutation: adds favorite (evidence: `frontend/src/pages/DashboardPage.tsx`)
- City details → Forecast query: loads forecast (evidence: `frontend/src/pages/CityDetailsPage.tsx`)
- Favorites page → Favorite queries: loads favorites (evidence: `frontend/src/pages/FavoritesPage.tsx`)
- Favorites page → Favorite cities view: renders (evidence: `frontend/src/pages/FavoritesPage.tsx`)
- Favorite queries → Frontend API adapter: requests favorites (evidence: `frontend/src/queries/favorites/useFavorites.ts`)
- Add favorite mutation → Frontend API adapter: adds favorite (evidence: `frontend/src/queries/favorites/useAddFavoriteMutation.ts`)
- Weather queries → Frontend API adapter: requests weather (evidence: `frontend/src/queries/weather/useWeather.ts`)
- Forecast query → Frontend API adapter: requests forecast (evidence: `frontend/src/queries/weather/useFiveDayForecast.ts`)
- Frontend API adapter → HTTP API client: delegates requests (evidence: `frontend/src/services/weatherApi.ts`)
- HTTP API client → Tenant and units: reads tenant (evidence: `frontend/src/services/ApiService.ts`)
- HTTP API client → Hapi server: sends HTTP requests
- Hapi server → Weather routes: registers routes (evidence: `backend/src/server.ts`)
- Hapi server → Favorite routes: registers routes (evidence: `backend/src/server.ts`)
- Weather routes → Weather handlers: dispatches (evidence: `backend/src/routes/weather.ts`)
- Favorite routes → Favorite handlers: dispatches (evidence: `backend/src/routes/favorites.ts`)
- Weather handlers → Tenant validation: validates tenant (evidence: `backend/src/handlers/weatherHandler.ts`)
- Weather handlers → Weather and forecast: gets weather (evidence: `backend/src/handlers/weatherHandler.ts`)
- Favorite handlers → Tenant validation: validates tenant (evidence: `backend/src/handlers/favoriteHandlers.ts`)
- Favorite handlers → Favorite service: manages favorites (evidence: `backend/src/handlers/favoriteHandlers.ts`)
- Weather and forecast → Geocoding and weather APIs: fetches conditions (evidence: `backend/src/services/weatherService.ts`)
- Tenant validation → Tenant model: checks tenant (evidence: `backend/src/utils/validateTenant.ts`)
- Favorite service → Favorite repository: delegates persistence (evidence: `backend/src/services/favoriteService.ts`)
- Favorite repository → Favorite model: queries records (evidence: `backend/src/repositories/favoritesRepository.ts`)
- Favorite model → PostgreSQL: uses connection (evidence: `backend/src/models/favoriteModel.ts`)
- Tenant model → PostgreSQL: uses connection (evidence: `backend/src/models/tenantModel.ts`)
