# kamayu2/weather-gpt architecture

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

- Interactive diagram: https://gitdiagram.com/kamayu2/weather-gpt
- Repository: https://github.com/kamayu2/weather-gpt

## Overview

#### Purpose and Runtime
This is a Vite-built React 19 single-page application for an agriculture/weather-oriented product. It combines a public marketing experience, authenticated dashboard, weather visualizations/advisories, and a conversational interface. The frontend is TypeScript, React Router v7, Tailwind v4, Shadcn UI, Framer Motion, and optional Three.js; Bun is the intended package manager. Backend data, auth, and server functions run on Convex.

Entry points: `src/main.tsx`, `src/instrumentation.tsx`, `src/convex/http.ts`.

#### Application Shell and Routing
`src/main.tsx` owns client bootstrap, Convex client integration, route configuration, theme/toast-level providers, and auth redirect behavior. Its primary route partitions are public landing/auth screens and protected product screens:
- Public: `src/pages/Landing.tsx`, `src/pages/Auth.tsx`
- Protected dashboard: `src/pages/Dashboard.tsx`, guarded by `src/components/RequireAuth.tsx`
- Fallback: `src/pages/NotFound.tsx`

Unauthenticated access to protected routes redirects to `/auth` with a same-origin `returnTo`; successful auth normally lands at `/dashboard`.

#### Identity and Authorization Boundary
Convex Auth is the source of identity. Frontend code consumes auth only through `src/hooks/use-auth.ts`; route-level enforcement is in `src/components/RequireAuth.tsx`. Backend identity/user lookup belongs in `src/convex/users.ts`.

Auth configuration and the email-OTP/anonymous-user mechanisms are isolated and treated as infrastructure:
- `src/convex/auth.ts`
- `src/convex/auth.config.ts`
- `src/convex/auth/emailOtp.ts`

Convex server secrets include JWKS, JWT private key, and site URL; client connectivity uses `CONVEX_DEPLOYMENT` and `VITE_CONVEX_URL`.

#### Product Surfaces
The landing experience is a composed, animated acquisition surface, with hero/demo/technology sections:
- `src/pages/Landing.tsx`
- `src/components/landing/AnimatedHero.tsx`
- `src/components/landing/LiveDemo.tsx`

The authenticated dashboard is the central application surface:
- `src/pages/Dashboard.tsx`
- `src/components/dashboard/DashboardHome.tsx`
- `src/components/LogoDropdown.tsx`

Dashboard composition brings together weather intelligence and chat, rather than exposing standalone service pages.

#### Weather Intelligence Flow
Weather-related UI renders cards, historical/comparative charts, thermal mapping, alerts, and agriculture-oriented advice:
- `src/components/weather/WeatherCard.tsx`
- `src/components/weather/WeatherChart.tsx`
- `src/components/weather/AgriAdvisory.tsx`

The corresponding Convex service boundary is `src/convex/weather.ts`. It should own authorized backend reads/writes and any orchestration needed for weather data. If external providers are introduced, outbound calls must be placed in Node-enabled Convex actions, separated from queries and mutations.

#### Conversational Interaction Flow
The chat UI collects typed or voice input, presents suggestions and messages, and exposes pending/typing state:
- `src/components/chat/ChatInput.tsx`
- `src/components/chat/VoiceInput.tsx`
- `src/components/chat/ChatMessage.tsx`

`src/convex/chat.ts` is the backend boundary for conversation persistence and server-side chat operations. The intended control flow is authenticated dashboard → input interaction → Convex mutation/action → persisted or returned response → reactive Convex-driven message rendering.

#### Shared Presentation and Delivery
Styling/theme tokens originate in `src/index.css`; shared visual primitives are maintained under `src/components/ui/`, with app-wide dark/light behavior in `src/hooks/use-theme.ts`. Framer Motion supports animated product and marketing components.

Deployment metadata is Convex-centered (`convex.json`), while Vite serves/builds the SPA (`vite.config.ts`). `isolate/` is a prebuilt/static artifact bundle, not the primary source architecture; active implementation lives under `src/`.

