The Problem That Wouldn’t Leave Me Alone

Organizations rarely lose money in dramatic, obvious failures.

They lose it quietly.

A hospital orders insulin that expires unused in storage.
A factory runs heavy equipment overnight without production scheduled.
An office building cools nearly empty floors.
A retailer reorders products that haven’t moved in months.

Each incident seems minor on its own. Across departments and quarters, they compound into millions of dollars of loss.

What bothered me most wasn’t the waste itself, it was the delay.

Traditional audits are slow and fragmented. They review one department at a time, take weeks to complete, and deliver findings only after the money is already gone. By the time a report lands on someone’s desk, the damage is done.

The data to prevent this already exists inside organizations.
What’s missing is immediate visibility.

That gap is what inspired Ghost Economy Hunter.

The Question That Started Everything

What if organizations didn’t have to wait?

What if a system could continuously examine operational data and:

  • Scan every dataset automatically
  • Detect anomalies in minutes instead of weeks
  • Translate those anomalies into real dollar impact
  • Alert decision-makers immediately
  • Work on any dataset without manual configuration

That question became the mission.

What I Built

Ghost Economy Hunter is a multi-agent AI system that detects hidden financial waste across an organization’s operational data and converts it into defensible dollar impact in under four minutes.

You run one command.

Four specialized agents begin collaborating.

The System Architecture

1. Cartographer

Cartographer automatically discovers and maps any dataset it is given.

There are no predefined templates and no assumptions about schema.
It inspects field names, data types, timestamps, units, and relationships, then produces a structured schema manifest for downstream analysis.

This allows the system to work on unfamiliar datasets without manual preparation.

2. Pattern Seeker

Pattern Seeker performs the actual anomaly detection.

Instead of exporting data into an external analytics engine, it dynamically generates and executes ES|QL queries directly inside Elasticsearch. The queries are written based on the schema discovered by Cartographer, allowing detection logic to adapt as data changes.

This approach enables anomaly detection across:

  • Healthcare procurement
  • Manufacturing and IoT telemetry
  • Energy consumption
  • Retail inventory behavior

Detection scales with the Elasticsearch cluster itself, not the application server.

3. Valuator

Finding anomalies is not enough they must be translated into financial impact.

Valuator converts each detected anomaly into a precise dollar figure using normalized pricing indices derived from authoritative public sources, including:

  • Medicare Part B Average Sales Price
  • National Average Drug Acquisition Cost
  • Bureau of Labor Statistics Producer Price Index
  • Energy Information Administration electricity rates

Every calculation is traceable, timestamped, and defensible. There is no opaque estimation.

4. Action Taker

Action Taker turns analysis into outcomes.

It scores findings by confidence, triggers alerts, and writes structured audit trails. Each alert includes what was found, why it matters, how the dollar impact was calculated, and where the data came from.

Nothing is hidden. Every decision is explainable.

Orchestration & Transparency

A central orchestration pipeline manages structured handoffs between agents to ensure deterministic behavior and reliability.

The entire workflow streams live to a dashboard using Server-Sent Events. Users can observe not only what was detected, but how and why each conclusion was reached.

This is not a black box.
It is transparent, auditable AI.

Real Data, Real Constraints

I deliberately avoided synthetic demo datasets.

Instead, the system was tested against real-world data, including:

  • Municipal energy disclosure records
  • Retail inventory exports
  • Healthcare procurement patterns
  • Factory IoT telemetry

Real data exposed real problems: missing fields, inconsistent units, schema drift, and incomplete timestamps. Designing for those edge cases is what made the system robust.

The Hardest Challenges

1. Schema-Agnostic Intelligence

Most anomaly detection systems assume known field structures. Building Cartographer to reliably interpret unknown schemas was the most time-intensive and critical design challenge.

2. Dynamic ES|QL Generation

Pattern Seeker does not run static queries. It generates ES|QL dynamically based on discovered schemas.

Ensuring that those queries were syntactically valid, analytically meaningful, and efficient required repeated architectural refinement.

3. Pricing Data Normalization

Government pricing datasets vary widely in format and update cadence. Normalizing them into a single pricing index was essential — every dollar calculation depends on that integrity.

There was zero room for error.

4. Multi-Agent Orchestration

Strong individual agents are not enough.

The real challenge was designing reliable handoffs, deterministic outputs, race-condition avoidance, and resilient SSE streaming. In multi-agent systems, orchestration matters more than raw intelligence.

What I Learned

  • Databases are underused analytical engines. Pushing detection logic directly into Elasticsearch transforms infrastructure into intelligence.
  • Multi-agent systems succeed or fail at the interfaces. Structured outputs matter more than creativity.
  • Real-world data is messy and that’s where robustness is built.
  • Interoperable AI agents are not theoretical. With modern agent-to-agent and protocol-based coordination, explainable and production-ready systems are achievable today.

Ghost Economy Hunter reduces time to insight from weeks to minutes. It turns hidden operational waste into immediate, actionable financial intelligence while keeping every decision transparent and auditable.

This isn’t about finding anomalies.

It’s about stopping quiet losses before they become permanent.

Built With

Share this project:

Updates