How souma061/instaride works
InstaRide is a real-time ride-matching platform with a React operations dashboard, a TypeScript service, and optional native C++ spatial acceleration. The main flow is driver location ingestion and indexing, rider request and nearest-driver search, leased driver locking and offer dispatch, then trip-state updates and completion. Redis-backed lock and trip persistence support that lifecycle; WebSockets carry live events to rider, driver, and observer clients. The README documents the dual spatial engines and dashboard capabilities; several backend and UI relationships below rely on its architecture description and the SOURCE INDEX, since those implementations were not fully excerpted.
Main entry points: matching_service.ts Candidate dispatch · App.tsx Dashboard shell · server.ts REST API · driver_registry.ts Driver registry
Components 26
Rider and operations UI
- Dashboard shell
frontend/src/App.tsx - Rider cockpit
frontend/src/components/RiderCockpit.tsx - Driver cockpit
frontend/src/components/DriverCockpit.tsx - Spatial map
frontend/src/components/DynamicSpatialMap.tsx - Operations dashboard
frontend/src/components/OperationsDashboard.tsx - Chaos testing panel
frontend/src/components/ChaosTestingPanel.tsx - Audit stream
frontend/src/components/AuditLogStream.tsx - Header metrics
frontend/src/components/HeaderMetrics.tsx - Socket client
frontend/src/hooks/useInstaRideSocket.ts
Gateway and live events
- REST API
src/server.ts - WebSocket manager
src/gateway/ws_manager.ts - Driver simulation
src/simulation/driver_simulator.ts
Matching and trip lifecycle
- Candidate dispatch
src/core/matching_service.ts - Driver registry
src/core/driver_registry.ts - Trip state machine
src/core/trip_state_machine.ts
Spatial engines
- TypeScript QuadTree
src/spatial/quadtree.ts - C++ IPC bridge
src/spatial/cpp_spatial_bridge.ts - Native QuadTree
cpp-engine/Quadtree.hpp
State and telemetry
- Driver lock leases
src/core/redis_driver_lock.ts - Trip persistence
src/core/redis_trip_store.ts - Redis client
src/infra/redis_client.ts - Service metrics
src/metrics/metrics.ts - Input validation
src/utils/validation.ts
Other components
- Rider
- Driver
- Operator
Connections 41
- Rider → Rider cockpit: books rides
README.md - Driver → Driver cockpit: sends updates
README.md - Operator → Operations dashboard: monitors service
README.md - Dashboard shell → Rider cockpit: renders
frontend/src/App.tsx - Dashboard shell → Driver cockpit: renders
frontend/src/App.tsx - Dashboard shell → Spatial map: renders
frontend/src/App.tsx - Dashboard shell → Operations dashboard: renders
frontend/src/App.tsx - Dashboard shell → Chaos testing panel: renders
frontend/src/App.tsx - Dashboard shell → Audit stream: renders
frontend/src/App.tsx - Dashboard shell → Header metrics: renders
frontend/src/App.tsx - Rider cockpit → Socket client: uses live events
- Driver cockpit → Socket client: uses live events
- Spatial map → Socket client: uses telemetry
- Socket client → WebSocket manager: exchanges events
README.md - Rider → REST API: submits requests
README.md - Driver → REST API: posts trip actions
README.md - Chaos testing panel → REST API: runs scenarios
README.md - REST API → Candidate dispatch: routes requests
src/server.ts - REST API → WebSocket manager: broadcasts updates
src/server.ts - REST API → Driver simulation: queries simulation
src/server.ts - REST API → C++ IPC bridge: selects engine
src/server.ts - WebSocket manager → Candidate dispatch: dispatches actions
src/gateway/ws_manager.ts - WebSocket manager → Driver registry: updates driver status
src/gateway/ws_manager.ts - WebSocket manager → Trip state machine: reads active trip
src/gateway/ws_manager.ts - Candidate dispatch → TypeScript QuadTree: searches candidates
src/core/matching_service.ts - Candidate dispatch → Driver registry: locks candidates
src/core/matching_service.ts - Candidate dispatch → Trip state machine: creates and updates trips
src/core/matching_service.ts - Candidate dispatch → Trip persistence: persists trip state
src/core/matching_service.ts - Driver registry → TypeScript QuadTree: indexes drivers
src/core/driver_registry.ts - Driver registry → Driver lock leases: acquires leases
src/core/driver_registry.ts - Driver registry → Service metrics: records metrics
src/core/driver_registry.ts - Driver simulation → Driver registry: updates locations
src/simulation/driver_simulator.ts - Driver simulation → Candidate dispatch: exercises matching
src/simulation/driver_simulator.ts - Driver simulation → Trip state machine: exercises trip flow
src/simulation/driver_simulator.ts - Driver simulation → TypeScript QuadTree: uses spatial index
src/simulation/driver_simulator.ts - Driver lock leases → Redis client: stores leases
src/core/redis_driver_lock.ts - Trip persistence → Redis client: stores trips
src/core/redis_trip_store.ts - Trip persistence → Trip state machine: uses trip model
src/core/redis_trip_store.ts - Trip state machine → Input validation: validates coordinates
src/core/trip_state_machine.ts - C++ IPC bridge → Native QuadTree: uses native engine
README.md - Candidate dispatch → C++ IPC bridge: optional spatial search
README.md