A production-ready Python wrapper for MSN Weather with automatic versioning and CI/CD
Project description
MSN Weather Wrapper
A modern, production-ready Python wrapper for MSN Weather with Flask REST API and React frontend.
Overview
MSN Weather Wrapper is a comprehensive weather data solution featuring:
- Python Library - Type-safe weather client with Pydantic models
- REST API - Production-ready Flask API with OpenAPI/Swagger docs
- Web Frontend - Modern React 19 + TypeScript 5.7+ with Vite 7
- Containerized - Podman/Docker deployment with Gunicorn & Nginx
Technology Stack:
- Backend: Python 3.10+, Flask 3.1+, Pydantic 2.12+, Flasgger, 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
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 --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 WSGI (4 workers), Supervisor (process manager), Kubernetes-ready health checks
Documentation
๐ Full Documentation
- API Reference - Complete REST API documentation
- Interactive Swagger UI - Live API testing & exploration
- Development Guide - Setup & development workflow
- Testing Guide - Test suite & coverage
- Security Guide - Security features & automated scanning
- SBOM Guide - Software bill of materials
- Changelog - Version history
Project Structure
msn-weather-wrapper/
โโโ src/msn_weather_wrapper/ # Python package
โโโ tests/ # Test suite (168 tests: 128 backend + 40 frontend E2E, 97% coverage)
โโโ frontend/ # React application
โโโ api.py # Flask REST API with Swagger
โโโ docs/ # Documentation
โโโ Containerfile # Production container
โโโ pyproject.toml # Python config
Contributing
Contributions are welcome! Please ensure:
- โ
All tests pass:
pytest - ๐จ Code is formatted:
ruff format . - ๐ Type checks pass:
mypy src/ - ๐ช Pre-commit hooks pass
- ๐ Documentation is updated
See CONTRIBUTING.md for detailed guidelines.
License
MIT License - see LICENSE for details.
Links
- ๐ Documentation
- ๐ฆ PyPI Package
- ๐ Issue Tracker
- ๐ฌ Discussions
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msn_weather_wrapper-2.0.2.tar.gz.
File metadata
- Download URL: msn_weather_wrapper-2.0.2.tar.gz
- Upload date:
- Size: 380.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe0c2c1090394cbe7f247cb07621496cd0ea451766e10b053157edca3e8cff54
|
|
| MD5 |
4d3497cc7e5739f850f91f08111693d1
|
|
| BLAKE2b-256 |
ceddd517cab8d61664402f77c17eea4e35a17e79a4c729db290e01f2d621f09f
|
Provenance
The following attestation bundles were made for msn_weather_wrapper-2.0.2.tar.gz:
Publisher:
publish-release.yml on jim-wyatt/msn-weather-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msn_weather_wrapper-2.0.2.tar.gz -
Subject digest:
fe0c2c1090394cbe7f247cb07621496cd0ea451766e10b053157edca3e8cff54 - Sigstore transparency entry: 1214895300
- Sigstore integration time:
-
Permalink:
jim-wyatt/msn-weather-wrapper@74ce1172eaeb12e0ad3c251be806b12e766a0e1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jim-wyatt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
publish-release.yml@74ce1172eaeb12e0ad3c251be806b12e766a0e1e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file msn_weather_wrapper-2.0.2-py3-none-any.whl.
File metadata
- Download URL: msn_weather_wrapper-2.0.2-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ba331176916662468791b6189521b4aa6573255689ac5f8e1d0bc3edd96f657
|
|
| MD5 |
66233b42bb2802e40726f246d6315abd
|
|
| BLAKE2b-256 |
8ac6e8c161eb8864e39be06103d713f923da0c14808b35f796b7ec10ed091bcf
|
Provenance
The following attestation bundles were made for msn_weather_wrapper-2.0.2-py3-none-any.whl:
Publisher:
publish-release.yml on jim-wyatt/msn-weather-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msn_weather_wrapper-2.0.2-py3-none-any.whl -
Subject digest:
0ba331176916662468791b6189521b4aa6573255689ac5f8e1d0bc3edd96f657 - Sigstore transparency entry: 1214895447
- Sigstore integration time:
-
Permalink:
jim-wyatt/msn-weather-wrapper@74ce1172eaeb12e0ad3c251be806b12e766a0e1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jim-wyatt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
publish-release.yml@74ce1172eaeb12e0ad3c251be806b12e766a0e1e -
Trigger Event:
workflow_dispatch
-
Statement type: