AWS Builder Center
CIRA: A Serverless Incident-Fusion Engine for Campus Safety on AWS

CIRA: A Serverless Incident-Fusion Engine for Campus Safety on AWS

How I built a fully serverless system on Lambda, API Gateway, DynamoDB, Step Functions, and SNS that automatically merges duplicate incident reports into one prioritized alert — with a from-scratch TF-IDF fusion engine and deterministic (non-LLM) priority rules.

Building CIRA: A Serverless Incident-Fusion Engine for Campus Safety on AWS

When something goes wrong on a college campus, we usually don't get one perfect emergency report.
We might get five different reports from five students about the same incident, all written differently and sometimes even mentioning the location in different ways.
One student might say, “Someone collapsed near the basketball court.”
Another might say, “A person is unconscious near the basketball ground.”
For a human, these reports could obviously be talking about the same incident. But for a system, they are just two different pieces of text.
That was the problem we wanted to solve with CIRA (Cognitive Incident Response & Analytics), the backend behind our CampusPulse application.
What does CIRA actually do?
Whenever a new report comes in, CIRA checks it against the active incidents and tries to figure out whether it is a completely new incident or another report about something that's already happening.
We currently use four signals for this:
• Text similarity – We implemented TF-IDF + cosine similarity from scratch in Python. We also added a small domain-specific synonym table so words like “collapsed” and “unconscious” can be treated as related.
• Location similarity – We normalize location names and use Jaccard similarity, so things like “Basketball Court” and “Basketball Ground” can still match.
• Time proximity – Reports that are close together in time get a higher score. Reports more than 30 minutes apart are treated as unrelated.
• Category match – If both reports have the same category, such as MEDICAL, FIRE or VIOLENCE, that also contributes to the score.
We combine them using:
0.4 × Text + 0.3 × Location + 0.2 × Time + 0.1 × Category
If the final score is above 0.75, we add the new report to the existing incident instead of creating another one.
The important part for us was keeping the actual priority decision deterministic. We didn't want an LLM deciding whether an incident is critical. The priority comes from a rule-based engine so that the decision is easier to explain and test.
AWS Architecture
The backend is completely serverless:
• AWS Lambda (Python) for the main business logic • Amazon API Gateway (HTTP API) for frontend/backend communication • Amazon DynamoDB for reports, incidents and timelines • AWS Step Functions for escalation workflows • Amazon SNS for critical alerts and escalation notifications • Amazon S3 for hosting the React/Vite/TypeScript frontend • AWS SAM for deployment
Things that broke while building it
It definitely wasn't working perfectly from day one.
One issue we faced was with DynamoDB Decimal values. When a report was merged into an existing incident, DynamoDB returned report_count as a Python Decimal, which caused json.dumps() to fail. After debugging, we realized the fusion logic wasn't the problem. It was the serialization. We fixed it by converting the value before returning it and adding a safer fallback.
We also initially tested our HTTP API using a /Prod/reports URL. After getting a 404, we spent time checking the routes before realizing that /Prod was from the REST API pattern we had in mind, not the HTTP API we were actually using.
Another problem came from moving the frontend from Windows to Linux. We had carried over the existing node_modules, which caused platform-specific dependency issues, including Rollup. Reinstalling the dependencies in the target environment fixed it.
We also had a frontend/backend integration problem. Initially, our frontend had local versions of the fusion and priority logic so we could work on the UI quickly. The UI looked like it was working, but it wasn't actually using the AWS backend. Instead of rebuilding everything, we connected the report submission to the real API while keeping the existing UI.
During testing, we also accidentally pasted a whole paragraph of instructions into a report description. That changed the similarity score enough that the report didn't get merged. It was a good reminder that the quality of the input matters too.
What's next?
Our next step is to add Amazon Bedrock (Claude 3 Haiku) before the fusion engine.
The LLM will help extract structured information from messy, natural-language reports.
The idea is:
Raw report → AI-assisted extraction → Structured data → Deterministic fusion → Priority and escalation
The LLM handles the language-processing part, while the actual incident decision remains deterministic.
#BharatBuilds #AWS #Serverless #AWSLambda #DynamoDB #AmazonBedrock #Python #React #CampusSafety
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article