# sirithreddy175-boop/telangana-rytu-seva architecture

> Architecture diagram of the GitHub repository sirithreddy175-boop/telangana-rytu-seva, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sirithreddy175-boop/telangana-rytu-seva
- Repository: https://github.com/sirithreddy175-boop/telangana-rytu-seva

## Overview

#### Purpose and runtime
A TypeScript React/Vite application for an agriculture-focused farmer portal: weather and groundwater information, crop disease help, market prices and marketplace access, schemes/eligibility, localized content, reporting, and administration. Server-capable application startup is centered on `src/start.ts` and `src/server.ts`; browser routing is defined by `src/router.tsx` and generated `src/routeTree.gen.ts`.

#### Route and page composition
TanStack-style file routes provide the application’s navigation boundary. `src/routes/__root.tsx` establishes shared layout; `src/routes/index.tsx` is the public landing page; `src/routes/dashboard.tsx` and its `dashboard.*` children define authenticated/portal-style views. Administrative access is isolated in `src/routes/admin-login.tsx` and `src/routes/admin.tsx`.

#### Farmer dashboard domains
The UI is composed as feature-oriented React components rather than a monolithic dashboard. Key information and decision-support domains include weather (`src/components/WeatherCard.tsx`, `src/components/WeatherAlertBanner.tsx`), water (`src/components/Groundwater.tsx`, `src/components/LiveGroundwater.tsx`), market data (`src/components/Prices.tsx`, `src/components/Marketplace.tsx`), and public programs (`src/components/Schemes.tsx`, `src/components/EligibilityChecker.tsx`). Dedicated routed screens expose market prices, news, schemes, and villages.

#### Conversational and advisory interactions
AI and voice/chat experiences are front-end components backed by server-facing function modules: `src/components/AskAI.tsx`, `src/components/Chatbot.tsx`, and `src/lib/ai.functions.ts`; conversation and voice operations are separated in `src/lib/chat.functions.ts` and `src/lib/voice.functions.ts`. This boundary keeps credentialed or remote AI calls out of presentation components.

#### Location, localization, and data presentation
Location is a cross-cutting input to farmer-facing content, represented by `src/components/LocationSelector.tsx` and `src/lib/location.tsx`. Language switching and translation state live in `src/components/LanguageToggle.tsx` and `src/lib/i18n.tsx`. Domain data adapters include `src/lib/farm-data.ts`, `src/lib/weather.functions.ts`, and `src/lib/mandi.functions.ts`, which feed display components such as heatmaps, news, and prices.

#### Supabase persistence and authorization
Supabase is the primary backend integration, with browser/server clients separated in `src/integrations/supabase/client.ts` and `src/integrations/supabase/client.server.ts`. Authentication propagation is handled by `src/integrations/supabase/auth-attacher.ts` and `src/integrations/supabase/auth-middleware.ts`. Database schema evolution is versioned under `supabase/migrations/`; generated integration types reside in `src/integrations/supabase/types.ts`.

#### Administration and operational flows
Admin-only resource operations are separated from public farmer workflows through `src/components/admin/ResourceManager.tsx`, `src/lib/admin.functions.ts`, and `src/lib/use-admin.ts`. User reporting is an independent submission flow via `src/components/FloatingReportButton.tsx` and `src/components/ReportForm.tsx`. Shared error/configuration boundaries are provided by `src/lib/error-capture.ts`, `src/lib/error-page.ts`, and `src/lib/config.server.ts`.

Main entry points: [`src/integrations/supabase/client.ts`](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/integrations/supabase/client.ts) (Supabase clients), [`src/routes/dashboard.tsx`](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/dashboard.tsx) (Dashboard routes), [`src/components/WeatherCard.tsx`](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/WeatherCard.tsx) (Farmer information widgets), [`src/routeTree.gen.ts`](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routeTree.gen.ts) (Generated route tree)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_startup{{"Server startup<br/>TypeScript entrypoint<br/>[start.ts]"}}
  node_server["Application server<br/>Server runtime<br/>[server.ts]"]
  node_router["Route registry<br/>TanStack router<br/>[router.tsx]"]
  node_route_tree["Generated route tree<br/>Generated routes<br/>[routeTree.gen.ts]"]
