ANNOUNCEMENTVoyage AI joins MongoDB to power more accurate and trustworthy AI applications on Atlas. Learn more >
NEWSLearn why MongoDB was named a leader in the 2024 Gartner® Magic Quadrant™ Read the report >
NEWMongoDB 8.0: Experience unmatched speed and performance. Check it out >

Solutions

Agentic AI-Powered Connected Fleet Incident Advisor

MongoDB helps automotive companies manage fleets of connected vehicles, optimize route planning, and improve driver safety.
Start Free
Agentic AI-Powered Connected Fleet Incident Advisor.
Solution Overview

The automotive and mobility industry is undergoing a significant transformation, driven by advancements in vehicle connectivity, autonomous systems, shared mobility, and electrification. Vehicles today are sophisticated machines that generate massive amounts of data. Automotive demand will grow by 3% annually in the next 20 years with increased preference towards connected and electric vehicles. Automotive players are embracing artificial intelligence (AI), battery electrical vehicles (BEVs) and software-defined vehicles (SDVs) to maintain their competitive advantage. The global connected vehicles market size is expected to be worth around USD 446.6 billion by 2033, growing at a CAGR of 19.5% between 2024 to 2033. Managing fleets of connected vehicles is a challenge. As cars get more sophisticated and integrated with internal and external systems, the volume of data greatly increases. This data needs to be stored, transferred, and consumed by various downstream applications to unlock new business opportunities. The global fleet management market is projected to reach USD 65.7 billion by 2030, growing at a rate of almost 10.8% annually.

A 2024 study conducted by Webfleet revealed that 32% of fleet managers believe AI and machine learning will significantly impact fleet operations in the coming years. It narrowly surpasses the 30% who cited EVs as the primary game-changer. Optimising route planning and improving driver safety are the two most commonly cited ways fleet managers believe AI will change their working day. As fleet management software providers continue to invest in AI, integrating agentic AI, autonomous systems capable of making real-time decisions, can significantly help with use cases like route optimization and driver safety enhancement. For example, AI agents can process real-time traffic updates and weather conditions to dynamically adjust routes, ensuring timely deliveries while advising drivers on their car condition as needed. This proactive approach contrasts with traditional reactive methods, improving vehicle utilization and reducing operational and maintenance costs.

An agent is an operational application that attempts to achieve a goal by observing the world and acting upon it using the data and tools it has at its disposal. The term "agentic" denotes having agency as an AI agent, proactively taking steps to achieve objectives without constant human oversight. For example, rather than just reporting an anomaly based on connected car telemetry data analysis, an agentic AI system for a connected fleet could autonomously cross-check that anomaly against known issues, decide whether it's critical or not, and schedule a maintenance appointment all on its own.

In this solution, we will build an AI-powered Connected Fleet Advisor built using MongoDB Atlas, Voyage AI, OpenAI, and LangGraph.

The system receives driver complaints or fleet manager queries, processes vehicle telemetry data, generates a chain-of-thought, performs a vector search for similar issues, persists the data in MongoDB, and finally produces a diagnostic recommendation using an OpenAI LLM.

Basic Components of an AI Agent
Basic Components of an AI Agent
Reference Architecture

The reference architecture shown below illustrates the inner workings and data flow of the AI agent. The workflow begins when a user (driver) query is received about a potential issue (for example hearing a knocking sound). This request is then processed by the LangGraph-based agent orchestrator, which uses an LLM (OpenAI GPT-4o) to interpret the request and create a chain of thought (CoT) reasoning and workflow. The workflow is then executed by the agent using tools such as Atlas Vector Search.

The agent processes an issue report by:

Reading telemetry data: Ingests vehicle sensor data from a CSV file (or an API in a production setup).

Generating an embedding: Uses Voyage AI embedding API to convert the complaint text into a numerical representation.

Atlas Vector Search: Searches for similar issues in MongoDB Atlas using the generated embedding.

Data persistence: Saves telemetry data, session logs, and recommendations in MongoDB Atlas.

Final recommendation: Uses OpenAI chat API to produce actionable diagnostic advice.

Reference Architecture of Solution
Reference Architecture of Solution
Data Modelling Approach

