clarion-app / weather-backend
Fetchs and store weather data. Provides endpoints for frontend weather app.
Requires
- clarion-app/backend: dev-main
- clarion-app/eloquent-multichain-bridge: dev-main
This package is auto-updated.
Last update: 2025-06-20 15:26:46 UTC
README
A Laravel package that fetches and stores weather data, providing comprehensive weather forecasting endpoints for frontend applications. This backend integrates with weather APIs (like OpenWeatherMap) to deliver current conditions, forecasts, alerts, and minutely precipitation data.
Features
- Multi-Location Support: Manage multiple weather locations with favorites and active status
- Comprehensive Weather Data: Current, hourly, daily, and historical weather information
- Weather Alerts: Store and manage weather alerts with severity levels and acknowledgment
- Minutely Precipitation: Detailed precipitation forecasts for the next hour
- Geocoding Integration: Location search and creation from coordinates
- Multiple Weather APIs: Support for multiple weather service providers
- Data Cleanup: Automated cleanup of old weather data
- Background Jobs: Asynchronous weather data updates via Laravel queues
- REST API: Full RESTful API with authentication
Database Schema
The package creates the following database tables:
- weather_apis: Configuration for weather service providers
- weather_locations: Geographic locations for weather monitoring
- weather_data: Current, hourly, daily, and historical weather data
- weather_alerts: Weather warnings and alerts
- weather_minutely: Minute-by-minute precipitation forecasts
API Endpoints
Weather APIs Management
GET /weather-apis
- List all weather APIsPOST /weather-apis
- Create new weather API configurationGET /weather-apis/{id}
- Get specific weather APIPUT /weather-apis/{id}
- Update weather API configurationDELETE /weather-apis/{id}
- Delete weather APIPATCH /weather-apis/{id}/activate
- Activate weather APIPATCH /weather-apis/{id}/deactivate
- Deactivate weather APIGET /weather-apis/active
- Get active weather APIs
Location Management
GET /locations
- List all locationsPOST /locations
- Create new locationGET /locations/{id}
- Get specific locationPUT /locations/{id}
- Update locationDELETE /locations/{id}
- Delete locationGET /locations/active
- Get active locationsGET /locations/favorites
- Get favorite locationsGET /locations/nearby
- Find nearby locationsGET /locations/search-geocode
- Search locations by geocodingPOST /locations/from-geocode
- Create location from geocode dataPATCH /locations/{id}/activate
- Activate locationPATCH /locations/{id}/deactivate
- Deactivate locationPATCH /locations/{id}/favorite
- Add location to favoritesDELETE /locations/{id}/favorite
- Remove location from favorites
Weather Data
GET /weather-data
- List all weather dataPOST /weather-data
- Create weather data entryGET /weather-data/{id}
- Get specific weather dataPUT /weather-data/{id}
- Update weather dataDELETE /weather-data/{id}
- Delete weather dataGET /weather-data/{locationId}/current
- Get current weather for locationGET /weather-data/{locationId}/hourly
- Get hourly forecast for locationGET /weather-data/{locationId}/daily
- Get daily forecast for locationGET /weather-data/{locationId}/historical
- Get historical data for locationPOST /weather-data/cleanup
- Clean up old weather data
Weather Alerts
GET /weather-alerts
- List all weather alertsPOST /weather-alerts
- Create weather alertGET /weather-alerts/{id}
- Get specific weather alertPUT /weather-alerts/{id}
- Update weather alertDELETE /weather-alerts/{id}
- Delete weather alertGET /weather-alerts/{locationId}/active
- Get active alerts for locationGET /weather-alerts/statistics
- Get alert statisticsGET /weather-alerts/severity/{severity}
- Get alerts by severityPATCH /weather-alerts/{id}/acknowledge
- Acknowledge alertPATCH /weather-alerts/{id}/resolve
- Resolve alertPOST /weather-alerts/cleanup
- Clean up old alerts
Minutely Precipitation
GET /weather-minutely
- List minutely dataPOST /weather-minutely
- Create minutely dataGET /weather-minutely/{id}
- Get specific minutely dataPUT /weather-minutely/{id}
- Update minutely dataDELETE /weather-minutely/{id}
- Delete minutely dataGET /weather-minutely/{locationId}/next-hour
- Get next hour precipitationGET /weather-minutely/{locationId}/precipitation
- Get precipitation dataGET /weather-minutely/{locationId}/recent
- Get recent minutely dataPOST /weather-minutely/bulk
- Bulk create minutely dataPOST /weather-minutely/cleanup
- Clean up old minutely data
OpenWeatherMap Integration
POST /openweathermap/fetch-current
- Fetch current weather from OpenWeatherMapPOST /openweathermap/fetch-complete
- Fetch complete weather dataPOST /openweathermap/fetch-historical
- Fetch historical weather data
Commands
Weather Update Command
Update weather data for all active locations:
php artisan weather:update
This command dispatches a job to update weather data asynchronously via Laravel's queue system.
Configuration
The package integrates with the Clarion framework and includes custom prompts for AI-assisted operations:
- Choose Operations: Guides users to first get location IDs, then fetch weather data
- Generate API Calls: Provides context for proper API parameter usage
Models
- WeatherApi: Weather service provider configurations
- WeatherLocation: Geographic locations with coordinates and metadata
- WeatherData: Weather measurements and forecasts
- WeatherAlert: Weather warnings and notifications
- WeatherMinutely: Minute-by-minute precipitation data
Jobs
- WeatherDataUpdate: Background job for updating weather data from external APIs
Authentication
All API endpoints require authentication via Laravel's auth:api
middleware.
Units Support
The package supports different unit systems for temperature, wind speed, and other measurements, configurable per location.
Data Retention
The package includes cleanup functionality to manage data retention and prevent database bloat from historical weather data.
License
MIT License
Author
Tim Schwartz (tim@metaverse.systems)