
We Taught a Fridge to Open Incidents Instead of Spamming Alerts: Building FreshGuard on AWS
Four days, one simulated cold room, a lot of MQTT messages, and one rule: AI was not allowed to decide whether an incident was real. Here is how we built FreshGuard, an event-driven cold-chain monitoring system on AWS, plus what broke along the way.
It started with a slightly annoying question
What is the difference between a bad sensor reading and an incident?
At first, that sounds like the kind of question you answer in five seconds.
Temperature too high? Alert someone.
Done.
Except, not really.
Imagine a cold room publishing a reading every few seconds. The temperature briefly crosses a configured limit.
Do we alert immediately?
What if it drops again five seconds later?
What if it stays high for five minutes?
And if we send an alert for every bad reading, how quickly does the operator start ignoring us completely?
That was the problem that eventually became FreshGuard.
FreshGuard takes a stream of refrigeration telemetry and turns it into a small number of understandable, auditable incidents rather than treating every abnormal reading like an emergency. Our hackathon version uses a software-simulated MQTT device, not physical refrigeration hardware, but the cloud-facing contract is designed so a real MQTT-capable device could take its place later.
And because this was an AWS hackathon, we had four days to make it real.
Naturally, we decided distributed systems were a reasonable weekend activity.
The first rule: an event is not an incident
This became the most important design decision in the whole project.
A temperature reading above the configured threshold is just an event.
FreshGuard only creates an incident when that condition persists long enough to satisfy the configured grace period.
So our monitoring lifecycle looks like this:
NORMAL
↓
WATCHING
↓
ACTIVE
↓
RECOVERING
↓
NORMAL
If the temperature rises above the configured limit, the unit enters WATCHING .Nothing dramatic happens yet.
No alert.
No incident.
No AI.
If the temperature returns to normal before the grace period ends, FreshGuard quietly goes back to
NORMAL .But if the elevated readings continue long enough, the state becomes
ACTIVE and exactly one incident is opened.That incident keeps updating as new readings arrive.
Then, when the temperature returns below the configured threshold, FreshGuard enters
RECOVERING . It only resolves the incident after the recovery period is satisfied.If the temperature rises again halfway through recovery?
Back to
ACTIVE .Same incident.
No duplicate alert.
No duplicate incident.
This sounds simple written down.
Getting all the edge cases right was less simple. 🙂
The project intentionally distinguishes a continuous excursion from individual sensor events, and the same incident remains active through recovery until it is finally resolved.
We deliberately did not let AI make the important decision
It would have been very tempting to send every sensor reading to an LLM and ask:
“Does this look dangerous?”
It would also have been the wrong architecture for what we were building.
FreshGuard uses normal deterministic code for:
- threshold checks
- grace periods
- recovery timing
- duplicate protection
- incident creation
- incident resolution
Amazon Bedrock gets involved after an incident already exists.
That separation became one of our favourite parts of the project.
The system first records the facts:
{
"thresholdC": 8,
"temperatureAtOpenC": 9.4,
"peakTemperatureC": 10.1,
"doorState": "OPEN",
"powerState": "ON"
}
Then Bedrock receives those verified observations and turns them into a short explanation for the operator.In other words:
Code decides what happened. AI helps explain it.
The incident should still make complete sense even if you remove the AI paragraph entirely.
That “evidence first” principle is built directly into the product.
The architecture grew from that decision
Once we knew detection and explanation had to be independent, the AWS architecture became much clearer.
Our simulator publishes telemetry over MQTT.
The main path looks like this:
Python MQTT Simulator
↓
AWS IoT Core
↓
IoT Topic Rule
↓
AWS Lambda
↓
Amazon DynamoDB
↓
Amazon EventBridge
↙ ↘
SNS Bedrock
And separately:
DynamoDB
↓
API Gateway + Lambda
↓
Next.js dashboard
↓
AWS Amplify Hosting
The telemetry Lambda validates the payload, stores the reading, loads the current device state, and runs the deterministic state machine.When an incident opens, it is written to DynamoDB before downstream enrichment becomes relevant.
Then an incident event is sent to EventBridge.
From there, two independent things happen.
One consumer sends the alert through Amazon SNS.
Another consumer invokes Amazon Bedrock and saves the explanation back onto the incident.
That independence matters.
A slow AI response should not delay an alert.
A failed AI response definitely should not make an incident disappear.
EventBridge gave us a clean way to keep those responsibilities separate instead of turning the telemetry Lambda into one giant function that did absolutely everything.
The surprisingly satisfying part: watching
GENERATING change to READY
Once the backend started working, the dashboard made the architecture much easier to understand.A breach begins.
The dashboard changes:
NORMAL → WATCHING
The grace period completes.
WATCHING → INCIDENT
The incident appears immediately with its raw evidence.And underneath it:
AI explanation: Generating...
Meanwhile, the SNS notification has already been sent.A few moments later:
AI explanation: Ready
That little transition was one of the most satisfying parts of the build because it visually proves that AI is asynchronous.The incident did not wait for Bedrock.
The notification did not wait for Bedrock.
Bedrock was catching up with a decision the deterministic system had already made.
That was exactly the behaviour we wanted.
Then AWS reminded us that hackathons need villains
Then AWS reminded us that hackathons need villains
For us, one of those villains was Bedrock account access.
We had the enrichment flow designed.
We had the incident evidence.
We had the Lambda.
And then our AWS account hit a verification and access restriction that prevented us from enabling the AI explanation path.
This was particularly painful because the rest of the system was already working.
There is a special kind of hackathon anxiety that comes from staring at an architecture diagram where every arrow works except the arrow leading to the feature with “AI” written on it.
We eventually got the account restriction resolved, but it cost us time and taught us something useful:
Make optional dependencies genuinely optional.
If we had built Bedrock directly into incident detection, that verification problem could have blocked the entire product.
Instead, FreshGuard could still:
- ingest telemetry
- detect the excursion
- create the incident
- send the SNS alert
- display the evidence
- recover
- resolve the incident
The only missing piece was the generated explanation.
That failure mode was not an accident. The architecture explicitly treats Bedrock failure as degradation of explanation quality, not incident correctness.
We also learned that AWS IoT certificates are very good at making beginners question themselves
AWS IoT Core was one of the services we were most excited to use because we wanted the simulator to behave like an actual cloud-connected device.
It was also one of the steeper setup experiences.
There is a Thing.
There is a certificate.
There is a private key.
There is a root CA.
There is an IoT policy.
There is a client ID.
There is an endpoint.
There is a topic.
And if one character in one of those pieces is wrong, MQTT has a wonderful way of making you reconsider your life choices.
But once everything connected, the result felt genuinely production-shaped.
Our Python simulator could publish to:
freshguard/dev/devices/cold-room-01/telemetry
and AWS IoT Core would route those messages into the rest of the serverless application.We were no longer clicking a button in the frontend pretending that a sensor changed.
The data was actually travelling through the IoT pipeline.
That distinction mattered a lot to us.
Why three DynamoDB tables instead of trying to be clever
We used three DynamoDB tables:
Devices
Telemetry
Incidents
Could we have built an elegant single-table design?Probably.
Did we want to debug an elegant single-table design at 1:30 AM during a four-day hackathon?
Absolutely not.
Devices stores current state and configuration.Telemetry stores recent time-ordered sensor readings.Incidents stores the durable lifecycle record.Simple.
Easy to inspect.
Easy to explain.
Easy to debug.
One of the biggest lessons from this hackathon was that “production-shaped” does not mean “maximum complexity.”
Sometimes the better architecture is the one your entire team can still explain after several hours of debugging CORS.
The project deliberately chose three tables for clarity and straightforward access patterns rather than premature optimization.
The simulator was not a shortcut. It was a scope decision.
We do not have a refrigeration unit sitting beside our laptops.
We also did not want half the hackathon to become:
“Why isn't this ESP32 connecting to Wi-Fi?”
So we built a Python MQTT simulator.
It generates deterministic scenarios like:
NORMAL
↓
door opens
↓
temperature rises
↓
configured threshold exceeded
↓
recovery
Each reading gets a new event ID and timestamp and travels through the same MQTT contract a physical device could use later.For this prototype, that was the right trade-off.
It let us spend our limited time on the part we actually wanted to explore:
What happens after telemetry reaches the cloud?
That includes idempotency, state transitions, incident semantics, notification fan-out, observability, API design, AI enrichment, and recovery.
FreshGuard is explicitly a software-device prototype rather than a hardware product, and the simulated sensor is one of the documented limitations of the project.
Our favourite test was intentionally breaking the AI
Most demos try very hard not to show things failing.
We deliberately tested failure.
We forced the Bedrock enrichment path to fail and then triggered another temperature excursion.
What we wanted to see was:
Incident: OPEN
SNS: SENT
AI: FAILED
And nothing else should break.The dashboard should still show:
- when the incident opened
- the configured threshold
- opening temperature
- peak temperature
- door and power observations
Recovery should still work.
The same incident should still move to:
RESOLVED
This turned out to be a much more useful test than simply proving that Bedrock could return some text.“AI worked once” is nice.
“AI broke and the important parts still worked” tells us much more about the system.
Our test strategy explicitly includes a deliberate Bedrock failure test to prove that the incident and alert paths remain functional.
The AWS services that ended up earning their place
One thing we tried hard to avoid was adding services just because the architecture diagram looked cooler with more boxes.
Every major service needed a reason to exist.
AWS IoT Core
Because MQTT device ingestion is the actual boundary of the system.
AWS Lambda
Because our event processing is short-lived and naturally event-driven.
Amazon DynamoDB
Because our access patterns are simple and we wanted serverless persistence.
Amazon EventBridge
Because alerting and AI enrichment should not depend on each other.
Amazon SNS
Because an incident needed a real external notification path.
Amazon Bedrock
Because translating structured evidence into concise human-readable context is genuinely useful here.
Amazon API Gateway
Because the public dashboard should have a read-only HTTP boundary rather than direct database access.
AWS Amplify
Because we needed a deployed frontend without turning hosting into another project.
Amazon CloudWatch
Because distributed systems become significantly less fun when you cannot see what they are doing.
AWS SAM
Because rebuilding the architecture from memory and console screenshots is not infrastructure as code. 🙂
What we would change if this stopped being a hackathon project
FreshGuard is a prototype, and we are intentionally not pretending otherwise.
Our demo uses:
- one simulated device
- short demo-friendly threshold timings
- a public read-only dashboard
- limited telemetry retention
It is not a food-safety certification system.
It does not predict spoilage.
It does not determine whether food is safe.
It does not automatically control refrigeration equipment.
Those boundaries were important to us because it is very easy for a sensor + AI demo to accidentally make claims that the actual system cannot support.
If we continued developing it, we would look at stronger device provisioning, authentication, tenant isolation, longer-term telemetry storage, queues or DLQs where justified, and calibrated physical sensors.
But those were intentionally not four-day problems.
The biggest thing we learned
We started the hackathon thinking the interesting part would be connecting an IoT device to AWS and adding an AI explanation.
The more interesting lesson turned out to be where not to use AI.
The most important line of FreshGuard is not a Bedrock prompt.
It is the boundary between:
deterministic decision
and:
probabilistic explanation
That one decision influenced almost everything else:EventBridge fan-out.
Failure isolation.
Dashboard states.
Incident evidence.
Testing.
Cost.
Even the demo.
And somewhere along the way, our simulated refrigerator turned into a fairly decent lesson in event-driven architecture.
Not bad for something whose main job was pretending to be cold.
Final architecture

FreshGuard was built for the WeMakeDevs × AWS First Commit 2026 hackathon as a small, reliable end-to-end system rather than a huge collection of half-finished features. That matches the project goal of prioritizing reliability and a repeatable deployed workflow over breadth.
One last note about AI
We used ChatGPT/Codex as development assistants for implementation scaffolding, debugging, tests, and documentation during the hackathon.
The architecture, state-machine semantics, AWS configuration, integration decisions, security boundaries, and final behaviour were reviewed and validated by our team.
Because using AI to build a project about using AI felt appropriately recursive.
If you made it this far...
Thanks for reading.
And if your refrigerator ever starts publishing MQTT events to EventBridge, maybe don't ignore it. 😄
Team FreshGuard
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article