# shekhawat-ajay/drizzle-weather-app architecture

> Architecture diagram of the GitHub repository shekhawat-ajay/drizzle-weather-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shekhawat-ajay/drizzle-weather-app
- Repository: https://github.com/shekhawat-ajay/drizzle-weather-app

## Overview

##### Project Type & Purpose
- This is a client-side, single-page React application for checking weather/AQI.
- No custom backend—data comes from third-party weather/AQI APIs.

##### File Structure
- Top level: package.json, Vite config, public/index.html.
- src/
- components/ – presentational React components (Header, SearchBox, CurrentWeather, TodayWeather, WeeklyForecast, AirQuality, Footer)
- hooks/ – custom data-fetching hooks (useLocation, useCurrentWeather, useTodayWeather, useWeeklyForecast, useAQI) using Axios + useSWR
- utils/ – pure functions and mapping tables (weatherImageMap, uvIndexImageMap, aqiMap, getWindDirection, cn)
- Configuration: vite.config.js, eslint.config.js, .prettierrc

##### README for Stack & Flow
- React.js for UI, Tailwind/DaisyUI for styling
- Axios + useSWR for HTTP requests & caching
- Vite for local dev server & build

##### Main Components & Interactions
a. Browser (Client)
b. React App (SPA)
– UI Layer (components/)
– Data Layer (hooks/)
– Utilities (utils/)
c. External Services
– Weather API (current + forecast)
– AQI API
d. Build & Deployment
– Vite Dev Server / Vite Production Bundle

##### Data Flow & Relationships
1. User enters a city in SearchBox → triggers useLocation or search logic
2. Hooks (useCurrentWeather, useTodayWeather, useWeeklyForecast, useAQI) call Axios → external APIs
3. Responses pass through utils (mapping functions) → components render UI
4. useSWR manages caching and revalidation in the background

##### Architectural Patterns & Principles
- Component-based UI (separation of concerns)
- Custom hooks abstract data fetching + caching
- Utility modules keep transformation logic pure
- Unidirectional data flow (props & hooks → components)

