# rink42/taiwan-weather architecture

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

- Interactive diagram: https://gitdiagram.com/rink42/taiwan-weather
- Repository: https://github.com/rink42/taiwan-weather

## Overview

This is a browser-based Taiwan weather app with international weather lookup, location-based selection, forecast views, and offline support. The primary flow selects a Taiwan county/district or international city, retrieves forecast data, transforms it for display, and caches Taiwan results locally; the service worker separately handles static assets and network-only weather/geocoding requests. The excerpts support the main app, icon renderer, and service-worker behavior, but not all app.js internals, so uncertain call links are omitted.

Main entry points: [`app.js`](https://github.com/rink42/taiwan-weather/blob/main/app.js) (Weather app), [`service-worker.js`](https://github.com/rink42/taiwan-weather/blob/main/service-worker.js) (Request handler), [`icons.js`](https://github.com/rink42/taiwan-weather/blob/main/icons.js) (Weather icon renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_weather["Weather experience"]
  node_app["Weather app<br/>[app.js]"]
  node_taiwan["Taiwan forecasts<br/>[app.js]"]
  node_intl["International weather<br/>[app.js]"]
  node_location["Location lookup<br/>[app.js]"]
  node_forecast["Forecast processing<br/>[app.js]"]
end

subgraph group_offline["Offline support"]
  node_localcache[("Local forecast cache<br/>[app.js]")]
  node_serviceworker["Request handler<br/>[service-worker.js]"]
  node_staticcache[("Asset cache<br/>[service-worker.js]")]
end

subgraph group_visuals["Weather visuals"]
  node_icons["Weather icon renderer<br/>[icons.js]"]
end

node_user(("Weather viewer"))
node_weatherapi{{"CWA weather API"}}
node_openmeteo{{"Open-Meteo services"}}
node_nominatim{{"Nominatim geocoder"}}
node_nlsc{{"NLSC location API"}}

node_user -->|"uses"| node_app
node_app -->|"selects region"| node_taiwan
node_app -->|"selects city"| node_intl
node_app -->|"requests location"| node_location
node_taiwan -.->|"fetches forecasts"| node_weatherapi
node_intl -.->|"fetches forecasts"| node_openmeteo
node_intl -->|"reverse geocodes"| node_nominatim
node_location -->|"resolves Taiwan place"| node_nlsc
node_location -->|"resolves international place"| node_nominatim
node_taiwan -.->|"processes data"| node_forecast
node_forecast -->|"stores forecasts"| node_localcache
node_taiwan -.->|"loads offline data"| node_localcache
node_app -.->|"renders conditions"| node_icons
node_serviceworker -->|"reads and writes"| node_staticcache
node_user -.->|"requests app"| node_serviceworker
node_serviceworker -->|"network only"| node_weatherapi
node_serviceworker -->|"network only"| node_openmeteo
node_serviceworker -->|"network only"| node_nominatim

click node_app "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_taiwan "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_intl "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_location "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_forecast "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_localcache "https://github.com/rink42/taiwan-weather/blob/main/app.js"
click node_serviceworker "https://github.com/rink42/taiwan-weather/blob/main/service-worker.js"
click node_staticcache "https://github.com/rink42/taiwan-weather/blob/main/service-worker.js"
click node_icons "https://github.com/rink42/taiwan-weather/blob/main/icons.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_taiwan,node_intl,node_location,node_forecast,node_user toneBlue
class node_localcache,node_serviceworker,node_staticcache toneAmber
class node_icons,node_weatherapi,node_nlsc toneMint
class node_openmeteo,node_nominatim toneIndigo
```

## Components

### Weather experience

- [Weather app](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`
- [Taiwan forecasts](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`
- [International weather](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`
- [Location lookup](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`
- [Forecast processing](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`

### Offline support

- [Local forecast cache](https://github.com/rink42/taiwan-weather/blob/main/app.js): `app.js`
- [Request handler](https://github.com/rink42/taiwan-weather/blob/main/service-worker.js): `service-worker.js`
- [Asset cache](https://github.com/rink42/taiwan-weather/blob/main/service-worker.js): `service-worker.js`

### Weather visuals

- [Weather icon renderer](https://github.com/rink42/taiwan-weather/blob/main/icons.js): `icons.js`

### Other components

- **Weather viewer**
- **CWA weather API**
- **Open-Meteo services**
- **Nominatim geocoder**
- **NLSC location API**

## Connections

- Weather viewer → Weather app: uses (evidence: `app.js`)
- Weather app → Taiwan forecasts: selects region (evidence: `app.js`)
- Weather app → International weather: selects city (evidence: `app.js`)
- Weather app → Location lookup: requests location (evidence: `app.js`)
- Taiwan forecasts → CWA weather API: fetches forecasts
- International weather → Open-Meteo services: fetches forecasts
- International weather → Nominatim geocoder: reverse geocodes (evidence: `app.js`)
- Location lookup → NLSC location API: resolves Taiwan place (evidence: `app.js`)
- Location lookup → Nominatim geocoder: resolves international place (evidence: `app.js`)
- Taiwan forecasts → Forecast processing: processes data (evidence: `app.js`)
- Forecast processing → Local forecast cache: stores forecasts (evidence: `app.js`)
- Taiwan forecasts → Local forecast cache: loads offline data (evidence: `app.js`)
- Weather app → Weather icon renderer: renders conditions
- Request handler → Asset cache: reads and writes (evidence: `service-worker.js`)
- Weather viewer → Request handler: requests app
- Request handler → CWA weather API: network only (evidence: `service-worker.js`)
- Request handler → Open-Meteo services: network only (evidence: `service-worker.js`)
- Request handler → Nominatim geocoder: network only (evidence: `service-worker.js`)
