Skip to content

feat: Implement Redis-to-PostGIS background worker and secure WebSockets#60

Merged
GiZano merged 1 commit intomainfrom
Backend
Apr 18, 2026
Merged

feat: Implement Redis-to-PostGIS background worker and secure WebSockets#60
GiZano merged 1 commit intomainfrom
Backend

Conversation

@GiZano
Copy link
Copy Markdown
Owner

@GiZano GiZano commented Apr 18, 2026

Overview

This PR introduces the core asynchronous data persistence layer for the QuakeGuard backend, alongside critical security updates for the mobile application's real-time feeds.

Incoming IoT payloads validated by the FastAPI gateway are now reliably popped from the Redis message broker and batch-inserted into the PostGIS database via a dedicated Python background worker.

Changes Made

Testing Performed

  • Sent 200 concurrent requests via stress_test.py (Phase 1).
  • Verified Redis Rate Limiter correctly blocks overflow traffic (Status 429).
  • Verified Bad Signature & Replay Attacks are blocked (Status 401/403).
  • Confirmed the worker container spins up, connects to Redis/Postgres, and successfully transitions items from the Redis queue to the misuration table.

Related Issues

Closes #51
Closes #54
Closes #55
Closes #56
Closes #57
Closes #58

- Create `worker.py` to process IoT payloads from Redis `seismic_events` queue
- Implement safe ORM mapping for `Misuration` PostGIS inserts
- Add fallback Dead Letter Queue (`seismic_events_dlq`) for database commit failures
- Enforce token-based authentication on FastAPI WebSocket endpoints
- Fix `stress_test.py` asyncio sleep pacing for accurate load generation
- Add `PYTHONUNBUFFERED=1` and `flush=True` to worker for real-time Docker logging

Closes #51, Closes #54, Closes #55, Closes #56, Closes #57, Closes #58
@GiZano GiZano merged commit 1c9ce96 into main Apr 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment