Inspiration

Halal certification depends heavily on trust, documentation, and proper handling throughout the food-manufacturing procedure. One area we became especially interested in was shared processing equipment, where the same production line may be used for both halal and non-halal products.

The challenge is not simply whether a cleaning procedure was recorded as completed, but whether the line was actually cleaned effectively before halal production began.

That led us to ask a simple question:

What if a cleaning cycle could provide verifiable, sensor-based data to prove the line is clean?

HalalTrace was created to turn cleaning verification from a paperwork-based process into a measurable and auditable one.

That led us to ask a simple question:

What if a cleaning cycle could produce actual sensor-based proof that the line was clean?

HalalTrace was created to turn cleaning verification from a paperwork-based process into a measurable and auditable one.

What it does

HalalTrace is an IoT-based cleaning verification system for shared halal and non-halal food-processing lines.

During a cleaning cycle, the system monitors two key measurements:

  • Turbidity, which helps determine whether the rinse water has cleared and residual material has been removed.
  • Temperature, which verifies whether the sanitation process reached the required thermal conditions.

Instead of looking at only one measurement, HalalTrace analyzes the full cleaning cycle and determines whether it should PASS or FAIL.

Each cycle is associated with a specific production line and cycle ID, and the result can include the verdict, confidence level, sensor readings, and timestamp. The goal is to create a digital audit trail that halal certifiers or facility operators can review later. :contentReference[oaicite:1]{index=1}

The dashboard also allows users to monitor sensor readings during the cleaning process and review previous cleaning-cycle records.

How we built it

We built HalalTrace as a complete sensor-to-certification pipeline, connecting real-world hardware, IoT communication, machine learning, backend infrastructure, and a live web dashboard into one system.

The process starts at the production line. An ESP32 collects live readings from two sensors: a turbidity sensor that measures how clear the rinse water becomes, and a DS18B20 temperature sensor that verifies whether the sanitation cycle reaches the required thermal conditions.

Rather than treating each sensor reading independently, every measurement is tagged with a line_id, cycle_id, and timestamp. This lets HalalTrace understand an entire cleaning cycle as one verifiable event instead of just a stream of numbers.

The ESP32 sends the readings to our FastAPI backend, which buffers the data throughout the cleaning cycle. When the cycle ends, the backend transforms the raw sensor readings into meaningful features such as:

  • turbidity peak and decline rate
  • time required for the rinse water to clear
  • area under the turbidity curve
  • peak temperature
  • time spent above the sanitation threshold
  • the relationship between temperature and turbidity throughout the cycle

This is where our machine-learning layer comes in.

Instead of relying on a single hard-coded threshold, HalalTrace analyzes the shape and behavior of the entire cleaning cycle. Our classifier uses these features to determine whether the cycle should PASS or FAIL, while also returning a confidence score and the factors that influenced the result. :contentReference[oaicite:0]{index=0}

We also designed the two sensor signals to work together. Clear water alone is not enough if the correct sanitation temperature was never reached, and high temperature alone does not prove that residue was actually removed. By evaluating both signals together, the system provides a much stronger verification of whether the cleaning process was actually completed successfully. :contentReference[oaicite:1]{index=1}

Once the cycle is classified, the result is stored in a SQLite audit log along with the line ID, cycle ID, timestamp, sensor data, extracted features, verdict, and confidence score. This transforms the system from a simple IoT monitor into an auditable verification tool. :contentReference[oaicite:2]{index=2}

On the frontend, we built a React dashboard that lets operators and certifiers watch cleaning cycles in real time. It displays live turbidity and temperature data, the current cycle status, the final PASS/FAIL verdict, confidence level, and a history of previous cleaning cycles. :contentReference[oaicite:3]{index=3}

The final architecture became:

Sense → Stream → Analyze → Verify → Record

What makes HalalTrace powerful is that every layer works toward the same goal: turning a physical cleaning process into digital, timestamped evidence that can actually be reviewed and audited.

Instead of asking someone to trust that a production line was cleaned, HalalTrace gives them the data to prove it.

Challenges we ran into

One of our biggest challenges was getting the machine learning pipeline, backend, and frontend to work together as one reliable system.

Each part of HalalTrace was being developed independently, but the final product depended on all three layers agreeing on the same data formats, cycle states, API responses, and outputs. Small inconsistencies between the ML model, backend payloads, and frontend expectations could break the entire pipeline, so a major part of our work was designing a clean contract between every component.

