How picred/air-quality-monitor works
This is a real-time air-quality monitoring application: city observations are fetched and cleaned, streamed through Logstash/Kafka, scored by a Spark model, indexed in Elasticsearch, and presented in Kibana. It also documents historical-data preparation and model retraining. The sampled source establishes ingestion and Spark behavior; the README and repository configuration identify the broker, Logstash, Elasticsearch, and dashboard capabilities, but their wiring is not fully shown in excerpts.
Main entry points: ingestion_manager.py Live ingestion · app.py Stream processor · train_model.py Model training · retrieve_data.py City lookup
Components 18
Data ingestion
- Live ingestion
ingestion_manager/ingestion_manager.py - City lookup
ingestion_manager/utils/retrieve_data.py - Observation cleanup
ingestion_manager/utils/extract_data.py - Ingestion config
ingestion_manager/utils/setup.py - Historical import
ingestion_manager/utils/save_old_data.py - CSV writer
ingestion_manager/utils/csv_handler.py - Logstash sender
ingestion_manager/utils/logstash_handler.py
Event streaming
- Logstash pipeline
logstash/pipeline/from_python_to_kafka.conf - Kafka topic
kafka/conf/server.properties
Analytics
- Stream processor
spark/code/app.py - AQI prediction model
spark/model - Model training
spark/code/train_model.py - Historical observations
ingestion_manager/data/historical_data.csv - Elasticsearch index
Visualization
- Kibana dashboard
kibana/kibana_dashboard.ndjson
Other components
- Operator
- OpenWeather API
- Nominatim
Connections 19
- Operator → Live ingestion: starts ingestion
README.md - Live ingestion → Ingestion config: reads settings
ingestion_manager/ingestion_manager.py - Live ingestion → City lookup: resolves cities
ingestion_manager/ingestion_manager.py - City lookup → Nominatim: geocodes misses
ingestion_manager/utils/retrieve_data.py - Live ingestion → OpenWeather API: requests readings
ingestion_manager/ingestion_manager.py - Live ingestion → Observation cleanup: cleans response
ingestion_manager/ingestion_manager.py - Live ingestion → Logstash sender: sends observations
ingestion_manager/ingestion_manager.py - Logstash sender → Logstash pipeline: ships events
- Logstash pipeline → Kafka topic: publishes events
- Kafka topic → Stream processor: streams records
spark/code/app.py - Stream processor → AQI prediction model: loads model
spark/code/app.py - Stream processor → Elasticsearch index: indexes predictions
spark/code/app.py - Elasticsearch index → Kibana dashboard: supplies dashboard data
README.md - Operator → Historical import: prepares history
README.md - Historical import → CSV writer: writes rows
ingestion_manager/utils/save_old_data.py - CSV writer → Historical observations: stores training rows
- Operator → Model training: re-trains model
README.md - Model training → Historical observations: loads dataset
- Model training → AQI prediction model: saves model