Skip to main content

A production-ready Python wrapper for MSN Weather with a FastAPI backend and CI/CD

Project description

MSN Weather Wrapper

A modern, production-ready Python wrapper for MSN Weather with a FastAPI backend and React frontend.

CI/CD Pipeline PyPI version Python License Documentation Code style: ruff Checked with mypy Container


Overview

MSN Weather Wrapper is a comprehensive weather data solution featuring:

  • Python Library - Type-safe weather client with Pydantic models
  • REST API - Production-ready FastAPI service with built-in OpenAPI docs
  • Web Frontend - Modern React 19 + TypeScript 5.7+ with Vite 7
  • Containerized - Podman/Docker deployment with Gunicorn, Uvicorn workers, and Nginx

Technology Stack:

  • Backend: Python 3.10+, FastAPI 0.115+, Pydantic 2.12+, Uvicorn, Gunicorn 23.0+
  • Frontend: React 19.2, Vite 7.2, TypeScript 5.7+
  • Testing: pytest 8.0+, Playwright, 168 tests (128 backend, 40 frontend E2E) with 97% coverage
  • Quality: ruff 0.14+, mypy 1.19+, pre-commit hooks
  • Security: Bandit, Semgrep, pip-audit, Trivy, Grype, weekly automated scans
  • Deployment: Podman/Docker, Nginx, multi-stage builds

Quick Start

๐Ÿš€ Containerized Deployment (Recommended)

git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
podman-compose up -d
# Access at http://localhost:8080

๐Ÿ“ฆ Python Package

pip install msn-weather-wrapper
from msn_weather_wrapper import WeatherClient, Location

with WeatherClient() as client:
    location = Location(city="London", country="UK")
    weather = client.get_weather(location)
    print(f"Temperature: {weather.temperature}ยฐC")

๐Ÿงช Development Environment

./dev.sh setup   # One-time setup
./dev.sh start   # Start dev servers
./dev.sh status  # Check health
# Frontend: http://localhost:5173
# API: http://localhost:5000
# Health: http://localhost:5000/api/v1/health

๐Ÿงญ Start Here If You're New

If you're learning the codebase, explore it in this order:

  1. src/msn_weather_wrapper/ โ€” backend logic and the FastAPI app
  2. frontend/ โ€” the React UI
  3. tests/ โ€” examples of expected behavior
  4. scripts/ โ€” helper commands for setup, reports, and deployment tasks

A detailed walkthrough now lives in docs/PROJECT_STRUCTURE.md.


Features

  • ๐ŸŒค๏ธ Weather data extraction from MSN Weather
  • ๐ŸŒ 406+ cities worldwide with autocomplete
  • ๐Ÿ”Œ RESTful API with comprehensive validation
  • ๐Ÿ“š Interactive API docs (Swagger UI at /apidocs/)
  • โš›๏ธ Modern web interface with React + TypeScript
  • ๐Ÿš€ 5-minute caching (90%+ faster repeated requests)
  • ๐Ÿ”’ Rate limiting (30 req/min per IP, 200/hr global)
  • ๐Ÿ›ก๏ธ Input validation & attack prevention (SQL injection, XSS, etc.)
  • ๐Ÿ” Automated security scanning (Bandit, Semgrep, Trivy, Grype)
  • ๐Ÿ” Type safety with mypy strict mode
  • ๐Ÿ“‹ SBOM generation for supply chain security
  • โ™ฟ WCAG 2.1 Level AA accessible frontend
  • ๐Ÿ”„ Modular CI/CD workflows - Reusable, maintainable architecture
  • ๐Ÿ”„ Optimized CI/CD with Docker caching & conditional matrices
  • ๐Ÿท๏ธ Automated semantic versioning - Every PR auto-publishes to PyPI

Installation

Prerequisites

  • Python 3.10+
  • Node.js 20+ (for frontend development)
  • Podman or Docker (for containerized deployment)

From Source

git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pre-commit install

Usage

Python Library

from msn_weather_wrapper import WeatherClient, Location

with WeatherClient() as client:
    location = Location(city="Seattle", country="USA")
    weather = client.get_weather(location)

    print(f"Temperature: {weather.temperature}ยฐC")
    print(f"Condition: {weather.condition}")
    print(f"Humidity: {weather.humidity}%")

REST API

# Development
python api.py

# Production
gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:5000 --workers 4 --timeout 120 api:app

# GET request
curl "http://localhost:5000/api/weather?city=London&country=UK"

