How 4proj-le-projet-d-une-vie/supmap-navigation works
Project type and purpose
• This is a standalone Go microservice (“supmap-navigation”) dedicated to real-time navigation: managing WebSocket connections, tracking positions, multicasting incidents and triggering dynamic route recalculations.
• It integrates with Redis (cache & Pub/Sub), a GIS service for routing, and an Incidents service.
File structure
• Top-level:
• cmd/main.go – service entry point
• internal/api – HTTP server & WebSocket handler
• internal/ws – WebSocket client & manager
• internal/cache – Redis session cache
• internal/subscriber – Redis Pub/Sub subscriber
• internal/incidents – incident multicaster
• internal/gis – GIS HTTP client & polyline utilities
• internal/navigation – domain models (Session, Route, Position)
• Configuration & Docker/CI manifests at root (.env, Dockerfile, GH Actions).
Key insights from README
• One primary /ws endpoint exposing WebSockets.
• Redis used both as a session cache and as a Pub/Sub broker for incoming incidents.
• External dependencies: supmap-incidents (publishes to Redis channel), supmap-gis (HTTP route recalculations).
a. Clients (mobile/Web)
b. API / WebSocket Manager
c. WebSocket Client instances
d. Session Cache (Redis – storage of session state)
e. Subscriber (Redis Pub/Sub)
f. Multicaster (incident router & route recalculation orchestrator)
g. GIS HTTP Client
h. External services: supmap-incidents, supmap-gis
i. Infrastructure: Redis instance(s)
Relationships & data flows
• Clients ↔ WebSocket Manager: bidirectional real-time messages (init, position, incident, route).
• Manager ↔ Redis Cache: read/write session state on every message.
• Subscriber ← Redis Pub/Sub: receives incident events from supmap-incidents.
• Subscriber → Multicaster → WebSocket Manager: multicast to affected clients.
• Multicaster → GIS Client → supmap-gis → Multicaster: route recalculation when needed → update cache & push to clients.
Architectural patterns & design principles
• Layered internal modularization (API, WS, cache, subscriber, incidents, GIS, domain models).
• Pub/Sub asynchronous event handling for incident notifications.
• Manager/Client pattern for WebSocket lifecycle and message dispatch.
• Cache-aside pattern with Redis for session persistence.
• Single-responsibility principle: each package has a focused role.
Technologies & frameworks
• Go modules, Go standard library (net/http, context).
• gorilla/websocket (or equivalent) for real-time connections.
• go-redis/v9 for cache & Pub/Sub.
• Docker & GitHub Actions for container build & CI/CD.
• Clear component labels and grouping (by package/function).
• Arrowheads indicating request vs. response.
• Boundaries distinguishing “supmap-navigation” from external services & infrastructure.