MotorSignal-App/server/waze_relay/README.md

84 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🚔 MotorSignal Waze Alert Relay Server
A high-performance, lightweight headless relay backend that queries Waze Live Map feeds and provides normalized **Police Speed Traps, Speed Cameras, Red-Light Cameras, and Road Hazard Alerts** directly to the **MotorSignal** Motorcycle Cockpit application.
---
## 🚀 Quick Start
### Method 1: Run with Node.js (Local or VPS)
`ash
cd server/waze_relay
npm install
npm start
`
The server will start on http://0.0.0.0:3000.
### Method 2: Run with Docker / Docker Compose
`ash
cd server/waze_relay
docker compose up -d
`
---
## 📱 Connecting to MotorSignal
1. Open **MotorSignal** on your phone.
2. Go to **Settings** → **Community Traffic Provider**.
3. Under **Custom Endpoint URL**, enter your relay server URL:
`
http://<YOUR_SERVER_IP>:3000/alerts
`
*(e.g., http://192.168.1.69:3000/alerts for local Wi-Fi, or https://your-domain.com/alerts for remote VPS).*
4. Tap **TEST CONNECTION**. You will see the green **CONNECTED** badge!
---
## 📡 REST API Endpoints
### 1. Health Check
* GET /health or GET /
* **Response:**
`json
{
"status": "ok",
"service": "MotorSignal Waze Community Relay",
"version": "1.0.0"
}
`
### 2. Live Alerts Feed
* GET /alerts?lat=37.7749&lng=-122.4194&radius=5000
* **Query Parameters:**
* lat: Latitude of vehicle
* lng: Longitude of vehicle
*
adius: Search radius in meters (Default: 5000m)
* **Response:**
`json
{
"provider": "waze_relay",
"count": 2,
"alerts": [
{
"id": "wz_37.77490_-122.41940",
"type": "POLICE",
"category": "police",
"latitude": 37.7749,
"longitude": -122.4194,
"roadName": "Market St",
"description": "Hidden police speed trap reported on Market St",
"severity": "high",
"confidence": 0.9
}
]
}
`
---
## ⚡ Features
* **Police Trap Detection:** Parses POLICE_HIDDEN and POLICE_VISIBLE radar traps.
* **Camera Enforcement:** Speed cameras and red-light enforcement cameras.
* **In-Memory Geo-Grid Caching:** 30-second TTL prevents rate limiting and ensures sub-10ms response times for the motorcycle HUD.