How sgs-mythili/weatherapp works
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: App.tsx App routing · weatherApi.ts Frontend API adapter · DashboardPage.tsx Dashboard page · FavoritesPage.tsx Favorites page
Components 26
Dashboard frontend
- App routing
frontend/src/App.tsx - Dashboard page
frontend/src/pages/DashboardPage.tsx - City details
frontend/src/pages/CityDetailsPage.tsx - Favorites page
frontend/src/pages/FavoritesPage.tsx - Favorite cities view
frontend/src/components/FavoriteCities.tsx - Weather queries
frontend/src/queries/weather/useWeather.ts - Forecast query
frontend/src/queries/weather/useFiveDayForecast.ts - Favorite queries
frontend/src/queries/favorites/useFavorites.ts - Add favorite mutation
frontend/src/queries/favorites/useAddFavoriteMutation.ts - Frontend API adapter
frontend/src/services/weatherApi.ts - HTTP API client
frontend/src/services/ApiService.ts - Tenant and units
frontend/src/store/weatherStore.ts
Backend API
- Hapi server
backend/src/server.ts - Weather routes
backend/src/routes/weather.ts - Favorite routes
backend/src/routes/favorites.ts - Weather handlers
backend/src/handlers/weatherHandler.ts - Favorite handlers
backend/src/handlers/favoriteHandlers.ts - Tenant validation
backend/src/utils/validateTenant.ts
Weather service
- Weather and forecast
backend/src/services/weatherService.ts
Favorites and data
- Favorite service
backend/src/services/favoriteService.ts - Favorite repository
backend/src/repositories/favoritesRepository.ts - Favorite model
backend/src/models/favoriteModel.ts - Tenant model
backend/src/models/tenantModel.ts - PostgreSQL
backend/src/database/db.ts
Other components
- Dashboard user
- Geocoding and weather APIs
Connections 31
- Dashboard user → App routing: uses
frontend/src/App.tsx - App routing → Dashboard page: routes to
frontend/src/App.tsx - App routing → Favorites page: routes to
frontend/src/App.tsx - App routing → City details: routes to
frontend/src/App.tsx - App routing → Tenant and units: reads and updates
frontend/src/App.tsx - Dashboard page → Weather queries: loads weather
frontend/src/pages/DashboardPage.tsx - Dashboard page → Add favorite mutation: adds favorite
frontend/src/pages/DashboardPage.tsx - City details → Forecast query: loads forecast
frontend/src/pages/CityDetailsPage.tsx - Favorites page → Favorite queries: loads favorites
frontend/src/pages/FavoritesPage.tsx - Favorites page → Favorite cities view: renders
frontend/src/pages/FavoritesPage.tsx - Favorite queries → Frontend API adapter: requests favorites
frontend/src/queries/favorites/useFavorites.ts - Add favorite mutation → Frontend API adapter: adds favorite
frontend/src/queries/favorites/useAddFavoriteMutation.ts - Weather queries → Frontend API adapter: requests weather
frontend/src/queries/weather/useWeather.ts - Forecast query → Frontend API adapter: requests forecast
frontend/src/queries/weather/useFiveDayForecast.ts - Frontend API adapter → HTTP API client: delegates requests
frontend/src/services/weatherApi.ts - HTTP API client → Tenant and units: reads tenant
frontend/src/services/ApiService.ts - HTTP API client → Hapi server: sends HTTP requests
- Hapi server → Weather routes: registers routes
backend/src/server.ts - Hapi server → Favorite routes: registers routes
backend/src/server.ts - Weather routes → Weather handlers: dispatches
backend/src/routes/weather.ts - Favorite routes → Favorite handlers: dispatches
backend/src/routes/favorites.ts - Weather handlers → Tenant validation: validates tenant
backend/src/handlers/weatherHandler.ts - Weather handlers → Weather and forecast: gets weather
backend/src/handlers/weatherHandler.ts - Favorite handlers → Tenant validation: validates tenant
backend/src/handlers/favoriteHandlers.ts - Favorite handlers → Favorite service: manages favorites
backend/src/handlers/favoriteHandlers.ts - Weather and forecast → Geocoding and weather APIs: fetches conditions
backend/src/services/weatherService.ts - Tenant validation → Tenant model: checks tenant
backend/src/utils/validateTenant.ts - Favorite service → Favorite repository: delegates persistence
backend/src/services/favoriteService.ts - Favorite repository → Favorite model: queries records
backend/src/repositories/favoritesRepository.ts - Favorite model → PostgreSQL: uses connection
backend/src/models/favoriteModel.ts - Tenant model → PostgreSQL: uses connection
backend/src/models/tenantModel.ts