# m0hammedk/skycast architecture

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

- Interactive diagram: https://gitdiagram.com/m0hammedk/skycast
- Repository: https://github.com/m0hammedk/skycast

## Overview

##### Project type and purpose
- This is a full-stack, server-rendered React application built with Next.js (App Router).
- It provides a user interface for searching weather and forecast data by city, fetches that data from external weather APIs, and displays it in various UI panels and tables.

##### File structure to extract components
- src/app → Next.js front-end: routing (layout.tsx, page.tsx), global CSS, components
- src/app/api → two serverless API routes: /api/weather and /api/forecast
- src/server → fetch helper (Get.tsx) encapsulating external API calls
- src/utils → utility functions (Weather.tsx) for building requests/parsing responses
- src/models → TypeScript schemas and interfaces for Weather, Forecast, etc.
- src/app/components
- GlobalStates/CityContext.tsx → React Context for sharing selected city
- UI → Navbar, Footer, Panel, Table
- Tests (jest & cypress) and config files are ancillary QA components.

##### README for architecture hints
- A standard create-next-app setup on Vercel, no databases, no microservices.
- Focus is on serverless functions and front-end component hierarchy.

##### Main components and their relationships
a. Browser / User Interface
- Next.js pages (page.tsx) and layout
- UI components (Navbar, Footer, Panel, Table)
- React Context (CityContext)
b. API Layer (Next.js serverless functions)
- /api/weather
- /api/forecast
c. Server / Fetch Helper
- src/server/Get.tsx – centralizes fetch logic to external weather API
d. External Weather Service
- Third-party REST API (e.g., weatherapi.com)
e. Shared Data Models
- TypeScript schemas in src/models

##### Architectural patterns & principles
- Component-based UI (React)
- Serverless API routes (Next.js App Router)
- Single source of truth for city selection via React Context
- Separation of concerns:
- UI layer (components)
- API layer (route handlers)
- Data-fetch layer (Get.tsx)
- Data modeling (schemas)

