# azardnet/sc-weather architecture

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

- Interactive diagram: https://gitdiagram.com/azardnet/sc-weather
- Repository: https://github.com/azardnet/sc-weather

## Overview

##### Project type and purpose
- At its core “sc-weather” is a single-page, progressive web application (PWA) that fetches weather data from external APIs and displays it in a responsive React/TypeScript UI.
- The TODO list shows plans for an Express-based backend proxy, service-worker caching, notifications, and third-party integrations (e.g. Spotify).

##### File structure
- Root folder
- index.html, style.scss, static/ → raw HTML/CSS and assets served directly to the browser
- index.js, request.js, translate.js, utils.js → Node scripts (future Express server entrypoint, API wrappers, utility functions)
- webpack.dev.js / webpack.prod.js → build pipelines for bundling front-end assets and server code
- .env.example → environment variables for API keys (OpenWeatherMap, Spotify, etc.)
- face/ sub-folder
- package.json, vite.config.ts, tsconfig.json → standalone React/TypeScript front-end powered by Vite
- src/ → React components (Search, WeatherData), styles, assets, entrypoint (main.tsx)
- public/ → static files that Vite will copy into /dist

##### Key insights from the README
- The “wrapper back-end with express” item hints at a two-tier architecture:
a) Front-end SPA built and served as static assets
b) Express API to proxy external weather (and later Spotify) calls
- PWA features under development: service worker, manifest.json, caching strategies, notifications.

- Client (browser)
- Static asset server / CDN
- API server
- External services
- Important build steps (e.g. “Vite build → face/dist”, “Webpack → public/dist”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build Pipeline
    subgraph "Build Pipeline" 
        direction TB
        VITE["Vite Build"]:::build
        WEBDEV["Webpack Dev"]:::build
        WEBPROD["Webpack Prod"]:::build
    end
    VITE -->|outputs static assets| DIST_FACE["face/dist"]
    WEBDEV -->|outputs bundles| DIST_ROOT["public/dist"]
    WEBPROD -->|outputs bundles| DIST_ROOT

    %% Static Asset Server
    STATIC["Static Asset Server<br/>(Nginx / Express)"]:::server
    DIST_FACE --> STATIC
    DIST_ROOT --> STATIC

    %% Static files served
    ROOT_HTML["index.html"]:::frontend
    STYLE["style.scss"]:::frontend
    STATIC_DIR["static/"]:::frontend
    FACE_HTML["face/index.html"]:::frontend
    FACE_PUBLIC["face/public/"]:::frontend

    STATIC --> ROOT_HTML
    STATIC --> STYLE
    STATIC --> STATIC_DIR
    STATIC --> FACE_HTML
    STATIC --> FACE_PUBLIC

    %% Client
    subgraph "Client Browser" 
        direction TB
        BROWSER["Browser / React SPA"]:::frontend
        SW["Service Worker"]:::pwa
    end
    STATIC -->|serves| BROWSER
    BROWSER -->|registers| SW
    SW -->|intercepts fetch| CACHE["Cache Storage"]:::pwa
    BROWSER -->|fetch /api/*| API

    %% API Layer
    subgraph "API Layer" 
        direction TB
        API["Express API /api/*"]:::server
        REQ["request.js"]:::server
        TRANS["translate.js"]:::server
        UTIL["utils.js"]:::server
    end
    API --> REQ
    API --> TRANS
    API --> UTIL

    %% External Services
    subgraph "External Services"
        direction TB
        OWM["OpenWeatherMap API"]:::external
        SPOT["Spotify API (future)"]:::external
        NOTIF["Notification Service"]:::external
    end
    REQ --> OWM
    API --> SPOT
    API --> NOTIF
    TRANS --> OWM

    %% Environment
    ENV[".env.example"]:::config

    %% Click Events
    click face/src "https://github.com/azardnet/sc-weather/tree/master/face/src/"
    click face/src/main.tsx "https://github.com/azardnet/sc-weather/blob/master/face/src/main.tsx"
    click Search "https://github.com/azardnet/sc-weather/blob/master/face/src/components/Search/index.tsx"
    click WeatherData "https://github.com/azardnet/sc-weather/blob/master/face/src/components/WeatherData/index.tsx"
    click FACE_HTML "https://github.com/azardnet/sc-weather/blob/master/face/index.html"
    click FACE_PUBLIC "https://github.com/azardnet/sc-weather/tree/master/face/public/"
    click VITE "https://github.com/azardnet/sc-weather/blob/master/face/vite.config.ts"
    click ROOT_HTML "https://github.com/azardnet/sc-weather/blob/master/index.html"
    click STYLE "https://github.com/azardnet/sc-weather/blob/master/style.scss"
    click STATIC_DIR "https://github.com/azardnet/sc-weather/tree/master/static/"
    click API "https://github.com/azardnet/sc-weather/blob/master/index.js"
    click REQ "https://github.com/azardnet/sc-weather/blob/master/request.js"
    click TRANS "https://github.com/azardnet/sc-weather/blob/master/translate.js"
    click UTIL "https://github.com/azardnet/sc-weather/blob/master/utils.js"
    click WEBDEV "https://github.com/azardnet/sc-weather/blob/master/webpack.dev.js"
    click WEBPROD "https://github.com/azardnet/sc-weather/blob/master/webpack.prod.js"
    click ENV "https://github.com/azardnet/sc-weather/blob/master/.env.example"

    %% Styles
    classDef build fill:#f9f,stroke:#333,stroke-width:1px
    classDef frontend fill:#bbf,stroke:#333,stroke-width:1px
    classDef server fill:#fbf,stroke:#333,stroke-width:1px
    classDef external fill:#bfb,stroke:#333,stroke-width:1px
    classDef pwa fill:#ffb,stroke:#333,stroke-width:1px
    classDef config fill:#ddd,stroke:#333,stroke-width:1px
```
