# vimal-sabari/cloud-native-ride-dispatch-platform architecture

> Architecture diagram of the GitHub repository vimal-sabari/cloud-native-ride-dispatch-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vimal-sabari/cloud-native-ride-dispatch-platform
- Repository: https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform

## Overview

This is an AWS event-driven ride-dispatch platform. Riders request rides and drivers send location/status updates; the platform persists these changes, forwards DynamoDB stream events through queues, matches rides to nearby available drivers, confirms assignments, and notifies rider and driver clients over WebSockets. The graph also preserves authentication, stale-match recovery, and simulator capabilities. Several internal implementations are unsampled, so links to them rely on the README or are marked unverified.

Main entry points: [`services/trip-service/src/handlers/request-ride.ts`](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/handlers/request-ride.ts) (Trip handlers), [`services/event-forwarder/cmd/event-forwarder/main.go`](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/event-forwarder/cmd/event-forwarder/main.go) (Stream forwarder), [`services/matching-service/cmd/matching-service/main.go`](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/cmd/matching-service/main.go) (Matching daemon), [`services/matching-service/internal/matcher/batch.go`](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/matcher/batch.go) (Batch matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["API and auth"]
  node_rest{{"REST API"}}
  node_authorizer["JWT authorizer<br/>[authorizer.ts]"]
  node_token["Token issuer<br/>[issue-token.ts]"]
end

subgraph group_dispatch["Location and matching"]
  node_location["Location handlers<br/>[location.go]"]
  node_status["Driver status<br/>[status.go]"]
  node_forwarder["Stream forwarder<br/>[main.go]"]
  node_classify["Event classifier<br/>[classify.go]"]
  node_matcher["Matching daemon<br/>[main.go]"]
  node_batch["Batch matching<br/>[batch.go]"]
  node_geoindex["Spatial index<br/>[geoindex.go]"]
  node_hungarian["Hungarian solver<br/>[hungarian.go]"]
  node_assignment["Assignment protocol<br/>[assignment.go]"]
end

subgraph group_rides["Ride lifecycle"]
  node_trip["Trip handlers<br/>[request-ride.ts]"]
  node_stale["Stale-match recovery"]
  node_tripstate["Ride state machine<br/>[state-machine.ts]"]
end

subgraph group_notify["Events and notifications"]
  node_notification["SNS fanout<br/>[sns-fanout.ts]"]
  node_connections["WebSocket connections"]
end

subgraph group_clients["Clients and shared logic"]
  node_driver_sim["Driver simulator<br/>[driver-loop.ts]"]
  node_rider_sim["Rider simulator<br/>[rider-loop.ts]"]
end

node_rider(("Rider client"))
node_driver(("Driver client"))
node_dynamo[("DynamoDB")]
node_queues["SQS event queues"]
node_sns["Match events"]
node_websocket{{"WebSocket API"}}

node_rider -->|"requests rides"| node_rest
node_driver -->|"sends telemetry"| node_rest
node_rest -.->|"validates JWT"| node_authorizer
node_rest -->|"routes updates"| node_location
node_rest -->|"routes ride requests"| node_trip
node_location -->|"writes heartbeat"| node_dynamo
node_status -.->|"updates status"| node_dynamo
node_trip -->|"creates ride"| node_dynamo
node_trip -.->|"changes state"| node_tripstate
node_dynamo -->|"streams changes"| node_forwarder
node_forwarder -->|"classifies records"| node_classify
node_forwarder -->|"forwards events"| node_queues
node_queues -->|"delivers events"| node_matcher
node_matcher -->|"processes requests"| node_batch
node_batch -->|"finds nearby drivers"| node_geoindex
node_batch -->|"solves assignments"| node_hungarian
node_matcher -.->|"claims drivers"| node_assignment
node_assignment -->|"claims atomically"| node_dynamo
node_assignment -->|"confirms assignment"| node_rest
node_stale -->|"queries and updates"| node_dynamo
node_stale -->|"re-enqueues ride"| node_queues
node_trip -->|"publishes ride event"| node_sns
node_sns -->|"fans out events"| node_notification
node_notification -->|"looks up connections"| node_dynamo
node_notification -->|"pushes notifications"| node_connections
node_connections -->|"posts frames"| node_websocket
node_websocket -->|"delivers updates"| node_rider
node_websocket -->|"delivers updates"| node_driver
node_driver_sim -.->|"sends driver traffic"| node_rest
node_rider_sim -.->|"sends rider traffic"| node_rest
node_rider_sim -->|"requests token"| node_token
node_driver_sim -.->|"requests token"| node_token

click node_authorizer "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/auth-stub/src/authorizer.ts"
click node_token "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/auth-stub/src/issue-token.ts"
click node_location "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/location-service/internal/handler/location.go"
click node_status "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/location-service/internal/handler/status.go"
click node_forwarder "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/event-forwarder/cmd/event-forwarder/main.go"
click node_classify "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/event-forwarder/internal/classify/classify.go"
click node_matcher "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/cmd/matching-service/main.go"
click node_batch "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/matcher/batch.go"
click node_geoindex "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/geoindex/geoindex.go"
click node_hungarian "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/shared/matching-algorithms/hungarian.go"
click node_trip "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/handlers/request-ride.ts"
click node_stale "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/handlers/reassign-stale-matches.ts"
click node_tripstate "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/state-machine.ts"
click node_notification "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/notification-service/src/handlers/sns-fanout.ts"
click node_connections "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/notification-service/src/connection-manager.ts"
click node_driver_sim "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/simulators/driver-simulator/src/driver-loop.ts"
click node_rider_sim "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/simulators/rider-simulator/src/rider-loop.ts"
click node_assignment "https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/assignment/assignment.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rest,node_authorizer,node_token,node_rider,node_driver toneBlue
class node_location,node_status,node_forwarder,node_classify,node_matcher,node_batch,node_geoindex,node_hungarian,node_assignment,node_dynamo toneAmber
class node_trip,node_stale,node_tripstate,node_websocket toneMint
class node_notification,node_connections,node_queues toneRose
class node_driver_sim,node_rider_sim,node_sns toneIndigo
```

## Components

### API and auth

- **REST API**
- [JWT authorizer](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/auth-stub/src/authorizer.ts): `services/auth-stub/src/authorizer.ts`
- [Token issuer](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/auth-stub/src/issue-token.ts): `services/auth-stub/src/issue-token.ts`

### Location and matching

- [Location handlers](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/location-service/internal/handler/location.go): `services/location-service/internal/handler/location.go`
- [Driver status](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/location-service/internal/handler/status.go): `services/location-service/internal/handler/status.go`
- [Stream forwarder](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/event-forwarder/cmd/event-forwarder/main.go): `services/event-forwarder/cmd/event-forwarder/main.go`
- [Event classifier](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/event-forwarder/internal/classify/classify.go): `services/event-forwarder/internal/classify/classify.go`
- [Matching daemon](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/cmd/matching-service/main.go): `services/matching-service/cmd/matching-service/main.go`
- [Batch matching](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/matcher/batch.go): `services/matching-service/internal/matcher/batch.go`
- [Spatial index](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/geoindex/geoindex.go): `services/matching-service/internal/geoindex/geoindex.go`
- [Hungarian solver](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/shared/matching-algorithms/hungarian.go): `shared/matching-algorithms/hungarian.go`
- [Assignment protocol](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/matching-service/internal/assignment/assignment.go): `services/matching-service/internal/assignment/assignment.go`

### Ride lifecycle

- [Trip handlers](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/handlers/request-ride.ts): `services/trip-service/src/handlers/request-ride.ts`
- [Stale-match recovery](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/handlers/reassign-stale-matches.ts): `services/trip-service/src/handlers/reassign-stale-matches.ts`
- [Ride state machine](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/trip-service/src/state-machine.ts): `services/trip-service/src/state-machine.ts`

### Events and notifications

- [SNS fanout](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/notification-service/src/handlers/sns-fanout.ts): `services/notification-service/src/handlers/sns-fanout.ts`
- [WebSocket connections](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/services/notification-service/src/connection-manager.ts): `services/notification-service/src/connection-manager.ts`

### Clients and shared logic

- [Driver simulator](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/simulators/driver-simulator/src/driver-loop.ts): `simulators/driver-simulator/src/driver-loop.ts`
- [Rider simulator](https://github.com/vimal-sabari/cloud-native-ride-dispatch-platform/blob/main/simulators/rider-simulator/src/rider-loop.ts): `simulators/rider-simulator/src/rider-loop.ts`

### Other components

- **Rider client**
- **Driver client**
- **DynamoDB**
- **SQS event queues**
- **Match events**
- **WebSocket API**

## Connections

- Rider client → REST API: requests rides
- Driver client → REST API: sends telemetry
- REST API → JWT authorizer: validates JWT
- REST API → Location handlers: routes updates
- REST API → Trip handlers: routes ride requests
- Location handlers → DynamoDB: writes heartbeat
- Driver status → DynamoDB: updates status
- Trip handlers → DynamoDB: creates ride
- Trip handlers → Ride state machine: changes state (evidence: `services/trip-service/src/state-machine.ts`)
- DynamoDB → Stream forwarder: streams changes
- Stream forwarder → Event classifier: classifies records (evidence: `services/event-forwarder/cmd/event-forwarder/main.go`)
- Stream forwarder → SQS event queues: forwards events
- SQS event queues → Matching daemon: delivers events
- Matching daemon → Batch matching: processes requests (evidence: `services/matching-service/cmd/matching-service/main.go`)
- Batch matching → Spatial index: finds nearby drivers (evidence: `services/matching-service/internal/matcher/batch.go`)
- Batch matching → Hungarian solver: solves assignments
- Matching daemon → Assignment protocol: claims drivers
- Assignment protocol → DynamoDB: claims atomically
- Assignment protocol → REST API: confirms assignment
- Stale-match recovery → DynamoDB: queries and updates (evidence: `services/trip-service/src/handlers/reassign-stale-matches.ts`)
- Stale-match recovery → SQS event queues: re-enqueues ride (evidence: `services/trip-service/src/handlers/reassign-stale-matches.ts`)
- Trip handlers → Match events: publishes ride event
- Match events → SNS fanout: fans out events
- SNS fanout → DynamoDB: looks up connections (evidence: `services/notification-service/src/handlers/sns-fanout.ts`)
- SNS fanout → WebSocket connections: pushes notifications (evidence: `services/notification-service/src/handlers/sns-fanout.ts`)
- WebSocket connections → WebSocket API: posts frames (evidence: `services/notification-service/src/connection-manager.ts`)
- WebSocket API → Rider client: delivers updates
- WebSocket API → Driver client: delivers updates
- Driver simulator → REST API: sends driver traffic
- Rider simulator → REST API: sends rider traffic
- Rider simulator → Token issuer: requests token
- Driver simulator → Token issuer: requests token