- Browser / User
- Next.js UI (page.tsx + components + context)
- API Routes (route.tsx handlers)
- Fetch Helper (Get.tsx) + Utils & Models
- External Weather Service

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Title
    subgraph "Weather App Architecture"
    end

    %% User
    User["Browser / User"]:::external

    %% Frontend Layer
    subgraph "Frontend (React + Next.js App Router)"
        Layout["Layout (src/app/layout.tsx)"]:::frontend
        Page["Main Page (src/app/page.tsx)"]:::frontend
        CityContext["CityContext (src/app/components/GlobalStates/CityContext.tsx)"]:::frontend

        subgraph "UI Components"
            Navbar["Navbar (UI)"]:::frontend
            Panel["Panel (UI)"]:::frontend
            Table["Table (UI)"]:::frontend
            Footer["Footer (UI)"]:::frontend
        end

        subgraph "Icon Components"
            CloudIcon["CloudIcon"]:::frontend
            HumidityIcon["HumidityIcon"]:::frontend
            SearchIcon["SearchIcon"]:::frontend
            ThermometerIcon["ThermometerIcon"]:::frontend
            WindIcon["WindIcon"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Next.js API Routes)"
        APIWeather["/api/weather"]:::serverless
        APIForecast["/api/forecast"]:::serverless
    end

    %% Data Fetch & Models
    subgraph "Data Fetch & Models"
        GetHelper["Fetch Helper (src/server/Get.tsx)"]:::util
        Utils["Weather Utils (src/utils/Weather.tsx)"]:::util

        subgraph "Models (TypeScript Schemas)"
            WeatherModel["Weather (src/models/Weather.tsx)"]:::util
            WeatherDayModel["WeatherDay (src/models/WeatherDay.tsx)"]:::util
            ForecastModel["Forecast (src/models/Forecast.tsx)"]:::util
            ForecastDaySchema["ForecastDaySchema (src/models/ForecasDaySchema.tsx)"]:::util
            ForecastAstro["ForecastAstro (src/models/ForecastAstro.tsx)"]:::util
            ForecastHour["ForecastHour (src/models/ForecastHour.tsx)"]:::util
        end
    end

    %% External Service
    ExternalAPI["External Weather Service"]:::external

    %% QA Tools
    subgraph "QA & Testing"
        Jest["Jest Tests"]:::qa
        Cypress["Cypress Tests"]:::qa
    end

    %% Connections
    User -->|"visits"| Layout
    Layout -->|"renders"| Page
    Page -->|"uses context"| CityContext
    Page -->|"renders"| Navbar
    Page -->|"renders"| Panel
    Page -->|"renders"| Table
    Page -->|"renders"| Footer
    Page -->|"uses icons"| CloudIcon
    Page -->|"uses icons"| HumidityIcon
    Page -->|"uses icons"| SearchIcon
    Page -->|"uses icons"| ThermometerIcon
    Page -->|"uses icons"| WindIcon

    Page -->|"fetches weather"| APIWeather
    Page -->|"fetches forecast"| APIForecast

    APIWeather -->|"calls"| GetHelper
    APIForecast -->|"calls"| GetHelper

    GetHelper -->|"uses utils"| Utils
    GetHelper -->|"structures data"| WeatherModel
    GetHelper -->|"structures data"| WeatherDayModel
    GetHelper -->|"structures data"| ForecastModel
    GetHelper -->|"structures data"| ForecastDaySchema
    GetHelper -->|"structures data"| ForecastAstro
    GetHelper -->|"structures data"| ForecastHour

    GetHelper -->|"HTTP GET"| ExternalAPI
    ExternalAPI -->|"response"| GetHelper
    GetHelper -->|"returns data"| APIWeather
    GetHelper -->|"returns data"| APIForecast

    Jest --> Page
    Cypress --> User

    %% Click Events
    click Layout "https://github.com/m0hammedk/skycast/blob/master/src/app/layout.tsx"
    click Page "https://github.com/m0hammedk/skycast/blob/master/src/app/page.tsx"
    click CityContext "https://github.com/m0hammedk/skycast/blob/master/src/app/components/GlobalStates/CityContext.tsx"
    click Navbar "https://github.com/m0hammedk/skycast/blob/master/src/app/components/UI/Navbar.tsx"
    click Footer "https://github.com/m0hammedk/skycast/blob/master/src/app/components/UI/Footer.tsx"
    click Panel "https://github.com/m0hammedk/skycast/blob/master/src/app/components/UI/Panel.tsx"
    click Table "https://github.com/m0hammedk/skycast/blob/master/src/app/components/UI/Table.tsx"
    click CloudIcon "https://github.com/m0hammedk/skycast/blob/master/src/app/components/Icons/CloudIcon.tsx"
    click HumidityIcon "https://github.com/m0hammedk/skycast/blob/master/src/app/components/Icons/HumidityIcon.tsx"
    click SearchIcon "https://github.com/m0hammedk/skycast/blob/master/src/app/components/Icons/SearchIcon.tsx"
    click ThermometerIcon "https://github.com/m0hammedk/skycast/blob/master/src/app/components/Icons/ThermometerIcon.tsx"
    click WindIcon "https://github.com/m0hammedk/skycast/blob/master/src/app/components/Icons/WindIcon.tsx"
    click APIWeather "https://github.com/m0hammedk/skycast/blob/master/src/app/api/weather/route.tsx"
    click APIForecast "https://github.com/m0hammedk/skycast/blob/master/src/app/api/forecast/route.tsx"
    click GetHelper "https://github.com/m0hammedk/skycast/blob/master/src/server/Get.tsx"
    click Utils "https://github.com/m0hammedk/skycast/blob/master/src/utils/Weather.tsx"
    click WeatherModel "https://github.com/m0hammedk/skycast/blob/master/src/models/Weather.tsx"
    click WeatherDayModel "https://github.com/m0hammedk/skycast/blob/master/src/models/WeatherDay.tsx"
    click ForecastModel "https://github.com/m0hammedk/skycast/blob/master/src/models/Forecast.tsx"
    click ForecastDaySchema "https://github.com/m0hammedk/skycast/blob/master/src/models/ForecasDaySchema.tsx"
    click ForecastAstro "https://github.com/m0hammedk/skycast/blob/master/src/models/ForecastAstro.tsx"
    click ForecastHour "https://github.com/m0hammedk/skycast/blob/master/src/models/ForecastHour.tsx"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef serverless fill:#98FB98,stroke:#333,stroke-width:1px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef qa fill:#DDA0DD,stroke:#333,stroke-width:1px
```
