$ show chubin/wttr.in
wttr.in is a production-grade weather forecast service accessible via HTTP, designed primarily for terminal use with `curl`. It provides weather reports in multiple formats: ANSI-colored text (v1 and v2 views), plain text, JSON (j1/j2), Prometheus metrics (p1), HTML, and PNG images. The service automatically detects the user's location via IP geolocation (MaxMind GeoIP2) or explicit city/airport/coordinate queries, then fetches weather data from WorldWeatherOnline (the only actively configured data source). The architecture is a single Go binary with embedded assets (fonts, translations, templates) and a pipeline of interfaces: query parsing, location resolution, weather fetching, caching, rendering, and formatting. It supports 74 languages with per-language translation files and a rule-based routing system for selecting views and output types. The codebase demonstrates solid engineering with interface-based design, multiple caching layers (LRU in-memory, disk-based, SQLite-backed location cache), and request coalescing to prevent thundering herd on upstream APIs. However, it shows signs of technical drift: reliance on a single external weather API, hardcoded paths in configuration, disabled linters, and incomplete translations. The project is actively maintained with a large user base and extensive integration documentation for tools like tmux, Waybar, Emacs, and Google Sheets.
The LLM identified 4 files worth highlighting for reuse:
Implements an in-memory LRU cache with a unique request coalescing mechanism: `SetInProgressIfNotExists` marks a key as being fetched, and `WaitForCompletion` blocks concurrent requests until the first completes. This prevents thundering herd on upstream API calls. The cache is generic (uses `interface{}` keys and values) and can be extracted as a standalone library for any Go project needing cache stampede protection.
Loads and serves translations from embedded files at startup. Provides methods like `Text`, `Condition`, `ConditionByName`, and `File` to access localized strings. The bundle preloads all languages into memory, supporting 74 languages with consistent file structure (messages.json, conditions.txt, v1.json, v2.json). This pattern is reusable for any Go application needing a lightweight, file-based i18n system with embedded assets.
Converts ANSI-colored terminal output to PNG images using the `go-te` and `gg` libraries. It parses ANSI escape sequences, applies fonts, and renders to a bitmap. This is a self-contained utility that could be extracted as a standalone library for any project needing to convert terminal output to images (e.g., for sharing weather reports on social media or embedding in web pages).
Parses HTTP query strings into an `Options` struct using a YAML configuration file (`share/defs/options/options.yaml`) that defines allowed parameters, types, defaults, and active flags. The parser validates inputs against the YAML schema and returns structured options. This pattern is reusable for any Go web service that wants to decouple query parameter definitions from parsing logic, enabling easy addition or deprecation of options without code changes.