An agent requires different types of data to function. MongoDB’s document model allows you to easily model all of this data in one single database. Below you will find one example per different data type found in an agentic AI application for fleet management. Notice how the flexibility of the document model can be adapted to suit the type of data required to be stored.

Agent Profile

This contains the identity of the agent. It includes instructions, goals and constraints.

Example of an Agent Profile

Short Term Memory

This holds temporary, contextual information—recent data inputs or ongoing interactions—that the agent uses in real-time. For example, short-term memory could store sensor data from the last few hours of vehicle activity. In certain agentic AI frameworks like LangGraph, short term memory is implemented through a checkpointer. The checkpointer stores intermediate states of the agent’s actions and/or reasoning. This memory allows the agent to seamlessly pause and resume operations.

Example of short term memory - Telemetry data stored in Time Series Collections

Long-Term Memory

This is where the agent stores accumulated knowledge over time. This may include patterns, trends, logs, historical recommendations, and decisions.

Example of long term memory - historical issues with connected vehicles vectorized and stored in MongoDB

Building the Solution

The solution integrates several key technologies. To build this solution there are a few pre-requisities.

Prerequisites:
  • Python 3.11+ (backend)
  • Node.js (for the Next.js frontend)
  • MongoDB Atlas account
  • OpenAI API Key
  • Voyage AI API Key
Backend:

We implement a multi-step diagnostic workflow using LangGraph. The backend reads telemetry data from a CSV file (simulating vehicle sensor inputs), generates text embeddings using Voyage AI, performs vector searches to identify similar past issues from MongoDB, persists session and run data, and finally generates a diagnostic recommendation.

MongoDB Atlas:

The flexible document model database stores agent profiles, historical recommendations, telemetry data, session logs, and more. This persistent storage not only logs every step of the diagnostic process for traceability but also enables efficient querying and reusability of past data.

  • Next.js frontend: Provides a two-column view:
    • Left column: Displays the real-time agent workflow updates such as the chain-of-thought reasoning, update messages, and final recommendations.
    • Right column: Shows the documents inserted into MongoDB during the agent run, including session details, telemetry logs, historical recommendations, agent profiles and sample past issues.
System Architecture:
  • Backend workflow:
    • The agent receives a user’s issue report (e.g., "My vehicle’s fuel consumption has increased significantly over the past week. What might be wrong with the engine or fuel system?").
    • It first retrieves telemetry data (simulated here via a CSV file) and logs the update.
    • Next, it generates an embedding for the complaint using Voyage AI voyage-3-large embedding API.
    • The system then performs a vector search against historical issues in MongoDB to find similar cases.
    • All data (telemetry, embeddings, session logs) are persisted in MongoDB for traceability.
    • Finally, the agent uses OpenAI’s ChatCompletion API to produce a final recommendation.
  • MongoDB role:
    • MongoDB stores everything: the agent profile, session logs, telemetry data, historical recommendations, and even checkpoints. This makes the system highly traceable and scalable.
  • Frontend interface:
    • The two-column UI shows both the real-time workflow and the relevant MongoDB documents that validate each step.
Backend Setup

1. Clone the repository and navigate to the backend directory:

2. Create and activate a virtual environment:

3. Install dependencies:

4. Configure environment variables:

Create a .env file in the backend directory with the following content:

5. Run create_issue_embeddings.py to create and store embeddings in MongoDB.

6. Create a Atlas Vector Search index with name issues_index and path embeddings.

For more details on how to set up Vector Search index, go to this link

7. Run the backend server:

8. Frontend Setup

Navigate to the frontend directory and install dependencies:

9. Run the Next.js development server:

The frontend should now be accessible at http://localhost:3000.

10. Feel free to adjust the prompt in main.py or update the telemetry data in the telemetry_data.csv file.