# POST request
curl -X POST http://localhost:5000/api/weather \
  -H "Content-Type: application/json" \
  -d '{"city": "London", "country": "UK"}'

Web Frontend

cd frontend
npm install
npm run dev  # http://localhost:5173

Features: City autocomplete (406+ cities), temperature unit toggle (ยฐC/ยฐF), geolocation support, responsive design, WCAG 2.1 Level AA accessibility


Development

# Setup & Run
./dev.sh setup   # One-time setup
./dev.sh start   # Start dev environment
./dev.sh test    # Run tests
./dev.sh logs    # View logs

# Code Quality
ruff format .                    # Format
ruff check .                     # Lint
mypy src/msn_weather_wrapper     # Type check
pre-commit run --all-files       # Run all checks

# Testing
pytest                           # All tests
pytest --cov=src --cov-report=html  # With coverage
pytest tests/test_client.py -v   # Specific file

Deployment

# Podman/Docker Compose
podman-compose up -d
podman-compose logs -f
podman-compose down

# Standalone Container
podman build -t msn-weather-wrapper .
podman run -p 8080:80 msn-weather-wrapper

Architecture: Unified container (Python + Node.js), Nginx reverse proxy, Gunicorn with Uvicorn workers, and Kubernetes-ready health checks


Documentation

๐Ÿ“š Full Documentation


Project Structure

msn-weather-wrapper/
โ”œโ”€โ”€ src/msn_weather_wrapper/
โ”‚   โ”œโ”€โ”€ api/                    # FastAPI app (main, routers, services, schemas)
โ”‚   โ”œโ”€โ”€ client.py               # Core MSN weather client
โ”‚   โ”œโ”€โ”€ models.py               # Shared Pydantic models
โ”‚   โ””โ”€โ”€ exceptions.py           # Domain exceptions
โ”œโ”€โ”€ frontend/                   # React application
โ”œโ”€โ”€ tests/                      # Backend and integration tests
โ”œโ”€โ”€ scripts/                    # Dev, reporting, and deployment helpers
โ”œโ”€โ”€ infra/                      # Containers, compose files, and runtime config
โ”œโ”€โ”€ docs/                       # Docs and beginner walkthroughs
โ”œโ”€โ”€ api.py                      # Local API entrypoint
โ”œโ”€โ”€ dev.sh                      # Thin wrapper around `scripts/dev.sh`
โ””โ”€โ”€ pyproject.toml              # Python project configuration

Contributing

Contributions are welcome! Please ensure:

  1. โœ… All tests pass: pytest
  2. ๐ŸŽจ Code is formatted: ruff format .
  3. ๐Ÿ” Type checks pass: mypy src/
  4. ๐Ÿช Pre-commit hooks pass
  5. ๐Ÿ“ Documentation is updated

See CONTRIBUTING.md for detailed guidelines.


License

MIT License - see LICENSE for details.


Links


Disclaimer

This project is an unofficial wrapper for MSN Weather data and is provided for educational and personal use only. This software is not affiliated with, endorsed by, or officially connected to Microsoft Corporation or MSN Weather in any way.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msn_weather_wrapper-2.0.3.tar.gz (385.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

msn_weather_wrapper-2.0.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file msn_weather_wrapper-2.0.3.tar.gz.

File metadata

  • Download URL: msn_weather_wrapper-2.0.3.tar.gz
  • Upload date:
  • Size: 385.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msn_weather_wrapper-2.0.3.tar.gz
Algorithm Hash digest
SHA256 a1a946f3be37dae5e0460751ede9a801e3ce331f22bb0f05debf66b8d6f8e1dc
MD5 25fc025dfeac6b006c43f493b239f633
BLAKE2b-256 94f8e2641cab395504ce1ca5bdb9dd536a724bdd9c22b28f242a941586b3527d

See more details on using hashes here.

Provenance

The following attestation bundles were made for msn_weather_wrapper-2.0.3.tar.gz:

Publisher: publish-release.yml on jim-wyatt/msn-weather-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msn_weather_wrapper-2.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for msn_weather_wrapper-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6961e4870f33d79f4b166147e7af07d03d1d0c6734f5179583b5f0f887d8e55
MD5 eaba1eabdff0eb97b00df92f4159f847
BLAKE2b-256 40587bab81b858b9f0f965622213308fe55ee5e3c51bcbd47f90b7a73a55836c

See more details on using hashes here.

Provenance

The following attestation bundles were made for msn_weather_wrapper-2.0.3-py3-none-any.whl:

Publisher: publish-release.yml on jim-wyatt/msn-weather-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page