# harshshirke66/project-kisan architecture

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

- Interactive diagram: https://gitdiagram.com/harshshirke66/project-kisan
- Repository: https://github.com/harshshirke66/project-kisan

## Overview

##### Project Type & Purpose
- This is a **frontend-heavy React/TypeScript SPA** (built with Vite) that interfaces with:
- Supabase (Auth & PostgreSQL)
- AI engine (Gemini)
- External data APIs (OpenWeatherMap, IQAir, WAQI)
- Data-viz libs (Chart.js, Leaflet)

##### Main Components
- **UI Layer** (src/components)
- LandingPage, Dashboard, Alerts, CropDiagnosis, etc.
- MainApp wraps all feature-specific modules
- **Service Layer** (src/services + src/config)
- geminiService → AI chatbot/analytics
- Supabase client → auth & data storage
- **Hooks & Utils**
- useSpeechRecognition (voice control)
- textFormatter
- **External Systems**
- Supabase (Auth + Postgres)
- OpenWeatherMap, IQAir, WAQI
- Gemini AI

##### Relationships & Data Flows
- **User → UI Layer**: interactions (clicks, voice commands)
- **UI → Service Layer**: fetch/send requests
- Auth calls → Supabase Auth
- Data queries → Supabase DB
- AI prompts → Gemini API
- Weather/Market data → respective APIs
- **Responses → UI**: update charts, alerts, maps

##### Architectural Highlights
- **Single-Page App** with clear separation of concerns
- **Service abstraction**: all external calls live in `src/services`
- **Composable components**: each feature is a self-contained React component
- **Hook-based extensions**: re-usable behavior (speech recognition)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        LP["LandingPage"]:::ui
        DBP["Dashboard"]:::ui
        AL["Alerts"]:::ui
        CD["CropDiagnosis"]:::ui
        MR["MarketAnalysis"]:::ui
        WF["WeatherForecast"]:::ui
        QA["QuickActions"]:::ui
        VC["VoiceControl"]:::ui
        MA["MainApp"]:::ui
        AP["App Entry (App.tsx)"]:::ui
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        SS["supabaseClient"]:::service
        GS["geminiService"]:::service
        GC["Gemini Config"]:::service
    end

    %% External Systems
    subgraph "External & Backends"
        direction TB
        SA["Supabase Auth"]:::external
        SDB[(Supabase DB)]:::database
        OW["OpenWeatherMap"]:::external
        IQ["IQAir API"]:::external
        WA["WAQI API"]:::external
        AI["Gemini AI"]:::external
    end

    %% Hooks & Utils
    subgraph "Hooks & Utils"
        direction TB
        SR["useSpeechRecognition"]:::util
        TF["textFormatter"]:::util
    end

    %% Connections
    LP -->|"renders"| MA
    DBP -->|"renders"| MA
    AL -->|"renders"| MA
    CD -->|"renders"| MA
    MR -->|"renders"| MA
    WF -->|"renders"| MA
    QA -->|"renders"| MA
    VC -->|"binds"| SR
    MA -->|"calls"| SS
    MA -->|"calls"| GS
    SS -->|"auth/db queries"| SA
    SS -->|"auth/db queries"| SDB
    GS -->|"AI prompts"| AI
    SS -->|"fetch weather"| OW
    SS -->|"fetch air data"| IQ
    SS -->|"fetch air data"| WA
    SR -.->|"voice events"| MA
    TF -.->|"format text"| MA

    %% Click Events
    click LP "https://github.com/harshshirke66/project-kisan/blob/main/src/components/LandingPage.tsx"
    click DBP "https://github.com/harshshirke66/project-kisan/blob/main/src/components/dashboard/Dashboard.tsx"
    click AL "https://github.com/harshshirke66/project-kisan/blob/main/src/components/AlertsSection.tsx"
    click CD "https://github.com/harshshirke66/project-kisan/blob/main/src/components/CropDiagnosis.tsx"
    click MR "https://github.com/harshshirke66/project-kisan/blob/main/src/components/MarketAnalysis.tsx"
    click WF "https://github.com/harshshirke66/project-kisan/blob/main/src/components/WeatherForecast.tsx"
    click QA "https://github.com/harshshirke66/project-kisan/blob/main/src/components/QuickActions.tsx"
    click VC "https://github.com/harshshirke66/project-kisan/blob/main/src/components/VoiceControl.tsx"
    click MA "https://github.com/harshshirke66/project-kisan/blob/main/src/components/MainApp.tsx"
    click AP "https://github.com/harshshirke66/project-kisan/blob/main/src/App.tsx"
    click GS "https://github.com/harshshirke66/project-kisan/blob/main/src/services/geminiService.ts"
    click SS "https://github.com/harshshirke66/project-kisan/blob/main/src/config/supabase.ts"
    click GC "https://github.com/harshshirke66/project-kisan/blob/main/src/config/gemini.ts"
    click SR "https://github.com/harshshirke66/project-kisan/blob/main/src/hooks/useSpeechRecognition.ts"
    click TF "https://github.com/harshshirke66/project-kisan/blob/main/src/utils/textFormatter.ts"

    %% Styles
    classDef ui fill:#e0ffe0,stroke:#008000,color:#006600;
    classDef service fill:#e0f0ff,stroke:#0066cc,color:#003366;
    classDef database fill:#f0e0ff,stroke:#800080,color:#4b0082;
    classDef external fill:#fff3e0,stroke:#cc8400,color:#994c00;
    classDef util fill:#f0f0f0,stroke:#999999,color:#333333;
```