end

subgraph group_portal["Farmer Portal"]
  node_root_routes["Shared and public routes<br/>React routes<br/>[__root.tsx]"]
  node_dashboard_routes["Dashboard routes<br/>Protected portal routes<br/>[dashboard.tsx]"]
  node_farmer_widgets["Farmer information widgets<br/>React feature components<br/>[WeatherCard.tsx]"]
  node_location["Location context<br/>Location state<br/>[location.tsx]"]
  node_localization["Localization state<br/>i18n state<br/>[i18n.tsx]"]
  node_data_adapters["Farm data adapters<br/>Server functions"]
end

subgraph group_advisory["Advisory Services"]
  node_ai_ui["AI and chat UI<br/>React advisory components<br/>[AskAI.tsx]"]
  node_ai_functions["AI service functions<br/>Server functions<br/>[ai.functions.ts]"]
  node_conversation_voice["Conversation and voice functions<br/>Server functions<br/>[chat.functions.ts]"]
end

subgraph group_backend["Backend Integration"]
  node_supabase_clients[("Supabase clients<br/>Browser/server clients<br/>[client.ts]")]
  node_auth_boundary["Auth propagation<br/>Auth middleware<br/>[auth-middleware.ts]"]
  node_database_schema[("Database schema migrations<br/>Supabase migrations")]
end

subgraph group_operations["Administration &amp; Reporting"]
  node_admin_routes["Admin access routes<br/>Admin routes<br/>[admin.tsx]"]
  node_admin_operations["Admin resource operations<br/>Admin functions and UI<br/>[admin.functions.ts]"]
  node_reporting["User reporting flow<br/>Report UI"]
end

node_startup -->|"boots"| node_server
node_server -->|"serves"| node_router
node_router -->|"uses"| node_route_tree
node_route_tree -->|"includes"| node_root_routes
node_route_tree -->|"includes"| node_dashboard_routes
node_dashboard_routes -->|"composes"| node_farmer_widgets
node_farmer_widgets -->|"uses location"| node_location
node_farmer_widgets -->|"uses translations"| node_localization
node_farmer_widgets -->|"loads data from"| node_data_adapters
node_ai_ui -->|"requests AI"| node_ai_functions
node_ai_ui -->|"uses chat and voice"| node_conversation_voice
node_dashboard_routes -->|"exposes"| node_ai_ui
node_data_adapters -->|"accesses backend"| node_supabase_clients
node_ai_functions -->|"uses backend"| node_supabase_clients
node_auth_boundary -->|"configures sessions"| node_supabase_clients
node_supabase_clients -->|"persists to"| node_database_schema
node_admin_routes -->|"requires"| node_auth_boundary
node_admin_routes -->|"opens"| node_admin_operations
node_admin_operations -->|"manages resources through"| node_supabase_clients
node_dashboard_routes -->|"offers"| node_reporting
node_reporting -->|"submits through"| node_supabase_clients

