A modern, production-ready Python wrapper for MSN Weather with a FastAPI backend and React frontend.
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
git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
podman-compose up -d
# Access at http://localhost:8080pip install msn-weather-wrapperfrom 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")./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/healthIf you're learning the codebase, explore it in this order:
src/msn_weather_wrapper/β backend logic and the FastAPI appfrontend/β the React UItests/β examples of expected behaviorscripts/β helper commands for setup, reports, and deployment tasks
A detailed walkthrough now lives in
docs/PROJECT_STRUCTURE.md.
- π€οΈ 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
- Python 3.10+
- Node.js 20+ (for frontend development)
- Podman or Docker (for containerized deployment)
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 installfrom 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}%")# 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"}'cd frontend
npm install
npm run dev # http://localhost:5173Features: City autocomplete (406+ cities), temperature unit toggle (Β°C/Β°F), geolocation support, responsive design, WCAG 2.1 Level AA accessibility
# 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# 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-wrapperArchitecture: Unified container (Python + Node.js), Nginx reverse proxy, Gunicorn with Uvicorn workers, and Kubernetes-ready health checks
π 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
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
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.
MIT License - see LICENSE for details.
- π Documentation
- π¦ PyPI Package
- π Issue Tracker
- π¬ Discussions
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.