Learn how to transform flight operations with powerful real-time analytics. Cut costs, minimize delays, and boost efficiency through intelligent data monitoring.
Use cases: Analytics, IoT, Modernization, Single View
Industries: Manufacturing & Mobility
Products and tools: MongoDB Atlas, Aggregation Pipeline, Time Series Collections, MongoDB Change Streams
Partners: Google Cloud, Next.js, FastAPI , TensorFlow, Scikit-learn
Solution Overview
The real-time flight management solution enables airlines to proactively manage and mitigate costly flight delays. In 2019 alone, flight delays cost European airlines an average of €4,320 per hour per flight.
The solution leverages intelligent data handling and immediate response to provide real-time monitoring, predictive insights, and optimized resource allocation. It uses an event-driven architecture with:
FastAPI for simulation
GCP PubSub for messaging
Vertex AI for advanced analytics
Google Cloud Functions for serverless event-driven processing.
Built on MongoDB's flexible document model and time series collections, the solution offers a comprehensive approach to minimizing operational disruptions.
Figure 1. Components of an event-driven architecture
The solution delivers:
Reduced delay propagation: Real-time monitoring and immediate response capabilities help prevent delays from cascading through flight schedules.
Optimized resource allocation: Intelligent data analysis enables efficient reallocation of resources during disruptions.
Enhanced customer experience: Better disruption management leads to improved passenger satisfaction and loyalty.
Scalable operations: Flexible architecture supports growing data volumes and operational demands.
Real-time decision making: Immediate access to flight data enables quick and informed operational decisions.
Reference Architectures
The real-time flight management solution implements an event-driven architecture for delay management, which provides real-time monitoring, predictive insights, and resource optimization. The architecture consists of several key components:
1. Data generation and processing
FastAPI microservice housing Real-Time Data Simulator and Path Finder.
PubSub topics handling both static and real-time data streams.
Cloud Functions for processing application and telemetry data.
2. Analytics and cost management
Vertex AI Cost Calculator for financial impact analysis.
Analytical data creator Cloud Function for data transformation.
Aggregation pipeline for complex data processing.
3. Database structure
MongoDB database as the central data store.
Specialized collections:
flight_costscollection to track and analyze flight-related expenses.flight_planesimulation collection for predictive modeling and scenario planning.flight_realtimeCFcollection designed for real-time data tracking and historical analysis (Time Series Collection).flightscollection for comprehensive general flight information management.
4. Integration components
Change Streams for real-time data changes.
Google Maps API for visualizing geographical data.
Next.js for front-end interface and visualization.
As illustrated in Figure 2, this architecture enables the following data flows:
Operational data flow (blue lines): Handles real-time flight operations.
Analytical data flow (green lines): Manages business intelligence.
Internal connections (black lines): Maintains system integration.
Figure 2. Event-driven architecture
Build the Solution
For a detailed, step-by-step guide that implements this solution, including code samples and specific configuration instructions, visit this GitHub repository. This solution provides a scalable, event-driven architecture to manage flight operations and minimize delays and disruptions.
To implement the solution, follow these steps:
Configure GCP services
Deploy the application as a containerized service using Google Cloud’s Cloud Run.
Configure Google Cloud’s Cloud Build for automated deployments.
Set up Google Cloud’s Cloud Storage for assets.
Use Google Cloud Pub/Sub for real-time data distribution.
Implement Google Cloud’s Cloud Functions for data processing. The code snippet runs in a cloud function. When the system identifies a disruption, the function updates the new path obtained from the path finder algorithm. This feature ensures optimal rerouting, which minimizes fuel consumption and reduces costs.
import base64 import json from bson import ObjectId import os from pymongo import MongoClient import functions_framework # Triggered from a message on a Cloud Pub/Sub topic. def postPath(cloud_event): # Access URI in secrets MONGO_URI = os.environ.get('MONGO_URI', "MONGO_URI is not set.") MONGO_DATABASE = os.environ.get('MONGO_DATABASE', "MONGO_DATABASE is not set.") MONGO_COLLECTION = os.environ.get('MONGO_COLLECTION', "MONGO_COLLECTION is not set.") if not all([MONGO_URI, MONGO_DATABASE, MONGO_COLLECTION]): print("Error: One or more environment variables are not set.") return client = MongoClient(MONGO_URI) db = client[MONGO_DATABASE] collection = db[MONGO_COLLECTION] try: # Parse the data in the message byte_message = base64.b64decode(cloud_event.data["message"]["data"]) json_str = byte_message.decode('utf-8') data_dict = json.loads(json_str) print(data_dict) # Work with the dictionary fields flight_id = data_dict.get("flight_id") initial_path = data_dict.get("initial_path_airps") new_path = data_dict.get("new_path_airps") disruption_coords = data_dict.get("disruption_coords") # Check if all required fields are present if not flight_id: print("Error: flight_id is missing.") return if initial_path is None or new_path is None: print("Error: One or more path fields are missing.") return # Find the document in the MongoDB collection and update the path field result = collection.update_one( {"_id": ObjectId(flight_id)}, {"$set": { "initial_path": initial_path, "new_path": new_path, "disruption_coords": { "lat": disruption_coords[0], "long": disruption_coords[1] } }} ) if result.matched_count > 0: print("Document successfully updated.") else: print("No document found with the specified flight_number.") except Exception as e: print(f"Error updating document: {e}") finally: client.close()
Deploy Google Cloud’s Vertex AI for analytics. Ensure you obtain a Google Maps API Key for enhanced geospatial analysis and visualization.
After you follow these steps, your app should look like this:
Figure 3. Flight management dashboard with filters
Figure 4. Flight route and cost monitoring
Key Learnings
Utilize flexible models: MongoDB's flexible schema and time series collections provide a powerful foundation for flight operations. These features enable airlines to efficiently handle both pre-flight planning and telemetry data, while adapting to changing requirements.
Enable real-time monitoring: An event-driven architecture powered by MongoDB's integration with Google Cloud services, such as Pub/Sub, and Cloud Functions, enables immediate response to flight disruptions. By processing real-time data streams, this approach helps airlines minimize delays, which can cost an average of €4,320 per hour.
Obtain enhanced insights: MongoDB’s aggregation pipelines turn operational flight data into actionable insights, enabling airlines to optimize routes and resources. Google Cloud Vertex AI delivers predictive analytics that help airlines manage costs and delays.
Manage data efficiently: This solution shows how MongoDB handles diverse data types and workloads, from real-time telemetry collection to analytical processing. Its distributed architecture and change streams capabilities ensure consistent performance.
Authors
Dr. Humza Akhtar, MongoDB
Rami Pinto, MongoDB
Sebastian Rojas Arbulu, MongoDB