Running the solution:
  • Starting a new diagnosis:
    • Open the frontend and choose “New Diagnosis.”
    • Enter an issue report in the text box (e.g., the sample complaint already shown).
    • Example prompts
      • I am hearing knocking sound while turning at low speeds.
      • My car is making a persistent rattling noise when I accelerate at low speeds.
      • I noticed a sudden drop in oil pressure along with a slight rise in engine temperature.
      • My vehicle’s fuel consumption has increased significantly over the past week. What might be wrong with the engine or fuel system?
      • A warning light recently appeared on my dashboard, and the car is struggling to accelerate.
    • Click the “Run Agent” button and wait for a a min or two as the agent finishes its run
  • Viewing workflow:
    • The workflow, chain-of-thought output, and the final recommendation is shown in the left column.
    • The workflow is being generated in real time, giving transparency into the agent's decision-making process.
  • Reviewing MongoDB documents:
    • In the right column, the documents shown are the records inserted during the current agent run.
      • agent_sessions: Contains session metadata and the thread ID.
      • historical_recommendations: Stores the final recommendations and related diagnostics.
      • telemetry_data: Holds the telemetry sensor readings.
      • logs: Contains log entries for the diagnostic process.
      • agent_profiles: Shows the agent's profile that was used during diagnosis.
      • past_issues: (If available) Displays a sample of historical issues.
      • checkpoints: (From the checkpointing database) Shows the last saved state for potential recovery.
  • Resume functionality:
    • Optionally, we can demonstrate the "Resume Diagnosis" feature by entering a thread ID and showing how the system retrieves the corresponding session.
Sequence Diagram of AI Agent Workflow
Sequence Diagram of AI Agent Workflow
Key Learnings

Building agentic AI solutions for mobility requires a robust data infrastructure. MongoDB Atlas offers several key advantages that make it an ideal foundation for these AI-driven architectures.

Scalability and flexibility: Connected car platforms such as fleet management systems need to handle extreme data volumes and variety. MongoDB Atlas easily scales horizontally across cloud clusters, letting you ingest millions of telemetry events per minute and store terabytes of telemetry data with ease. For example, ZF SCALAR uses MongoDB to process 90,000 vehicle messages per minute (over 50 GB of data per day) from hundreds of thousands of connected cars​. The document model seamlessly adapts as the fleet grows. Developers can evolve schemas as vehicles add new sensors or features. This flexibility accelerates development and ensures your data model stays aligned with the real-world entities (vehicles, trips, incidents) it represents.

Built-in vector search: AI Agents require a robust set of tools to work with. One of the most widely used tools is vector search, which allows the agent to perform semantic search on unstructured data such as driver logs, error codes descriptions, and repair manuals. MongoDB Atlas has native support for vector search, which allows you to store and index high-dimensional vectors alongside your operational data and perform fast similarity queries over them. In practice, this means your AI embeddings live right next to the relevant vehicle telemetry and operational data in the database. This drastically simplifies architectures for use cases like the connected car incident advisor, where an issue can be matched against past issues encountered before passing the context to LLM. (See how an automotive OEM leverages vector search for audio based diagnostics with MongoDB Atlas Vector Search.)

Time series collections and real-time data processing: MongoDB Atlas is designed for real-time applications. It provides time series collections for connected car telemetry data storage, change streams, and triggers that can react to new data instantly. Given that real-time visibility is a top feature in modern fleet management systems, MongoDB’s ability to serve fresh insights to the AI agents ensures the decisions they make are based on the latest information. This is crucial for agentic AI feedback loops, where ongoing data ingestion and learning are happening continuously.

Best-in-class embedding models with Voyage AI: MongoDB has recently acquired Voyage AI, a leader in embedding and reranking models. As Voyage AI embedding models get integrated in MongoDB Atlas, developers will no longer need to manage external embedding APIs, standalone vector stores, or complex search pipelines. AI retrieval will be built into the database itself, making semantic search, vector retrieval, and ranking as seamless as traditional queries. This will reduce the time required for developing Agentic AI applications.

Author
  • Humza Akhtar, MongoDB
Related Resources
general_content_developer

GitHub Repository: Fleet Incident Advisor Demo

Create this demo for yourself by following the instructions in this solution’s repository.

industry_ai

MongoDB for Generative AI

See how MongoDB can supercharge your AI journey.

cloud_iot

MongoDB for Internet of Things (IoT)

Learn how MongoDB’s modern database supports the entire IoT data life cycle.

Get started with Atlas

Get started in seconds. Our free clusters come with 512 MB of storage so you can experiment with sample data and get familiar with our services.
Try FreeContact sales
Illustration of hands typing on a laptop in the foreground and a superimposed desktop window and coffee cup in the background.