Netscape Weather App

A modern weather application that uses Netscape's free weather service, powered by Bun, Express.js, and Ollama AI for data parsing.

Features

  • CLI Interface: Interactive command-line weather search with Enquirer prompts
  • Web Interface: Beautiful map-based visualization with animated particles
  • AI-Powered Parsing: Uses Ollama (llama3.2:1b) to parse weather data into structured JSON
  • Smart Caching: File-based cache with 1-hour expiry to minimize API requests
  • Particle Animations: Visual weather effects including wind, rain, clouds, temperature, and humidity overlays

Prerequisites

Install Ollama and pull the model:

ollama pull llama3.2:1b

Installation

bun install

Usage

CLI Mode

Run the interactive command-line interface:

bun run cli

Features:

  • Interactive search prompts with Enquirer
  • Displays today's weather and forecast
  • Color-coded output for better readability
  • Cached results for faster subsequent queries
  • Selection menu when multiple locations found

Web Server Mode

Start the web server:

bun run server

Then open http://localhost:3000 in your browser.

Features:

  • Interactive map powered by Leaflet and OpenStreetMap
  • Search for any location
  • Multiple visualization modes:
    • Temperature: Red-blue gradient overlay (40°C = red, -5°C = blue)
    • Felt Temperature: Same as temperature but uses "feels like" values
    • Humidity: Blue-red gradient (0% = blue, 100% = red)
    • Wind: Particle animation with trails showing wind speed and direction
    • Clouds: Cloud-shaped particles based on cloud coverage
  • Automatic caching (max 1 request per location per hour)
  • Dark theme optimized for weather visualization

Testing

Run individual test files:

# Run all tests (integration)
bun run test:integration

# Test web scraper
bun run test:scraper

# Test AI parser (requires Ollama running)
bun run test:parser

# Test file cache
bun run test:cache

Project Structure

.
├── index.js              # CLI entry point
├── server.js             # Web server entry point
├── package.json          # Dependencies
├── src/
│   ├── scraper.js        # Netscape weather scraping
│   ├── parser.js         # Ollama AI parsing
│   ├── cache.js          # File-based caching
│   ├── geocode.js        # Location helpers
│   └── public/
│       ├── index.html    # Web interface
│       ├── style.css     # Styling
│       └── app.js        # Frontend logic + particles
├── cache/                # Cache directory (auto-created)
├── test-scraper.js       # Scraper tests
├── test-parser.js        # Parser tests
└── test-cache.js         # Cache tests

API Endpoints

GET /api/search?q={query}

Search for locations by name or zip code.

Response:

{
  "places": [
    {"id": "12838767", "name": "Ilmenau, TH, DE"}
  ]
}

GET /api/weather/:locationId?type=today|forecast

Get weather data for a location.

Response:

{
  "locationId": "12838767",
  "type": "today",
  "data": [
    {
      "time": "6:00 PM Friday",
      "clouds": 1,
      "temp": 46,
      "humidity": 92,
      "felttemp": 45,
      "wind": 5,
      "winddir": "sse"
    }
  ]
}

How It Works

  1. Scraping: The app scrapes Netscape's weather pages (https://isp.netscape.com/weather/)
  2. Parsing: Raw HTML is converted to text and sent to Ollama AI
  3. Caching: Results are cached locally in JSON files for 1 hour
  4. Visualization: Frontend uses Canvas API for particle effects and Leaflet for maps

Notes

  • This app uses Netscape's free weather service which may not be available indefinitely
  • The geocoding feature is simplified and may not work for all locations
  • Ollama must be running locally for the parser to work
  • Cache files are stored in the ./cache directory

License

MIT