Another challenge was deciding how to store very different types of data without overcomplicating the architecture. HalalTrace generates structured audit information, time-series sensor readings, extracted ML features, and prediction results.

For a hackathon, we wanted to keep the infrastructure simple, so we designed everything around a single SQLite3 relational database. Important audit fields such as cycle ID, line ID, timestamps, verdicts, and confidence scores are stored in dedicated columns, while more complex data such as sensor readings and extracted ML features are serialized as JSON dictionaries. This gave us the simplicity of one database while still allowing us to store flexible ML and time-series data.

We also had to safely handle repeated requests and multiple cleaning cycles occurring over time. Sensor readings are constantly being sent to the backend, and without a clear way to separate them, readings from different cleaning cycles could overwrite each other or create conflicting audit records.

To solve this, every cleaning session receives a unique cycle ID. Every sensor reading, ML prediction, and audit record is tied to that cycle ID, allowing the backend to isolate each cleaning event and prevent data from different cycles from being mixed together.

Another major challenge was making the ML integration resilient. During development, the backend could not assume that trained model artifacts would always exist or that incoming data would always arrive in exactly the expected format.

We therefore designed the ML layer to fail safely. The backend validates incoming data, handles missing or incompatible ML artifacts, and avoids allowing a model-loading or formatting issue to crash the entire verification pipeline.

These challenges pushed us to think beyond simply making the demo work. We had to think about data consistency, fault tolerance, concurrency, storage design, and system integration — the same kinds of problems that would matter if HalalTrace were deployed in a real facility.

Accomplishments that we're proud of

We're proud that HalalTrace became more than just a sensor-monitoring prototype. We built a complete end-to-end verification pipeline that connects data collection, machine learning, backend processing, database storage, and a live web dashboard into one system.

One of our biggest accomplishments was building a machine-learning pipeline around 160 labeled cleaning cycles representing clean, contaminated, and under-temperature scenarios. Our model achieved 87.5% accuracy and 96.7% recall on failed-cycle detection, which was especially important to us because missing an unsafe cleaning cycle is much more serious than incorrectly flagging one for review. :contentReference[oaicite:0]{index=0}

We're also proud of turning each cleaning cycle into something that can actually be reviewed later. Instead of only displaying live sensor values, HalalTrace produces a PASS/FAIL verdict with confidence and stores the result as part of an audit record that can be displayed directly on the dashboard. :contentReference[oaicite:1]{index=1}

Most importantly, we built the project around a real problem instead of adding technology for its own sake. HalalTrace takes a process that can rely heavily on manual verification and turns it into something measurable, traceable, and easier for a certifier to audit.

What we learned

We learned that building HalalTrace was not just about creating an ML model or connecting a few sensors — the hardest part was making hardware, data processing, machine learning, backend logic, storage, and the dashboard all work together as one system.

We also learned how important data structure and feature engineering are. Instead of feeding raw readings directly into a model, we used tsfresh and domain-specific features such as turbidity AUC, decay rate, and cross-correlation, then used mRMR and LASSO to select the most relevant features before classification. :contentReference[oaicite:0]{index=0}

Another major lesson was that model performance alone is not enough. For this use case, detecting a failed cleaning cycle is especially important, so metrics like FAIL recall became more meaningful to us than accuracy by itself. :contentReference[oaicite:1]{index=1}

We also learned to be realistic about the limits of our prototype. Our current cycle data is simulated, so the model will need to be tested and retrained with real ESP32 and sensor data before we can judge how well it performs in a real processing environment. :contentReference[oaicite:2]{index=2}

Finally, we learned that HalalTrace should not replace a halal certifier. Its value is in giving certifiers continuous, traceable evidence that they can review during an audit, rather than relying only on a manual sign-off. :contentReference[oaicite:3]{index=3}

What's next for HalalTrace

Simulation Status: The current cycle metrics are simulated due to the pending deployment of physical ESP32, DS18B20 (temperature), and turbidity sensor hardware. All dashboard data will transition to live measures once real hardware is online.

Scope & Future Enhancements: Current data processing is limited to two telemetry streams: turbidity and temperature. Consequently, anomalies such as incorrect detergent concentration or a fouled valve may not be detected. Expanding the sensor array remains a primary objective for future devlopmets.

This system currently serves as a continuous data monitoring tool to support external audits rather than a replacement for certified regulatory inspections. Future development should focus on complying with Halal certification standards

Built With

Share this project:

Updates