Main entry points: [`src/main.tsx`](https://github.com/kamayu2/weather-gpt/blob/main/src/main.tsx) (Client bootstrap), [`src/convex/auth.ts`](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/auth.ts) (Auth infrastructure), [`src/components/RequireAuth.tsx`](https://github.com/kamayu2/weather-gpt/blob/main/src/components/RequireAuth.tsx) (Protected-route guard), [`src/components/dashboard/DashboardHome.tsx`](https://github.com/kamayu2/weather-gpt/blob/main/src/components/dashboard/DashboardHome.tsx) (Dashboard home)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React SPA"]
  node_main{{"Client bootstrap<br/>React entry<br/>[main.tsx]"}}
  node_instrumentation["Instrumentation<br/>client telemetry"]
  node_theme["Theme and UI system<br/>presentation<br/>[index.css]"]
  node_auth_hook["Auth client hook<br/>auth adapter<br/>[use-auth.ts]"]
end

subgraph group_product["Product surfaces"]
  node_landing["Landing experience<br/>public page<br/>[Landing.tsx]"]
  node_auth_page["Authentication screen<br/>public page<br/>[Auth.tsx]"]
  node_require_auth["Protected-route guard<br/>[RequireAuth.tsx]"]
  node_dashboard["Dashboard<br/>protected page<br/>[Dashboard.tsx]"]
  node_dashboard_home["Dashboard home<br/>dashboard composition<br/>[DashboardHome.tsx]"]
  node_weather_ui["Weather intelligence UI<br/>weather presentation<br/>[WeatherCard.tsx]"]
  node_chat_ui["Conversation UI<br/>chat presentation<br/>[ChatInput.tsx]"]
  node_not_found["Not found<br/>fallback page<br/>[NotFound.tsx]"]
end

subgraph group_convex["Convex backend"]
  node_convex_http{{"HTTP entry<br/>Convex HTTP<br/>[http.ts]"}}
  node_convex_auth["Auth infrastructure<br/>Convex Auth<br/>[auth.ts]"]
  node_users[("Identity and users<br/>Convex service<br/>[users.ts]")]
  node_weather_service[("Weather service<br/>Convex service<br/>[weather.ts]")]
  node_chat_service[("Chat service<br/>Convex service<br/>[chat.ts]")]
end

node_main -->|"initializes"| node_instrumentation
node_main -->|"provides"| node_theme
node_main -->|"public route"| node_landing
node_main -->|"public route"| node_auth_page
node_main -->|"protects dashboard route"| node_require_auth
node_main -->|"fallback route"| node_not_found
node_require_auth -->|"checks session"| node_auth_hook
node_require_auth -->|"authorized access"| node_dashboard
node_dashboard -->|"renders"| node_dashboard_home
node_dashboard_home -->|"composes"| node_weather_ui
node_dashboard_home -->|"composes"| node_chat_ui
node_main -->|"uses Convex auth"| node_convex_auth
node_auth_hook -->|"consumes identity"| node_convex_auth
node_convex_auth -->|"establishes identity"| node_users
node_weather_ui -->|"reactive weather data"| node_weather_service
node_weather_service -->|"authorizes requests"| node_users
node_chat_ui -->|"mutations and responses"| node_chat_service
node_chat_service -->|"authorizes conversations"| node_users
node_convex_http -.->|"HTTP auth boundary"| node_convex_auth

click node_main "https://github.com/kamayu2/weather-gpt/blob/main/src/main.tsx"
click node_instrumentation "https://github.com/kamayu2/weather-gpt/blob/main/src/instrumentation.tsx"
click node_theme "https://github.com/kamayu2/weather-gpt/blob/main/src/index.css"
click node_auth_hook "https://github.com/kamayu2/weather-gpt/blob/main/src/hooks/use-auth.ts"
click node_landing "https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Landing.tsx"
click node_auth_page "https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Auth.tsx"
click node_require_auth "https://github.com/kamayu2/weather-gpt/blob/main/src/components/RequireAuth.tsx"
click node_dashboard "https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Dashboard.tsx"
click node_dashboard_home "https://github.com/kamayu2/weather-gpt/blob/main/src/components/dashboard/DashboardHome.tsx"
click node_weather_ui "https://github.com/kamayu2/weather-gpt/blob/main/src/components/weather/WeatherCard.tsx"
click node_chat_ui "https://github.com/kamayu2/weather-gpt/blob/main/src/components/chat/ChatInput.tsx"
click node_not_found "https://github.com/kamayu2/weather-gpt/blob/main/src/pages/NotFound.tsx"
click node_convex_http "https://github.com/kamayu2/weather-gpt/blob/main/src/convex/http.ts"
click node_convex_auth "https://github.com/kamayu2/weather-gpt/blob/main/src/convex/auth.ts"
click node_users "https://github.com/kamayu2/weather-gpt/blob/main/src/convex/users.ts"
click node_weather_service "https://github.com/kamayu2/weather-gpt/blob/main/src/convex/weather.ts"
click node_chat_service "https://github.com/kamayu2/weather-gpt/blob/main/src/convex/chat.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_main,node_instrumentation,node_theme,node_auth_hook toneBlue
class node_landing,node_auth_page,node_require_auth,node_dashboard,node_dashboard_home,node_weather_ui,node_chat_ui,node_not_found toneAmber
class node_convex_http,node_convex_auth,node_users,node_weather_service,node_chat_service toneMint
```

## Components

### React SPA

Vite-built client application.

- [Client bootstrap](https://github.com/kamayu2/weather-gpt/blob/main/src/main.tsx): React entry · Configures routing, Convex, providers, and redirects. · `src/main.tsx`
- [Instrumentation](https://github.com/kamayu2/weather-gpt/blob/main/src/instrumentation.tsx): client telemetry · `src/instrumentation.tsx`
- [Theme and UI system](https://github.com/kamayu2/weather-gpt/blob/main/src/index.css): presentation · Theme hook, tokens, toasts, and shared UI primitives. · `src/index.css`
- [Auth client hook](https://github.com/kamayu2/weather-gpt/blob/main/src/hooks/use-auth.ts): auth adapter · Only frontend access point for authentication state. · `src/hooks/use-auth.ts`

### Product surfaces

- [Landing experience](https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Landing.tsx): public page · Animated acquisition surface with hero and live demo. · `src/pages/Landing.tsx`
- [Authentication screen](https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Auth.tsx): public page · `src/pages/Auth.tsx`
- [Protected-route guard](https://github.com/kamayu2/weather-gpt/blob/main/src/components/RequireAuth.tsx): route guard · Redirects unauthenticated users to /auth with returnTo. · `src/components/RequireAuth.tsx`
- [Dashboard](https://github.com/kamayu2/weather-gpt/blob/main/src/pages/Dashboard.tsx): protected page · Composes weather intelligence and conversational interaction. · `src/pages/Dashboard.tsx`
- [Dashboard home](https://github.com/kamayu2/weather-gpt/blob/main/src/components/dashboard/DashboardHome.tsx): dashboard composition · `src/components/dashboard/DashboardHome.tsx`
- [Weather intelligence UI](https://github.com/kamayu2/weather-gpt/blob/main/src/components/weather/WeatherCard.tsx): weather presentation · Cards, charts, alerts, and agricultural advisories. · `src/components/weather/WeatherCard.tsx`
- [Conversation UI](https://github.com/kamayu2/weather-gpt/blob/main/src/components/chat/ChatInput.tsx): chat presentation · Typed/voice input, suggestions, messages, and pending state. · `src/components/chat/ChatInput.tsx`
- [Not found](https://github.com/kamayu2/weather-gpt/blob/main/src/pages/NotFound.tsx): fallback page · `src/pages/NotFound.tsx`

### Convex backend

Auth, data, and server operations.

- [HTTP entry](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/http.ts): Convex HTTP · `src/convex/http.ts`
- [Auth infrastructure](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/auth.ts): Convex Auth · Email OTP and anonymous identity configuration. · `src/convex/auth.ts`
- [Identity and users](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/users.ts): Convex service · Resolves backend identity and user records. · `src/convex/users.ts`
- [Weather service](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/weather.ts): Convex service · Authorized weather reads, writes, and orchestration. · `src/convex/weather.ts`
- [Chat service](https://github.com/kamayu2/weather-gpt/blob/main/src/convex/chat.ts): Convex service · Conversation persistence and server-side operations. · `src/convex/chat.ts`

## Connections

- Client bootstrap → Instrumentation: initializes
- Client bootstrap → Theme and UI system: provides
- Client bootstrap → Landing experience: public route
- Client bootstrap → Authentication screen: public route
- Client bootstrap → Protected-route guard: protects dashboard route
- Client bootstrap → Not found: fallback route
- Protected-route guard → Auth client hook: checks session
- Protected-route guard → Dashboard: authorized access
- Dashboard → Dashboard home: renders
- Dashboard home → Weather intelligence UI: composes
- Dashboard home → Conversation UI: composes
- Client bootstrap → Auth infrastructure: uses Convex auth
- Auth client hook → Auth infrastructure: consumes identity
- Auth infrastructure → Identity and users: establishes identity
- Weather intelligence UI → Weather service: reactive weather data
- Weather service → Identity and users: authorizes requests
- Conversation UI → Chat service: mutations and responses
- Chat service → Identity and users: authorizes conversations
- HTTP entry → Auth infrastructure: HTTP auth boundary
