# mihirbhadak/hackathon_nasa_nirma architecture

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

- Interactive diagram: https://gitdiagram.com/mihirbhadak/hackathon_nasa_nirma
- Repository: https://github.com/mihirbhadak/hackathon_nasa_nirma

## Overview

##### Main components
- User Interface (UI): There are two main areas. One is found in the “app” directory under “Components” which contains weather-related widgets such as AirPollution, DailyForecast, Temperature, etc. Also be aware of the “components” directory with subdirectories for reusable atoms, UI elements, and chat components, which likely serve to build parts of the interface.
- API Routes: The “app/api” directory contains several endpoints (chat, fiveday, geocoded, pollution, uv, weather) that serve as the backend for fetching or processing data.
- Pages/Views: The Next.js app uses file-based routing. Note the “app/page.tsx” for the home page, “app/chat-with-ai/page.tsx” for the chat interface, and “app/map/page.tsx” for the map view.
- Providers and Global State: The “app/Providers” (like ThemeProvider) and “app/context” (globalContext.js) show that the project uses context for application-wide state management.
- External Integration/Utilities: There are utility files and configurations (e.g., lib/utils, next.config.mjs, tailwind.config.ts) that support styling, configuration, and common helper functions.

##### Relationships and interactions
- That the UI pages (the front-end) call upon the UI components for rendering detailed weather data.
- Providers/Context layer to the UI components to show that application state (like themes or global settings) is shared across the UI.

##### Architectural patterns/design principles
- File-based routing of Next.js: Emphasize how pages and API routes are organized by their directory structure.
- Separation of concerns: UI components are clearly separated from API implementations and business logic.
- Reusability: The existence of both “app/Components” and “components” (atoms and UI) directories indicates component reusability and clear component hierarchies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Node
    Client["Client Browser"]:::components

    %% Pages Subgraph
    subgraph "Pages"
        Home["Home Page"]:::pages
        Chat["Chat-With-AI Page"]:::pages
        Map["Map Page"]:::pages
    end

    %% UI Components Subgraph
    subgraph "UI Components"
        subgraph "Weather Components"
            AirPollution["Air Pollution Widget"]:::components
            DailyForecast["Daily Forecast Widget"]:::components
            FeelsLike["Feels Like Widget"]:::components
            FiveDayForecast["Five Day Forecast Widget"]:::components
            Humidity["Humidity Widget"]:::components
            Temperature["Temperature Widget"]:::components
            UvIndex["UV Index Widget"]:::components
            UvProgress["UV Progress Widget"]:::components
            OtherUI["Other UI Widgets"]:::components
        end
        subgraph "Reusable & Chat Components"
            Atoms["Reusable Atoms"]:::components
            UIElements["UI Elements"]:::components
            ChatComponents["Chat Components"]:::components
        end
    end

    %% API Endpoints Subgraph
    subgraph "API Endpoints"
        ChatAPI["Chat API Endpoint"]:::api
        FiveDayAPI["Five-day Forecast API"]:::api
        GeocodedAPI["Geocoded API Endpoint"]:::api
        PollutionAPI["Pollution API Endpoint"]:::api
        UVAPI["UV API Endpoint"]:::api
        WeatherAPI["Weather API Endpoint"]:::api
    end

    %% Providers / Global State Subgraph
    subgraph "Providers & Global State"
        ThemeProvider["Theme Provider"]:::providers
        GlobalContext["Global Context"]:::providers
        AdditionalProvider["Additional Theme Provider"]:::providers
    end

    %% Configuration & Utilities Subgraph
    subgraph "Configuration & Utilities"
        Utils["Utility Functions"]:::config
        Lib["Library Helpers & Types"]:::config
        NextConfig["Next Config"]:::config
        TailwindConfig["Tailwind Config"]:::config
        PostCSSConfig["PostCSS Config"]:::config
    end

    %% Connections from Client to Pages
    Client --> Home
    Client --> Chat
    Client --> Map

    %% Connections from Pages to UI Components
    Home --> Temperature
    Home --> DailyForecast
    Home --> AirPollution
    Home --> Humidity
    Home --> UvIndex
    Home --> UvProgress

    Chat --> ChatComponents
    Chat --> Atoms
    Chat --> UIElements

    Map --> OtherUI

    %% Connections from UI Components to API Endpoints
    Temperature -->|"fetches"| WeatherAPI
    DailyForecast -->|"fetches"| FiveDayAPI
    FeelsLike -->|"fetches"| WeatherAPI
    AirPollution -->|"calls"| PollutionAPI
    Humidity -->|"fetches"| WeatherAPI
    UvIndex -->|"calls"| UVAPI
    UvProgress -->|"calls"| UVAPI
    ChatComponents -->|"calls"| ChatAPI

    %% Providers influence UI Components
    ThemeProvider --- Temperature
    ThemeProvider --- DailyForecast
    GlobalContext --- ChatComponents
    AdditionalProvider --- UIElements

    %% Configuration influences both UI and API
    Utils --- WeatherAPI
    Lib --- PollutionAPI
    NextConfig --- WeatherAPI
    TailwindConfig --- Home
    PostCSSConfig --- Home

    %% Styles
    classDef pages fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef components fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef api fill:#FFCDD2,stroke:#D32F2F,stroke-width:2px;
    classDef providers fill:#BBDEFB,stroke:#1976D2,stroke-width:2px;
    classDef config fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;

    %% Click Events for Pages
    click Home "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/page.tsx"
    click Chat "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/chat-with-ai/page.tsx"
    click Map "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/map/page.tsx"

    %% Click Events for Weather Components
    click AirPollution "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/AirPollution/AirPollution.tsx"
    click DailyForecast "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/DailyForecast/DailyForecast.tsx"
    click FeelsLike "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/FeelsLike/FeelsLike.tsx"
    click FiveDayForecast "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/FiveDayForecast/FiveDayForecast.tsx"
    click Humidity "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/Humidity/Humidity.tsx"
    click Temperature "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/Temperature/Temperature.tsx"
    click UvIndex "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/UvIndex/UvIndex.tsx"
    click UvProgress "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Components/UvProgress/UvProgress.tsx"

    %% Click Events for API Endpoints
    click ChatAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/chat/route.ts"
    click FiveDayAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/fiveday/route.ts"
    click GeocodedAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/geocoded/route.ts"
    click PollutionAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/pollution/route.ts"
    click UVAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/uv/route.ts"
    click WeatherAPI "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/api/weather/route.ts"

    %% Click Events for Providers
    click ThemeProvider "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/Providers/ThemeProvider.tsx"
    click GlobalContext "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/app/context/globalContext.js"
    click AdditionalProvider "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/components/providers/theme-provider.tsx"

    %% Click Events for Configuration & Utilities
    click Utils "https://github.com/mihirbhadak/hackathon_nasa_nirma/tree/main/app/utils"
    click Lib "https://github.com/mihirbhadak/hackathon_nasa_nirma/tree/main/lib"
    click NextConfig "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/next.config.mjs"
    click TailwindConfig "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/mihirbhadak/hackathon_nasa_nirma/blob/main/postcss.config.js"
```