##### Technologies & Frameworks
- React.js (JSX components)
- Tailwind CSS + DaisyUI (styling)
- Axios + useSWR (data fetching & caching)
- Vite (dev server & bundler)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Entry & Core
    subgraph "Application Entry & Core"
        HTML["public/index.html"]:::build
        Main["src/main.jsx"]:::build
        App["src/App.jsx"]:::build
    end

    %% UI Layer
    subgraph "UI Layer"
        Header["Header"]:::ui
        SearchBox["SearchBox"]:::ui
        CurrentWeather["CurrentWeather"]:::ui
        TodayWeather["TodayWeather"]:::ui
        WeeklyForecast["WeeklyForecast"]:::ui
        AirQuality["AirQuality"]:::ui
        Footer["Footer"]:::ui
    end

    %% Data Layer
    subgraph "Data Layer"
        useLocation["useLocation"]:::data
        useCurrentWeather["useCurrentWeather"]:::data
        useTodayWeather["useTodayWeather"]:::data
        useWeeklyForecast["useWeeklyForecast"]:::data
        useAQI["useAQI"]:::data
    end

    %% Utilities
    subgraph "Utilities"
        weatherImageMap["weatherImageMap"]:::utils
        uvIndexImageMap["uvIndexImageMap"]:::utils
        aqiMap["aqiMap"]:::utils
        getWindDirection["getWindDirection"]:::utils
        cn["cn"]:::utils
    end

    %% External Services
    subgraph "External Services"
        WeatherAPI[("Weather API")]:::external
        AQIAPI[("AQI API")]:::external
    end

    %% Build & Deploy
    subgraph "Build & Deploy"
        Package["package.json"]:::build
        ViteConfig["vite.config.js"]:::build
        ESLint["eslint.config.js/.prettierrc"]:::build
        ViteServer["Vite Dev Server / Build"]:::build
    end

    %% Connections - Entry
    HTML -->|"loads"| Main
    Main -->|"initializes"| App

    %% Connections - UI to Hooks
    App -->|"renders"| Header
    App -->|"renders"| SearchBox
    App -->|"renders"| CurrentWeather
    App -->|"renders"| TodayWeather
    App -->|"renders"| WeeklyForecast
    App -->|"renders"| AirQuality
    App -->|"renders"| Footer

    SearchBox -->|"triggers"| useLocation
    CurrentWeather -->|"uses"| useCurrentWeather
    TodayWeather -->|"uses"| useTodayWeather
    WeeklyForecast -->|"uses"| useWeeklyForecast
    AirQuality -->|"uses"| useAQI

    %% Connections - Hooks to External APIs
    useCurrentWeather -->|"GET data"| WeatherAPI
    useTodayWeather -->|"GET data"| WeatherAPI
    useWeeklyForecast -->|"GET data"| WeatherAPI
    useAQI -->|"GET data"| AQIAPI

    WeatherAPI -->|"JSON response"| useCurrentWeather
    WeatherAPI -->|"JSON response"| useTodayWeather
    WeatherAPI -->|"JSON response"| useWeeklyForecast
    AQIAPI -->|"JSON response"| useAQI

    %% Connections - Hooks to Utilities to UI
    useCurrentWeather -->|"process"| weatherImageMap
    useCurrentWeather -->|"process"| getWindDirection
    useTodayWeather -->|"process"| uvIndexImageMap
    useWeeklyForecast -->|"process"| weatherImageMap
    useAQI -->|"process"| aqiMap
    weatherImageMap -->|"mapped data"| CurrentWeather
    getWindDirection -->|"mapped data"| CurrentWeather
    uvIndexImageMap -->|"mapped data"| TodayWeather
    weatherImageMap -->|"mapped data"| WeeklyForecast
    aqiMap -->|"mapped data"| AirQuality

    %% Connections - Build Pipeline
    Package --> ViteServer
    ViteConfig --> ViteServer
    ESLint --> ViteServer
    ViteServer -->|"serves Dev"| Main
    ViteServer -->|"bundles Prod"| App

    %% Click Events - Application Entry & Core
    click HTML "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/public/index.html"
    click Main "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/main.jsx"
    click App "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/App.jsx"

    %% Click Events - UI Layer
    click Header "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/Header.jsx"
    click SearchBox "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/SearchBox.jsx"
    click CurrentWeather "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/CurrentWeather.jsx"
    click TodayWeather "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/TodayWeather.jsx"
    click WeeklyForecast "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/WeeklyForecast.jsx"
    click AirQuality "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/AirQuality.jsx"
    click Footer "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/components/Footer.jsx"

    %% Click Events - Data Layer
    click useLocation "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/hooks/useLocation.js"
    click useCurrentWeather "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/hooks/useCurrentWeather.js"
    click useTodayWeather "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/hooks/useTodayWeather.js"
    click useWeeklyForecast "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/hooks/useWeeklyForecast.js"
    click useAQI "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/hooks/useAQI.js"

    %% Click Events - Utilities
    click weatherImageMap "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/utils/weatherImageMap.js"
    click uvIndexImageMap "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/utils/uvIndexImageMap.js"
    click aqiMap "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/utils/aqiMap.js"
    click getWindDirection "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/utils/getWindDirection.js"
    click cn "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/src/utils/cn.js"

    %% Click Events - Build & Deploy
    click Package "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/package.json"
    click ViteConfig "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/vite.config.js"
    click ESLint "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/eslint.config.js"
    click ViteServer "https://github.com/shekhawat-ajay/drizzle-weather-app/blob/main/vite.config.js"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef data fill:#A8E6CF,stroke:#333,stroke-width:1px
    classDef utils fill:#FFF3B0,stroke:#333,stroke-width:1px
    classDef external fill:#FFD3B6,stroke:#333,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:1px
```
