Topics: real-time-monitoring
weather-api
fastapi
react
websockets
prometheus
grafana
docker
postgresql
redis
jwt-auth
interactive-maps
email-notifications
sms-alerts
microservices
A comprehensive enterprise-grade real-time weather monitoring system with user authentication, interactive maps, multi-channel notifications, and advanced monitoring capabilities.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND LAYER β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β React SPA β Interactive β User Authentication β
β + Dashboard β Maps β + JWT Auth β
β + Charts β (Leaflet.js) β + Personal Settings β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β² β² β²
β WebSocket β REST API β Auth
β Real-time β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND LAYER β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β FastAPI β WebSocket β Prometheus Metrics β
β + JWT Auth β Manager β + System Monitoring β
β + REST APIs β + Real-time β + Performance Tracking β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β² β² β²
β β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA & MESSAGING LAYER β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β PostgreSQL β Redis β Notification Services β
β + User Data β + Pub/Sub β + Email (SMTP) β
β + Weather Data β + Caching β + SMS (Twilio) β
β + Alerts β + Sessions β + Real-time Alerts β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β² β² β²
β β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MONITORING & SCHEDULING LAYER β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β Weather Cron β Prometheus β Grafana β
β Scheduler β + Metrics β + Dashboards β
β + Auto Fetch β + Alerting β + Visualization β
β + Threshold β + Rules β + System Health β
β Detection β β β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β²
β
βββββββββββββββββββ
β OpenWeatherMap β
β API β
β + Weather Data β
β + Air Quality β
βββββββββββββββββββ
- JWT-based Authentication: Secure login/signup system
- Personal Dashboards: Customized user experience
- Custom Alert Thresholds: User-defined temperature, humidity, and AQI limits
- City Management: Add/remove favorite cities with interactive map
- Real-time WebSocket Alerts: Instant browser notifications
- Email Notifications: HTML-formatted alerts via SMTP
- SMS Alerts: Text message notifications via Twilio
- Bulk Notifications: Concurrent delivery for performance
- User Preferences: Toggle email/SMS per alert type
- Leaflet.js Integration: Interactive world map interface
- Weather Visualization: Real-time weather markers with conditions
- Click-to-Add Locations: Select any global location for monitoring
- User City Markers: Visual indicators for saved locations
- Reverse Geocoding: Automatic city name resolution
- Prometheus Metrics: System performance and API monitoring
- Grafana Dashboards: Real-time visualization and alerting
- System Health Tracking: CPU, memory, disk usage monitoring
- API Performance Metrics: Request rates, response times, error tracking
- Weather Data Analytics: Fetch success rates, alert statistics
- Interactive Charts: Temperature trends, humidity levels, AQI data
- Historical Analysis: Weather pattern analysis over time
- Real-time Updates: Live data refresh every 5 minutes
- Multi-city Comparison: Side-by-side weather comparisons
- Alert History: Comprehensive alert tracking and resolution
- FastAPI 0.104: High-performance async API framework
- WebSockets: Real-time bidirectional communication
- PostgreSQL 15: Robust relational database with user/weather data
- Redis 7: Caching, session management, and pub/sub messaging
- JWT Authentication: Secure token-based authentication
- Prometheus Client: Metrics collection and monitoring
- React 18.2: Modern component-based UI framework
- Leaflet.js: Interactive mapping and geolocation
- Recharts: Beautiful, responsive data visualization
- React Router: Client-side routing and navigation
- Axios: HTTP client for API communication
- React Toastify: User-friendly notification system
- Docker Compose: Multi-container orchestration
- Prometheus: Metrics collection and alerting
- Grafana: Advanced dashboards and visualization
- Node Exporter: System metrics collection
- AlertManager: Alert routing and management
- APScheduler: Automated weather data fetching
- OpenWeatherMap API: Weather and air quality data
- SMTP Email Service: Email notification delivery
- Twilio SMS: Text message alert delivery
- Reverse Geocoding: Location name resolution
weather-monitoring-system/
βββ backend/ # FastAPI Backend Service
β βββ app/
β β βββ api/ # REST API endpoints
β β β βββ auth.py # Authentication routes
β β β βββ weather.py # Weather data endpoints
β β β βββ alerts.py # Alert management
β β β βββ user_alerts.py # User custom alerts
β β βββ core/ # Core functionality
β β β βββ config.py # Configuration settings
β β β βββ database.py # Database connection
β β β βββ security.py # JWT authentication
β β β βββ metrics.py # Prometheus metrics
β β βββ models/ # Database models
β β β βββ weather.py # Weather & alert models
β β β βββ user.py # User & custom alert models
β β βββ services/ # Business logic
β β β βββ weather_service.py # Weather data processing
β β β βββ notification_service.py # Email/SMS notifications
β β βββ websocket/ # Real-time communication
β β βββ manager.py # WebSocket connection manager
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend container config
βββ frontend/ # React Frontend Application
β βββ src/
β β βββ components/ # React components
β β β βββ WeatherDashboard.js # Main dashboard
β β β βββ AlertPanel.js # Alert management
β β β βββ MapSelector.js # Interactive map
β β β βββ Login.js # Authentication
β β β βββ Register.js # User registration
β β βββ services/ # API communication
β β β βββ api.js # HTTP client
β β βββ hooks/ # Custom React hooks
β β β βββ useWebSocket.js # WebSocket hook
β β βββ App.js # Main application
β βββ package.json # Node.js dependencies
β βββ Dockerfile # Frontend container config
βββ scheduler/ # Weather Data Scheduler
β βββ weather_scheduler.py # Automated data fetching
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Scheduler container config
βββ monitoring/ # Monitoring Configuration
β βββ prometheus.yml # Prometheus config
β βββ alert_rules.yml # Alerting rules
β βββ alertmanager.yml # Alert manager config
βββ docker-compose.yml # Multi-service orchestration
βββ .env.example # Environment template
βββ README.md # Project documentation
- Docker & Docker Compose installed
- OpenWeatherMap API key (Get one here)
- Optional: Gmail app password for email alerts
- Optional: Twilio account for SMS alerts
# Clone the repository
git clone https://github.com/Brijes987/WeatherPulse.git
cd WeatherPulse
# Copy environment template
cp .env.example .env
# Edit .env with your API keys
nano .env # or use your preferred editor
# Minimum required in .env file:
OPENWEATHER_API_KEY=your_openweathermap_api_key_here
# Optional for notifications:
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_gmail_app_password
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token
TWILIO_PHONE_NUMBER=your_twilio_phone
# Start all services
docker-compose up --build
# Or run in background
docker-compose up -d --build
- π€οΈ Main Dashboard: http://localhost:3000
- π API Documentation: http://localhost:8000/docs
- π Grafana Monitoring: http://localhost:3001 (admin/admin)
- π Prometheus Metrics: http://localhost:9090
- β‘ System Metrics: http://localhost:8000/metrics
# Weather API (Required)
OPENWEATHER_API_KEY=your_api_key_here
# Database
DATABASE_URL=postgresql://weather_user:weather_pass@postgres:5432/weather_monitoring
# Redis Cache
REDIS_URL=redis://redis:6379
TEMP_HIGH_THRESHOLD=45.0 # High temperature alert (Β°C)
TEMP_LOW_THRESHOLD=-10.0 # Low temperature alert (Β°C)
HUMIDITY_HIGH_THRESHOLD=90.0 # High humidity alert (%)
AQI_HIGH_THRESHOLD=150 # Poor air quality alert
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_gmail_app_password
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your_auth_token
TWILIO_PHONE_NUMBER=+1234567890
- Sign Up: Create your account at http://localhost:3000
- Add Cities: Use the interactive map to select monitoring locations
- Set Alerts: Configure personal thresholds for temperature, humidity, AQI
- Monitor: View real-time data and receive instant notifications
- Click anywhere on the map to add a new monitoring location
- View real-time weather markers with current conditions
- Manage your saved cities and favorites
- Set personalized thresholds for each city
- Choose notification preferences (email/SMS)
- View alert history and resolution status
- Monitor temperature trends over time
- Compare weather data across multiple cities
- Track system performance and alert statistics
Access comprehensive monitoring at http://localhost:3001:
- System Health: CPU, memory, disk usage
- API Performance: Request rates, response times, errors
- Weather Metrics: Data fetch success rates, alert counts
- User Activity: Authentication, city additions, alert configurations
Key metrics available at http://localhost:9090:
weather_api_requests_total
- API request countsweather_api_request_duration_seconds
- Response timesweather_fetch_total
- Weather data fetch attemptsweather_alerts_total
- Generated alerts by typeweather_websocket_connections_active
- Active connections
Automated system alerts for:
- High API error rates (>10% for 2 minutes)
- Slow response times (>2 seconds for 5 minutes)
- Weather fetch failures (>20% for 5 minutes)
- High system resource usage (CPU >80%, Memory >85%)
POST /api/auth/register # User registration
POST /api/auth/login # User login
GET /api/auth/me # Get user profile
GET /api/weather/current/{city} # Current weather
GET /api/weather/history/{city} # Historical data
GET /api/weather/latest # Latest readings
GET /api/alerts/ # Get alerts
PUT /api/alerts/{id}/resolve # Resolve alert
GET /api/alerts/stats # Alert statistics
POST /api/user/cities # Add user city
GET /api/user/cities # Get user cities
POST /api/user/alerts # Create custom alert
GET /api/user/alerts # Get user alerts
# Check Docker status
docker-compose ps
# View logs
docker-compose logs backend
docker-compose logs frontend
# Reset database
docker-compose down -v
docker-compose up -d postgres
docker-compose up backend
- Verify OpenWeatherMap API key is valid
- Check API key has sufficient quota
- Ensure .env file is properly formatted
- For Gmail: Use app-specific password, not regular password
- For Twilio: Verify account SID and auth token
- Check phone number format (+1234567890)
- JWT Tokens: Secure authentication with configurable expiration
- Password Hashing: Bcrypt encryption for user passwords
- API Rate Limiting: Built-in protection against abuse
- CORS Configuration: Controlled cross-origin access
- Environment Variables: Sensitive data stored securely
docker swarm init
docker stack deploy -c docker-compose.yml weather-stack
# Convert docker-compose to k8s manifests
kompose convert
kubectl apply -f .
- AWS: Use ECS/EKS with RDS and ElastiCache
- GCP: Deploy on GKE with Cloud SQL and Memorystore
- Azure: Use AKS with Azure Database and Redis Cache