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 Next.js 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 FastAPI service with built-in OpenAPI docs
- Web Frontend - Modern Next.js 16 + React 19 + TypeScript 6
- 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: Next.js 16, React 19.2, TypeScript 6+
- Testing: pytest 9.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:3000
# 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:
backend/msn_weather_wrapper/โ backend logic and the FastAPI appfrontend/โ the Next.js UItests/โ examples of expected behaviorscripts/โ 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
- ๐ 463+ 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 24+ (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:3000
Features: City autocomplete (463+ 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 backend/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
- 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/
โโโ backend/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:
- โ
All tests pass:
pytest - ๐จ Code is formatted:
ruff format . - ๐ Type checks pass:
mypy backend/ - ๐ช 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.4.tar.gz.
File metadata
- Download URL: msn_weather_wrapper-2.0.4.tar.gz
- Upload date:
- Size: 386.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 |
4fec9ffaa013e553bd9ef72f380c4993e96ec20a83c8556a19332a87d42d4743
|
|
| MD5 |
800970d72bcc5609d3cb7d074f43c503
|
|
| BLAKE2b-256 |
5f7f449eb4a95a40ff7d0c5b9dc5e4a97458687416de7ed44052fca6f6a4b989
|
Provenance
The following attestation bundles were made for msn_weather_wrapper-2.0.4.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.4.tar.gz -
Subject digest:
4fec9ffaa013e553bd9ef72f380c4993e96ec20a83c8556a19332a87d42d4743 - Sigstore transparency entry: 1280943284
- Sigstore integration time:
-
Permalink:
jim-wyatt/msn-weather-wrapper@9a36eb1a04203ebb74930284450fc4e3700e5299 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jim-wyatt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@9a36eb1a04203ebb74930284450fc4e3700e5299 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file msn_weather_wrapper-2.0.4-py3-none-any.whl.
File metadata
- Download URL: msn_weather_wrapper-2.0.4-py3-none-any.whl
- Upload date:
- Size: 23.2 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 |
8b60230ccbbdafa220209064272c7fc441a851205b3b3ed4b4a340843517fb81
|
|
| MD5 |
fd1c72739403a47c26ccbc93efd9c557
|
|
| BLAKE2b-256 |
3ee323875b94b95b3ab4101e584139b4b915f619eda3eb97b013c116d13bd0f6
|
Provenance
The following attestation bundles were made for msn_weather_wrapper-2.0.4-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.4-py3-none-any.whl -
Subject digest:
8b60230ccbbdafa220209064272c7fc441a851205b3b3ed4b4a340843517fb81 - Sigstore transparency entry: 1280943286
- Sigstore integration time:
-
Permalink:
jim-wyatt/msn-weather-wrapper@9a36eb1a04203ebb74930284450fc4e3700e5299 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jim-wyatt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@9a36eb1a04203ebb74930284450fc4e3700e5299 -
Trigger Event:
workflow_dispatch
-
Statement type: