For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

AI-Powered Track and Trace for Manufacturing

Transform unstructured factory floor data into audit-ready traceability records. Meet EPCIS 2.0 and EU Digital Product Passport requirements in real time.

Use cases: Agentic AI, Single View

Products: MongoDB Atlas, Atlas Stream Processing

Partners: Amazon Web Services

Track and trace is the practice of recording every event in a product's journey, from raw materials sourcing through manufacturing, distribution, and delivery, into a connected, auditable timeline.

The global track and trace market is projected to reach $12 billion by 2030. Three regulatory deadlines are forcing manufacturers to move:

  • US DSCSA: Requires item-level drug serialization to trace every prescription drug through the supply chain.

  • EU Battery Passport: Requires manufacturers to document the full lifecycle of EV and industrial batteries by February 2027.

  • EU Digital Product Passport: Requires a verifiable digital record for all products sold in the EU by 2030.

Each of these mandates shares the same requirement: manufacturers must prove, at any point in time, exactly where a product has been and what happened to it. The cost of falling short is high. For example, medical device recalls rose 8.6% year over year in 2024, and a single pharma recall can cost up to $600 million.

Meeting these requirements depends on data, and most manufacturers already generate it. The problem is that 90% of it never gets used. It sits in fragmented silos: free-text operator logs, inconsistent timestamps, and mixed measurement units that traditional ETL pipelines cannot handle without rigid schemas and brittle parsing rules. By the time data gets cleaned and structured, the window to prevent a recall or meet a compliance deadline has already closed.

The gap between fragmented factory data and compliance-ready records is an engineering problem. This solution closes it by connecting raw factory floor events to a structured, queryable product history using MongoDB Atlas and AWS Bedrock.

Raw factory floor events land in MongoDB as they arrive, then move through an AI cleaning pipeline powered by AWS Bedrock. The pipeline normalizes each event into a structured, EPCIS 2.0-compliant record. The complete product journey lives in a single document, so a compliance auditor or supply chain manager retrieves the full chain of custody in one read, with no joins and no separate system to query.

Regulated industries already run this architecture at scale:

  • McKesson traces 1.2 billion pharmaceutical serial numbers per year and met its DSCSA federal deadline on MongoDB Atlas.

  • GE HealthCare cuts data retrieval time by 83% using Change Streams and Atlas Search.

  • Bosch tracks 6 million fastening events per aircraft with a full FAA-compliant audit trail.

The proposed architecture relies on the following components:

  • MongoDB Atlas serves as the unified data platform.

  • AWS Bedrock handles AI reasoning.

  • A Next.js web application surfaces the product journey in real time.

Track and Trace solution architecture

Figure 1. Track and Trace solution architecture

The workflow begins when factory floor events land in MongoDB with no validation or preprocessing. Next, Atlas Stream Processing routes each event to a processing queue. From there, a Change Stream triggers AWS Bedrock, which normalizes the unstructured raw text into a structured, EPCIS 2.0-compliant record. Finally, MongoDB stores the cleaned event and updates the product's journey document, completing the entire process within seconds.

The full product history lives in a single document. The web application retrieves the complete chain of custody in one query, with no joins.

A product document in MongoDB starts simple and grows with every manufacturing stage. The two documents below show that evolution.

Factory floor events arrive exactly as operators write them without validation and preprocessing.

{
"text": "ALERT | BATCH-GM005-037 | ShenZhn WH | 06:15:00Z - rcvd \n raw mat'ls from Tianhe Biosci. Qty: 1000u glucose oxidase. \n Temp: 4.2C avg. Purity: 99.3%. 12 units MISSING — QA hold \n ref#QH-2024-001.",
"stage": "Raw Materials Sourcing",
"_timestamp": "2025-01-15T06:15:00.000Z"
}

After processing, the cleaned event updates the product document. Every manufacturing stage appends a new entry to the journey array. The complete chain of custody lives in one place, as shown below.

{
"_id": "GM-005",
"productName": "Continuous Glucose Monitor",
"status": "in_production",
"currentStage": "Enzyme Coating",
"journey": [
{
"stage": "Raw Materials Sourcing",
"status": "completed",
"location": "Shenzhen, CN",
"startTime": "2025-01-15T06:15:00.000Z",
"eventCount": 3
},
{
"stage": "Electrode Fabrication",
"status": "completed",
"location": "Penang, MY",
"startTime": "2025-01-16T07:00:00.000Z",
"eventCount": 4
},
{
"stage": "Enzyme Coating",
"status": "in_progress",
"location": "Penang, MY",
"startTime": "2025-01-17T08:00:00.000Z",
"eventCount": 1
}
]
}

Follow the steps in the GitHub repository's README to replicate this solution.

1

Ensure you meet the following requirements:

  • Node.js 18 or higher

  • A MongoDB Atlas cluster (M10 or larger) with Stream Processing enabled

  • AWS account with Bedrock access (Claude Haiku enabled in your region)

2

Use the following commands to set up your project:

git clone https://github.com/mongodb-industry-solutions/track-and-trace.git
cd track-and-trace
npm install
3

Copy the .env.example file to the .env file, then add your credentials:

MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/
DATABASE_NAME=track-and-trace
AWS_ACCESS_KEY_ID=<your-access-key>
AWS_SECRET_ACCESS_KEY=<your-secret-key>
AWS_REGION=us-east-1
4

Follow the instructions in the repository to create a Stream Processing instance, configure the Atlas source and sink connections, and deploy the pipeline.

5

Run the following command to populate the database:

npm run seed
6

Launch the application locally by running the following command:

npm run dev

Navigate to http://localhost:8080 and click Start Simulation to begin processing events through the pipeline.

  • Decouple ingestion from processing: Raw events land in MongoDB immediately, regardless of downstream load. Atlas Stream Processing handles routing independently, keeping the ingestion layer fast and simple.

  • Use Change Streams to build reactive AI pipelines: A Change Stream triggers AI processing the moment each event arrives, removing the need for polling or message queues with zero risk of missed events.

  • Accept any schema at ingestion; enforce structure at output: The ingestion layer operates without validation; instead, structure is enforced at the AI cleaning pipeline, where every event gets normalized to EPCIS 2.0 before writing to the events collection.

  • Embed the journey, not just the latest state: Every stage, location, and anomaly lives in a single product document, enabling compliance auditors to retrieve the full chain of custody in one read, without any joins.

  • Transform messy data into usable information with AI: An AI-driven cleaning pipeline can handle abbreviations, typos, inconsistent units, and missing fields. When standards change, you can update the prompt, instead of rewriting complex ETL code.

  • Humza Akthar, MongoDB

  • Javier Guajardo, MongoDB