While working as a CE with a system based on an Event‑Driven Architecture (EDA) pattern, I wanted to evaluate the possibility of using this architecture in more everyday tasks. For this case, I chose a control and attendance system that could be used during dog‑walking days organized by an animal shelter located in San Antonio de Benagéber, Valencia, Spain.
The main idea is to assist in coordinating the walks so that volunteers always know—visually and intuitively—which dogs have gone out, which dogs are currently walking, and any other necessary information to ensure the day runs smoothly.
Basically, the system consists of an entry point that triggers an event. The system then analyzes whether it is an entry or exit event and displays it on a dashboard. Later on, we will go deeper and—if possible—make it more complex. For example, adding the ability to obtain metrics about the walking days and the dogs, or adding warning indicators in case two reactive dogs might go out at the same time.
Solution Architecture (General Overview)
Ingestion (Producers):
A single API receives all events (QR, NFC, AI).
Routing (Event Bus):
An event bus classifies and distributes the events.
Logic (Consumers):
A “brain” function processes “Entry” and “Exit” events.
State (Database):
A database stores the current state (INSIDE/OUTSIDE) and timestamps.
Visualization (Dashboard):
The dashboard updates in real time.
1. Ingestion: Amazon API Gateway
To prevent the mobile app (used for QR/NFC) or the AI model from connecting directly to the logic layer, I use a single, secure, and scalable entry point.
- Service: Amazon API Gateway
- How it works:
A REST API is created (e.g., POST /events).
All devices send a simple JSON payload to this endpoint.
2. Routing: Amazon EventBridge
API Gateway performs no computation. Its only task is to pass the event on to the central event bus.
- Service: Amazon EventBridge
- How it works:
API Gateway places the event into EventBridge.
EventBridge evaluates the event and decides where to send it based on Rules.
3. Logic and State: AWS Lambda + Amazon DynamoDB
This is where the magic happens. EventBridge forwards all events to a “brain” function that maintains the dogs’ state.
- Services: AWS Lambda and Amazon DynamoDB
- Database (DynamoDB):
A table called EstadoPerros is created. - Function (Lambda):
A Lambda function called ProcesarMovimientoPerro is created.
EventBridge triggers it every time an event arrives.
Lambda Logic:
- IF the event action is
"SALIDA"(Exit):
Process the dog as “going out.” - IF the event action is
"ENTRADA"(Entry):
Process the dog as “coming back.”
4. Visualization: Real‑Time Dashboard
The dashboard must receive changes instantly, without a page refresh.
- Services: AWS AppSync or AWS IoT Core (WebSockets)
- How it works (with AppSync):
- EventBridge has a second rule:
“If an event containsnuevo_estado…” - The target of this rule is AppSync.
- The dashboard uses the AppSync client library to subscribe to updates.
- When AppSync receives an event like:
{"id_perro": "p-001", "nuevo_estado": "FUERA"}
it sends it via WebSocket to all connected dashboards. - The dashboard updates the icon for
p-001to “OUTSIDE” in real time.
- EventBridge has a second rule:
5. Total Time Calculation
To track information for the day:
tiempo_paseo_total_hoyis already being calculated and stored in DynamoDB each time a dog returns from a walk.- When the dashboard loads for the first time, it simply queries DynamoDB (via API Gateway) to retrieve the current state and total time for all dogs.
Additional Task: Daily Reset
I need a way to reset the tiempo_paseo_total_hoy counter to 0 every day.
- Service: Amazon EventBridge Scheduler
- How it works:
A scheduled rule (“cron job”) is created to run every day at midnight.
The target is a new Lambda function (ResetContadoresDiarios) that scans the DynamoDB table and setstiempo_paseo_total_hoy = 0for all dogs.
Implementation Notes
Whenever possible, I will use IaC (Terraform) for implementation and commit the code to my GitHub account.
Thanks to Oxigent Technologies for providing the resources for this POC.
Thanks for reading this far, and I welcome all suggestions!
Martin P.