# sunkumahesh-777/riderelay architecture

> Architecture diagram of the GitHub repository sunkumahesh-777/riderelay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sunkumahesh-777/riderelay
- Repository: https://github.com/sunkumahesh-777/riderelay

## Overview

RideRelay is a rider–captain ride-matching app with a React interface and Node API. Riders search routes and request rides; captains publish routes, manage requests and ride status, and maintain profiles and payment details. Authentication, payments, reviews, and location discovery are additional API capabilities. The README documents JSON fallback and PostgreSQL projection; the sampled source does not establish every internal call between backend modules, so uncertain wiring is omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/App.jsx) (RideRelay UI), [`frontend/src/services/api.js`](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/api.js) (HTTP client), [`backend/server.js`](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/server.js) (HTTP API), [`backend/db.js`](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/db.js) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web app"]
  node_app["RideRelay UI<br/>[App.jsx]"]
  node_auth_client["Auth client<br/>[authService.js]"]
  node_ride_client["Ride client<br/>[rideService.js]"]
  node_api_client["HTTP client<br/>[api.js]"]
end

subgraph group_api["API and domain"]
  node_api_server["HTTP API<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_ride_rules["Route and seat rules<br/>[rideService.js]"]
  node_ride_states["Ride status rules<br/>[rideController.js]"]
  node_user_profiles["Profile updates<br/>[userController.js]"]
  node_user_model["User records<br/>[User.js]"]
  node_ride_model["Ride records<br/>[Ride.js]"]
  node_locations["Location hubs<br/>[locations.js]"]
end

subgraph group_persistence["Persistence"]
  node_db_access["Database access<br/>[db.js]"]
  node_json_store[("Local JSON state<br/>[db.js]")]
  node_projector["Postgres projection"]
  node_schema["Relational schema<br/>[schema.sql]"]
end

subgraph group_external["External services"]
  node_postgres[("PostgreSQL")]
  node_leaflet["Map tiles"]
end

node_rider(("Rider"))
node_captain(("Captain"))

node_rider -->|"uses"| node_app
node_captain -->|"uses"| node_app
node_app -->|"signs in"| node_auth_client
node_app -->|"searches and requests"| node_ride_client
node_app -->|"loads data"| node_api_client
node_auth_client -->|"sends auth requests"| node_api_client
node_ride_client -->|"sends ride requests"| node_api_client
node_api_client -->|"HTTP requests"| node_api_server
node_api_server -->|"reads and writes"| node_db_access
node_db_access -->|"fallback state"| node_json_store
node_db_access -->|"projects saved data"| node_projector
node_projector -->|"writes projection"| node_postgres
node_postgres -.->|"uses schema"| node_schema
node_api_server -.->|"optional storage"| node_postgres
node_app -->|"renders map"| node_leaflet

click node_app "https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/App.jsx"
click node_auth_client "https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/authService.js"
click node_ride_client "https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/rideService.js"
click node_api_client "https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/api.js"
click node_api_server "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/server.js"
click node_auth "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/middleware/auth.js"
click node_ride_rules "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/services/rideService.js"
click node_ride_states "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/controllers/rideController.js"
click node_user_profiles "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/controllers/userController.js"
click node_user_model "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/models/User.js"
click node_ride_model "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/models/Ride.js"
click node_db_access "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/db.js"
click node_json_store "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/db.js"
click node_projector "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/postgres-projector.js"
click node_schema "https://github.com/sunkumahesh-777/riderelay/blob/main/database/schema.sql"
click node_locations "https://github.com/sunkumahesh-777/riderelay/blob/main/backend/locations.js"

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_app,node_auth_client,node_ride_client,node_api_client toneBlue
class node_api_server,node_auth,node_ride_rules,node_ride_states,node_user_profiles,node_user_model,node_ride_model,node_locations toneAmber
class node_db_access,node_json_store,node_projector,node_schema toneMint
class node_postgres,node_leaflet toneRose
class node_rider,node_captain toneIndigo
```

## Components

### Web app

- [RideRelay UI](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth client](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [Ride client](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/rideService.js): `frontend/src/services/rideService.js`
- [HTTP client](https://github.com/sunkumahesh-777/riderelay/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and domain

- [HTTP API](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Route and seat rules](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/services/rideService.js): `backend/services/rideService.js`
- [Ride status rules](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/controllers/rideController.js): `backend/controllers/rideController.js`
- [Profile updates](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [User records](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/models/User.js): `backend/models/User.js`
- [Ride records](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/models/Ride.js): `backend/models/Ride.js`
- [Location hubs](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/locations.js): `backend/locations.js`

### Persistence

- [Database access](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/db.js): `backend/db.js`
- [Local JSON state](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/db.js): `backend/db.js`
- [Postgres projection](https://github.com/sunkumahesh-777/riderelay/blob/main/backend/postgres-projector.js): `backend/postgres-projector.js`
- [Relational schema](https://github.com/sunkumahesh-777/riderelay/blob/main/database/schema.sql): `database/schema.sql`

### External services

- **PostgreSQL**
- **Map tiles**

### Other components

- **Rider**
- **Captain**

## Connections

- Rider → RideRelay UI: uses
- Captain → RideRelay UI: uses
- RideRelay UI → Auth client: signs in
- RideRelay UI → Ride client: searches and requests
- RideRelay UI → HTTP client: loads data
- Auth client → HTTP client: sends auth requests
- Ride client → HTTP client: sends ride requests
- HTTP client → HTTP API: HTTP requests
- HTTP API → Database access: reads and writes
- Database access → Local JSON state: fallback state
- Database access → Postgres projection: projects saved data
- Postgres projection → PostgreSQL: writes projection
- PostgreSQL → Relational schema: uses schema
- HTTP API → PostgreSQL: optional storage
- RideRelay UI → Map tiles: renders map
