How kamayu2/weather-gpt works
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: main.tsx Client bootstrap · auth.ts Auth infrastructure · RequireAuth.tsx Protected-route guard · DashboardHome.tsx Dashboard home
Components 17
React SPA
Vite-built client application.
- Client bootstrap · Configures routing, Convex, providers, and redirects.
src/main.tsx - Instrumentation
src/instrumentation.tsx - Theme and UI system · Theme hook, tokens, toasts, and shared UI primitives.
src/index.css - Auth client hook · Only frontend access point for authentication state.
src/hooks/use-auth.ts
Product surfaces
- Landing experience · Animated acquisition surface with hero and live demo.
src/pages/Landing.tsx - Authentication screen
src/pages/Auth.tsx - Protected-route guard · Redirects unauthenticated users to /auth with returnTo.
src/components/RequireAuth.tsx - Dashboard · Composes weather intelligence and conversational interaction.
src/pages/Dashboard.tsx - Dashboard home
src/components/dashboard/DashboardHome.tsx - Weather intelligence UI · Cards, charts, alerts, and agricultural advisories.
src/components/weather/WeatherCard.tsx - Conversation UI · Typed/voice input, suggestions, messages, and pending state.
src/components/chat/ChatInput.tsx - Not found
src/pages/NotFound.tsx
Convex backend
Auth, data, and server operations.
- HTTP entry
src/convex/http.ts - Auth infrastructure · Email OTP and anonymous identity configuration.
src/convex/auth.ts - Identity and users · Resolves backend identity and user records.
src/convex/users.ts - Weather service · Authorized weather reads, writes, and orchestration.
src/convex/weather.ts - Chat service · Conversation persistence and server-side operations.
src/convex/chat.ts
Connections 19
- 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