# kavitapuvinaykumar/studio architecture

> Architecture diagram of the GitHub repository kavitapuvinaykumar/studio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kavitapuvinaykumar/studio
- Repository: https://github.com/kavitapuvinaykumar/studio

## Overview

##### Project type and purpose
- This is a full-stack, server-less Next.js web application (“WeatherWise”) acting as a personal, AI-powered weather assistant.
- Key flows: user authentication, weather search & display, search history persistence, AI recommendation generation.

##### File structure
- Top-level configs: .env, next.config.ts, tailwind.config.ts, vercel.json, firebase rules.
- src/app: Next.js App Router (layout.tsx, pages for login, signup, dashboard).
- src/components: UI primitives & ShadCN components (accordion, button, chart, etc.).
- src/firebase: Firebase SDK wrappers (auth, Firestore hooks, error handling).
- src/ai: server-side AI flows (Genkit integration, personalized-weather-recommendations.ts).
- src/hooks & src/lib: custom React hooks and utility modules.

##### README for additional insights
- Auth via Firebase Auth → new user doc in Firestore
- Weather & geocoding via Open-Meteo API + ipapi.co
- Search history in Firestore subcollection
- AI recommendations via Genkit + Google AI (Gemini)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Web Browser"]:::frontend
    subgraph "Next.js Application (Vercel Serverless)"
        subgraph "Client Components"
            UI["React UI Components"]:::frontend
        end
        subgraph "Server Components"
            SSR["Next.js Server Components"]:::backend
        end
    end

    %% Firebase BaaS
    subgraph "Firebase (BaaS)"
        Auth["Authentication Service"]:::firebase
        DB["Firestore Database"]:::firebase
    end

    %% External APIs
    OpenMeteo["Open-Meteo API"]:::external
    IPAPI["ipapi.co"]:::external

    %% AI Pipeline
    subgraph "AI Pipeline"
        Genkit["Genkit Middleware"]:::ai
        Gemini["Google AI (Gemini)"]:::ai
    end

    %% Data Flows
    Browser -->|"Interacts"| UI
    UI -->|"Auth SDK calls"| Auth
    Auth -->|"Returns ID Token"| UI
    UI -->|"Writes search → Firestore"| DB
    UI -->|"Reads last 10 searches"| DB
    SSR -->|"Fetch geocode"| IPAPI
    SSR -->|"Fetch weather"| OpenMeteo
    OpenMeteo -->|"Weather data"| SSR
    IPAPI -->|"Location data"| SSR
    SSR -->|"Return weather data"| UI
    SSR -->|"Invoke AI flow"| Genkit
    Genkit -->|"Request prompt"| Gemini
    Gemini -->|"Recommendations"| Genkit
    Genkit -->|"Return recommendations"| SSR
    SSR -->|"Return AI recommendations"| UI

    %% Click Events - Next.js App Router
    click layout "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/layout.tsx"
    click page "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/page.tsx"
    click loginPage "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/login/page.tsx"
    click signupPage "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/signup/page.tsx"
    click actions "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/actions.ts"
    click authActions "https://github.com/kavitapuvinaykumar/studio/blob/main/src/app/auth-actions.ts"

    %% Click Events - UI Components
    click UI "https://github.com/kavitapuvinaykumar/studio/tree/main/src/components/ui"
    click weatherIcon "https://github.com/kavitapuvinaykumar/studio/blob/main/src/components/weather-icon.tsx"
    click loadingSkeleton "https://github.com/kavitapuvinaykumar/studio/blob/main/src/components/loading-skeleton.tsx"
    click errorListener "https://github.com/kavitapuvinaykumar/studio/blob/main/src/components/FirebaseErrorListener.tsx"

    %% Click Events - Firebase Auth
    click config "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/config.ts"
    click clientProvider "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/client-provider.tsx"
    click provider "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/provider.tsx"
    click nonBlocking "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/non-blocking-login.tsx"
    click errorEmitter "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/error-emitter.ts"
    click firebaseIndex "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/index.ts"

    %% Click Events - Firestore Data Access
    click useCollection "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/firestore/use-collection.tsx"
    click useDoc "https://github.com/kavitapuvinaykumar/studio/blob/main/src/firebase/firestore/use-doc.tsx"

    %% Click Events - AI Service
    click genkit "https://github.com/kavitapuvinaykumar/studio/blob/main/src/ai/genkit.ts"
    click recommendations "https://github.com/kavitapuvinaykumar/studio/blob/main/src/ai/flows/personalized-weather-recommendations.ts"
    click aiDev "https://github.com/kavitapuvinaykumar/studio/blob/main/src/ai/dev.ts"

    %% Click Events - External Wrappers
    click utilsLib "https://github.com/kavitapuvinaykumar/studio/blob/main/src/lib/utils.ts"
    click typesLib "https://github.com/kavitapuvinaykumar/studio/blob/main/src/lib/types.ts"

    %% Click Events - Client-side Hooks
    click useMobile "https://github.com/kavitapuvinaykumar/studio/blob/main/src/hooks/use-mobile.tsx"
    click useToast "https://github.com/kavitapuvinaykumar/studio/blob/main/src/hooks/use-toast.tsx"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef ai fill:#e2e3f3,stroke:#6f42c1,color:#6f42c1
    classDef firebase fill:#d1ecf1,stroke:#0c5460,color:#0c5460
```
