Skip to content

feat(backend): add demo endpoint to trigger simulated alerts#281

Merged
GiZano merged 1 commit into
mainfrom
backend/feat-191-demo-endpoint
May 19, 2026
Merged

feat(backend): add demo endpoint to trigger simulated alerts#281
GiZano merged 1 commit into
mainfrom
backend/feat-191-demo-endpoint

Conversation

@GiZano

@GiZano GiZano commented May 19, 2026

Copy link
Copy Markdown
Owner

name: Pull Request
about: Standard PR format for all QuakeGuard contributions
title: "feat(backend): add demo endpoint to trigger simulated alerts"

Overview

This PR introduces a dedicated POST /demo/trigger-earthquake endpoint to solve the unreliability of demonstrating critical alerts during presentations and testing. Instead of waiting for the stress tester to randomly generate high-magnitude anomalies, developers can now trigger an immediate, customized CRITICAL payload directly from Swagger UI.

Changes Made

  • src/schemas.py: Added a DemoAlertRequest Pydantic model with default values (Magnitude 7.5) to allow one-click executions with an empty body.
  • main.py: Created the /demo/trigger-earthquake route under the tags=["Demo"] group. Protected it with Depends(verify_api_key) and wired it directly to redis_client.publish().

Impact & Next Steps

This completely decouples frontend presentation testing from the backend statistical worker layer. We can now accurately test mobile push notifications, haptic patterns, and UI state changes instantly.
Next Steps: Document this endpoint in the developer onboarding guide so team members know how to test the frontend locally without spinning up the heavy Python worker container.

Testing Performed

  • Verified the endpoint appears under the "Demo" tag in Swagger UI and correctly rejects unauthenticated requests (HTTP 401).
  • Triggered the endpoint with an empty body and verified a default Magnitude 7.5 payload successfully propagated to the frontend via WebSocket.
  • Overrode the defaults with a custom JSON body and verified the custom message/magnitude were correctly parsed and broadcast.

Related Issues

Closes #191
Closes #192
Closes #193
Closes #194
Closes #195
Closes #196

Added a secure POST /demo/trigger-earthquake endpoint to main.py.
It bypasses the IoT ingestion worker and publishes a crafted
CRITICAL payload directly to the Redis Pub/Sub channel, enabling
instant, reproducible frontend testing and live demonstrations.

Closes #191
@GiZano GiZano requested a review from riccardo0731 as a code owner May 19, 2026 20:09
@GiZano GiZano merged commit 7f46223 into main May 19, 2026
2 checks passed
@GiZano GiZano deleted the backend/feat-191-demo-endpoint branch May 19, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment