How gdeep01/bindaas-blr works
1. High-level shape
- This is a React 18 + TypeScript + Vite single-page application deployed on Vercel, with Supabase serving as the backend database/auth/function layer.
- The app is organized around city intel use cases for Bengaluru: traffic, commute planning, livability/mood, garbage reporting, landslide alerts, and AI-generated insights.
2. Frontend shell and routing
- src/main.tsx bootstraps the app, src/App.tsx wires the top-level layout and routes, and src/pages/* contains the page-level screens.
- Pages are feature-oriented rather than generic: DashboardPage, CommutePage, MapPage, GarbagePage, LandslidePage, MoodIndexPage, AIInsightsPage, plus auth callback and “my reports” flows.
3. Presentation layer vs shared UI
- The UI is split into reusable primitives in src/components/ui and feature widgets in src/components/*.
- Larger feature clusters exist for specific domains: dashboard/, mood/, and garbage/, which suggests the app composes many small cards/panels rather than a monolithic screen.
- Map-related screens use TrafficMap, TrafficMapInner, MapSearchBox, and location-centric cards for hotspots, stations, and insights.
4. Client-side state and data access
- Cross-cutting client state is handled with React contexts and hooks, especially TrafficDataContext.
- Data access is mostly via custom hooks in src/hooks, such as auth/profile handling, notifications, install prompt, theme, locality metrics, route timing, and route reliability.
- This keeps pages thin: they orchestrate UI and rely on hooks for computed data or API-backed state.
5. Backend boundary: Supabase is the main server
- The only explicit backend integration in the frontend is src/integrations/supabase/client.ts.
- Supabase provides authentication, Postgres storage, and serverless/edge execution; there is no separate custom Node backend in this repo.
- Auth flows are visible in AuthModal, AuthCallbackPage, useAuth, useProfile, and edge functions like on-user-created and update-display-name.
6. Data pipeline for traffic
- Traffic is the core real-time pipeline: TomTom Traffic API → traffic-scheduler edge function → Supabase tables (traffic_history and related cached state) → frontend dashboards/maps.
- The frontend consumes prepared data rather than calling TomTom directly on every render.
- src/lib/trafficApi.ts, trafficHistory.ts, mapConstants.ts, and TrafficDataContext are the client-side pieces that shape and consume this data.
7. AI insights pipeline
- AI-generated traffic predictions are not computed in the browser; they are produced server-side by the traffic-insights Supabase function.
- The README indicates Gemini 1.5 Flash reads the latest traffic snapshot, generates structured predictions, and stores them in Supabase for the frontend to read as a cache.
- This is an important architectural boundary: expensive inference is decoupled from page loads.
8. Batch/cron-driven data refresh
- Several Supabase migrations point to a scheduled-data architecture: centralized_data_scheduler, reduced scheduler frequency, and security/data integrity hardening.
- The repo’s cron setup refreshes traffic periodically, and additional edge functions update livability scores and other derived datasets.
- In other words, much of the app’s “live” feel comes from scheduled ingestion and precomputation, not real-time socket streaming.
9. Domain subsystems
- Commute planning: route timing and reliability logic lives in src/lib/commute.ts and src/lib/routeTiming.ts, backed by a large historical route_reliability dataset.
- Livability / mood: the mood feature set combines area scoring, comparisons, and metric bars using static datasets and hooks like useLocalityMetrics and useLocalityScoreTrends.
- Garbage reporting: user-submitted reports combine photo upload, location capture, moderation/upvote flows, and official hotspot data.
- Disaster alerts: landslide risk and natural-event data are surfaced via landslide-predictions, plus external feeds for earthquakes and events.
10. Static data and derived analytics
- src/data/* contains bundled datasets for Bengaluru metro stations, property prices, garbage data, mood data, and traffic data.
- These datasets feed visualizations and computed scores such as livability, property growth, and station/proximity-based metrics.
- The app appears to mix static reference datasets with fresh backend-fed operational data, which is a key diagram boundary.
11. Offline and installability
- The presence of public/manifest.json, public/sw.js, and public/offline.html indicates this is a PWA-capable app.
- useInstallPrompt and InstallPromptBanner show that install UX is built into the frontend.
- This matters architecturally because the app supports offline fallback and install prompts, not just standard SPA navigation.
12. Notifications and user engagement
- useNotifications and NotificationsPanel suggest a user-facing notification subsystem, likely tied to Supabase-backed events or app-level alerts.
- This is a secondary but important flow alongside auth and reporting, especially for civic alerts and updates.
13. Maps and geospatial interaction
- Mapping is a major UI boundary, implemented with Leaflet and clustering support.
- Several screens and widgets are geospatial: traffic corridors/hotspots, garbage reports, airport stations, and likely locality comparisons on map layers.
- The map layer acts as the common visualization surface for many otherwise separate data products.
14. Operational concerns and quality
- supabase/migrations and supabase/sql show the schema and scheduled-job logic are versioned alongside the app, which is important for diagramming deployment dependencies.
- Tests exist for core computation in src/lib/__tests__ and a Vitest setup in src/test/setup.ts, indicating the numeric/route-planning logic is treated as a stable computation layer.
- Vercel handles SPA hosting and rewrite routing, while Supabase hosts the backend runtime and persistent state.
15. Architectural summary
- The repo is best drawn as a client-heavy civic intelligence SPA with:
- a React presentation layer,
- a Supabase-backed data and auth layer,
- scheduled ingestion/AI edge functions,
- static reference datasets,
- and PWA/offline capabilities.
- The central design pattern is precompute and cache on the backend, render and compare on the frontend.
Main entry points: pages Pages · functions Edge functions · components Feature widgets · data Static data
Components 28
Frontend app
React SPA shell, pages, and UI composition
- Boot · Starts the React app
src/main.tsx - App shell · Top-level routing and layout composition
src/App.tsx - Layout · Shared app chrome and navigation
src/components/AppLayout.tsx - Pages · Feature-oriented screens for dashboard, map, commute, alerts, and reports
src/pages - Dashboard · Main civic intelligence overview
src/pages/DashboardPage.tsx - Map · Traffic and locality map experience
src/pages/MapPage.tsx - Commute · Route timing and reliability views
src/pages/CommutePage.tsx - Garbage · Waste reporting and moderation flows
src/pages/GarbagePage.tsx - Mood index · Area comparisons and livability scoring
src/pages/MoodIndexPage.tsx - Landslide · Disaster risk and alert views
src/pages/LandslidePage.tsx - AI insights · Traffic prediction and AI-generated analysis
src/pages/AIInsightsPage.tsx - Traffic context · Shared traffic state and prepared data for the UI
src/contexts/TrafficDataContext.tsx - Hooks · Auth, profile, notifications, install prompt, theme, and route metrics
src/hooks - UI kit · Reusable primitives and base widgets
src/components/ui - Feature widgets · Dashboard, map, mood, garbage, and alert panels
src/components
Supabase backend
Auth, storage, scheduled functions, and schema
- Supabase client · Frontend connection point to Supabase
src/integrations/supabase/client.ts - Edge functions · Scheduled jobs, auth hooks, and civic APIs
supabase/functions - Traffic scheduler · Fetches and refreshes traffic snapshots
supabase/functions/traffic-scheduler/index.ts - Traffic insights · Generates structured predictions from recent traffic state
supabase/functions/traffic-insights/index.ts - Civic reports · Creates and manages civic report records
supabase/functions/civic-reports/index.ts - Garbage upvote · Handles report upvotes and moderation signals
supabase/functions/garbage-upvote/index.ts - Landslide predictions · Produces landslide risk outputs
supabase/functions/landslide-predictions/index.ts - Livability refresh · Updates derived locality scores
supabase/functions/update-livability-scores/index.ts - Schema & jobs · Versioned database schema, security, and scheduler changes
supabase/migrations
Data layer
Static datasets and derived analytics consumed by the app
- Static data · Metro stations, prices, garbage, mood, and traffic seed data
src/data - Traffic lib · Traffic API, history, constants, and map shaping logic
src/lib/trafficApi.ts - Commute logic · Route timing, commute comparison, and reliability calculations
src/lib/commute.ts - Landslide API · External geospatial and event feed integration
src/lib/landslideApi.ts
Connections 36
- Boot → App shell: bootstraps · React entry mounts the app shell
- App shell → Layout: uses · Routes are rendered within shared chrome
- App shell → Pages: routes to · Top-level navigation reaches feature pages
- Pages → Dashboard: includes · Dashboard route
- Pages → Map: includes · Map route
- Pages → Commute: includes · Commute route
- Pages → Garbage: includes · Garbage route
- Pages → Mood index: includes · Mood route
- Pages → Landslide: includes · Landslide route
- Pages → AI insights: includes · AI insights route
- Dashboard → Feature widgets: composes · Dashboard is assembled from feature panels
- Map → Traffic context: reads · Map and traffic screens consume shared traffic state
- Map → Feature widgets: uses · Map screens use search, hotspots, stations, and insight cards
- Commute → Commute logic: computes with · Route planning uses timing and reliability logic
- Garbage → Feature widgets: composes · Report form and related panels
- Mood index → Feature widgets: composes · Livability comparison panels and bars
- Landslide → Landslide API: reads · Surface alerts and predictions from external feeds
- AI insights → Traffic insights: reads · AI page consumes stored predictions
- Hooks → Supabase client: calls · Auth, profile, notifications, and data hooks use Supabase
- Supabase client → Edge functions: invokes · Frontend reaches serverless endpoints through Supabase
- Edge functions → Traffic scheduler: contains · Traffic refresh job
- Edge functions → Traffic insights: contains · AI prediction job
- Edge functions → Civic reports: contains · Civic reporting API
- Edge functions → Garbage upvote: contains · Report voting/moderation API
- Edge functions → Landslide predictions: contains · Risk prediction API
- Edge functions → Livability refresh: contains · Derived score refresh job
- Traffic scheduler → Traffic lib: refreshes · Uses traffic API and history shaping
- Traffic insights → Traffic lib: analyzes · Builds predictions from current traffic snapshot
- Schema & jobs → Traffic scheduler: defines · Schema and cron coordination for scheduled refreshes
- Schema & jobs → Civic reports: supports · Database changes for civic reports and moderation
- Static data → Dashboard: feeds · Static datasets power summary views
- Static data → Mood index: feeds · Reference and scoring data for livability views
- Static data → Commute logic: feeds · Historical and reference data for route analysis
- Static data → Traffic lib: feeds · Seed and reference traffic data
- Traffic context → Traffic lib: derives from · Context shapes prepared traffic state
- Feature widgets → UI kit: built on · Feature components rely on shared primitives