click node_startup "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/start.ts"
click node_server "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/server.ts"
click node_router "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/router.tsx"
click node_route_tree "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routeTree.gen.ts"
click node_root_routes "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/__root.tsx"
click node_dashboard_routes "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/dashboard.tsx"
click node_farmer_widgets "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/WeatherCard.tsx"
click node_location "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/location.tsx"
click node_localization "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/i18n.tsx"
click node_data_adapters "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/weather.functions.ts"
click node_ai_ui "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/AskAI.tsx"
click node_ai_functions "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/ai.functions.ts"
click node_conversation_voice "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/chat.functions.ts"
click node_supabase_clients "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/integrations/supabase/client.ts"
click node_auth_boundary "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/integrations/supabase/auth-middleware.ts"
click node_admin_routes "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/admin.tsx"
click node_admin_operations "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/admin.functions.ts"
click node_reporting "https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/FloatingReportButton.tsx"

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_startup,node_server,node_router,node_route_tree toneBlue
class node_root_routes,node_dashboard_routes,node_farmer_widgets,node_location,node_localization,node_data_adapters toneAmber
class node_ai_ui,node_ai_functions,node_conversation_voice toneMint
class node_supabase_clients,node_auth_boundary,node_database_schema toneRose
class node_admin_routes,node_admin_operations,node_reporting toneIndigo
```

## Components

### Application Runtime

- [Server startup](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/start.ts): TypeScript entrypoint · Bootstraps the server-capable application. · `src/start.ts`
- [Application server](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/server.ts): Server runtime · `src/server.ts`
- [Route registry](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/router.tsx): TanStack router · Connects generated file routes to the application. · `src/router.tsx`
- [Generated route tree](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routeTree.gen.ts): Generated routes · `src/routeTree.gen.ts`

### Farmer Portal

- [Shared and public routes](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/__root.tsx): React routes · Root layout and public landing page. · `src/routes/__root.tsx`
- [Dashboard routes](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/dashboard.tsx): Protected portal routes · Dashboard and dashboard child views. · `src/routes/dashboard.tsx`
- [Farmer information widgets](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/WeatherCard.tsx): React feature components · Weather, groundwater, prices, marketplace, schemes, and eligibility views. · `src/components/WeatherCard.tsx`
- [Location context](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/location.tsx): Location state · Cross-cutting location input for farmer content. · `src/lib/location.tsx`
- [Localization state](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/i18n.tsx): i18n state · `src/lib/i18n.tsx`
- [Farm data adapters](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/weather.functions.ts): Server functions · Weather, mandi, and farm-data access for presentation. · `src/lib/weather.functions.ts`

### Advisory Services

- [AI and chat UI](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/AskAI.tsx): React advisory components · Ask AI and chatbot presentation experiences. · `src/components/AskAI.tsx`
- [AI service functions](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/ai.functions.ts): Server functions · Keeps remote or credentialed AI operations outside UI components. · `src/lib/ai.functions.ts`
- [Conversation and voice functions](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/chat.functions.ts): Server functions · `src/lib/chat.functions.ts`

### Backend Integration

- [Supabase clients](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/integrations/supabase/client.ts): Browser/server clients · Separate browser and server backend clients. · `src/integrations/supabase/client.ts`
- [Auth propagation](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/integrations/supabase/auth-middleware.ts): Auth middleware · Attaches and propagates Supabase authentication. · `src/integrations/supabase/auth-middleware.ts`
- **Database schema migrations**: Supabase migrations

### Administration & Reporting

- [Admin access routes](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/routes/admin.tsx): Admin routes · Separate login and administrative navigation boundary. · `src/routes/admin.tsx`
- [Admin resource operations](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/lib/admin.functions.ts): Admin functions and UI · Resource management for authorized administrators. · `src/lib/admin.functions.ts`
- [User reporting flow](https://github.com/sirithreddy175-boop/telangana-rytu-seva/blob/main/src/components/FloatingReportButton.tsx): Report UI · Floating report entry and report submission form. · `src/components/FloatingReportButton.tsx`

## Connections

- Server startup → Application server: boots
- Application server → Route registry: serves
- Route registry → Generated route tree: uses
- Generated route tree → Shared and public routes: includes
- Generated route tree → Dashboard routes: includes
- Dashboard routes → Farmer information widgets: composes
- Farmer information widgets → Location context: uses location
- Farmer information widgets → Localization state: uses translations
- Farmer information widgets → Farm data adapters: loads data from
- AI and chat UI → AI service functions: requests AI
- AI and chat UI → Conversation and voice functions: uses chat and voice
- Dashboard routes → AI and chat UI: exposes
- Farm data adapters → Supabase clients: accesses backend
- AI service functions → Supabase clients: uses backend
- Auth propagation → Supabase clients: configures sessions
- Supabase clients → Database schema migrations: persists to
- Admin access routes → Auth propagation: requires
- Admin access routes → Admin resource operations: opens
- Admin resource operations → Supabase clients: manages resources through
- Dashboard routes → User reporting flow: offers
- User reporting flow → Supabase clients: submits through
