# rishabhdev06/smart-ride- architecture

> Architecture diagram of the GitHub repository rishabhdev06/smart-ride-, 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/rishabhdev06/smart-ride-
- Repository: https://github.com/rishabhdev06/smart-ride-

## Overview

Smart Ride is a subscription-based ride-booking application. Users authenticate, choose a plan, request a ride, and follow its status; captains authenticate, receive and accept requests, verify an OTP, and complete rides. The backend coordinates subscription quota, ride state, mapping, persistence, and socket notifications. The README documents additional profile, cancellation, and live-location capabilities; some of their implementation wiring was not sampled, so uncertain connections are omitted.

Main entry points: [`Backend/app.js`](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/app.js) (HTTP API), [`Backend/controllers/ride.controller.js`](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/ride.controller.js) (Ride coordinator), [`frontend/src/App.jsx`](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/App.jsx) (Web app routes), [`Backend/services/maps.service.js`](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/maps.service.js) (Maps and matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Web app routes<br/>[App.jsx]"]
  node_user_pages["Rider pages<br/>[Home.jsx]"]
  node_captain_pages["Captain pages<br/>[CaptainHome.jsx]"]
  node_plan_pages["Plan pages<br/>[Plans.jsx]"]
  node_client_context["Client contexts"]
end

subgraph group_identity["Accounts and plans"]
  node_user_routes["User routes<br/>[user.routes.js]"]
  node_captain_routes["Captain routes<br/>[captain.routes.js]"]
  node_auth["JWT auth<br/>[auth.middleware.js]"]
  node_user_controller["User account<br/>[user.controller.js]"]
  node_captain_controller["Captain account"]
  node_plan_routes["Plan routes<br/>[plan.routes.js]"]
  node_subscription_routes["Subscription routes"]
  node_plan_service["Plan service<br/>[plan.service.js]"]
  node_subscription_service["Subscription service"]
end

subgraph group_rides["Ride operations"]
  node_ride_routes["Ride routes<br/>[ride.routes.js]"]
  node_ride_controller["Ride coordinator<br/>[ride.controller.js]"]
  node_ride_service["Ride lifecycle<br/>[ride.service.js]"]
end

subgraph group_platform["Services and state"]
  node_api["HTTP API<br/>[app.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_realtime["Maps and realtime"]
  node_maps_routes["Map routes<br/>[maps.routes.js]"]
  node_maps_service["Maps and matching<br/>[maps.service.js]"]
  node_geoapify["Geoapify"]
  node_socket["Socket server<br/>[socket.js]"]
end

node_rider(("Rider"))
node_captain_actor(("Captain"))

node_rider -->|"uses"| node_app
node_captain_actor -->|"uses"| node_app
node_app -->|"routes to"| node_user_pages
node_app -->|"routes to"| node_captain_pages
node_app -->|"routes to"| node_plan_pages
node_user_pages -->|"requests"| node_api
node_captain_pages -->|"requests"| node_api
node_plan_pages -->|"requests"| node_api
node_client_context -->|"fetches state"| node_api
node_api -->|"dispatches"| node_user_routes
node_api -->|"dispatches"| node_captain_routes
node_api -->|"dispatches"| node_plan_routes
node_api -->|"dispatches"| node_subscription_routes
node_api -->|"dispatches"| node_ride_routes
node_api -->|"dispatches"| node_maps_routes
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"authenticates"| node_auth
node_captain_routes -->|"dispatches"| node_captain_controller
node_captain_routes -->|"authenticates"| node_auth
node_user_controller -->|"reads/writes"| node_mongo
node_captain_controller -->|"reads/writes"| node_mongo
node_plan_routes -->|"dispatches"| node_plan_service
node_subscription_routes -->|"dispatches"| node_subscription_service
node_plan_service -->|"reads/writes"| node_mongo
node_subscription_service -->|"reads/writes"| node_mongo
node_ride_routes -->|"authenticates"| node_auth
node_ride_routes -->|"dispatches"| node_ride_controller
node_ride_controller -->|"calls"| node_ride_service
node_ride_controller -->|"checks subscription"| node_subscription_service
node_ride_controller -->|"geocodes pickup"| node_maps_service
node_ride_controller -->|"notifies captains"| node_socket
node_ride_service -->|"consumes/refunds quota"| node_subscription_service
node_ride_service -->|"gets route estimate"| node_maps_service
node_ride_service -->|"reads/writes"| node_mongo
node_maps_routes -->|"dispatches"| node_maps_service
node_maps_service -.->|"requests mapping data"| node_geoapify
node_maps_service -->|"reads captain locations"| node_mongo
node_socket -->|"delivers ride events"| node_captain_actor
node_socket -->|"delivers ride updates"| node_rider

click node_app "https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/App.jsx"
click node_user_pages "https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/Home.jsx"
click node_captain_pages "https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/CaptainHome.jsx"
click node_plan_pages "https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/Plans.jsx"
click node_client_context "https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/context/SubscriptionContext.jsx"
click node_api "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/app.js"
click node_user_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/user.routes.js"
click node_captain_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/captain.routes.js"
click node_auth "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/middlewares/auth.middleware.js"
click node_user_controller "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/user.controller.js"
click node_captain_controller "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/captain.controller.js"
click node_plan_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/plan.routes.js"
click node_subscription_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/subscription.routes.js"
click node_plan_service "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/plan.service.js"
click node_subscription_service "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/subscription.service.js"
click node_ride_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/ride.routes.js"
click node_ride_controller "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/ride.controller.js"
click node_ride_service "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/ride.service.js"
click node_maps_routes "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/maps.routes.js"
click node_maps_service "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/maps.service.js"
click node_socket "https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/socket.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_user_pages,node_captain_pages,node_plan_pages,node_client_context toneBlue
class node_user_routes,node_captain_routes,node_auth,node_user_controller,node_captain_controller,node_plan_routes,node_subscription_routes,node_plan_service,node_subscription_service toneAmber
class node_ride_routes,node_ride_controller,node_ride_service toneMint
class node_api,node_mongo toneRose
class node_maps_routes,node_maps_service,node_geoapify,node_socket,node_rider,node_captain_actor toneIndigo
```

## Components

### Web application

- [Web app routes](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Rider pages](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Captain pages](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/CaptainHome.jsx): `frontend/src/pages/CaptainHome.jsx`
- [Plan pages](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/pages/Plans.jsx): `frontend/src/pages/Plans.jsx`
- [Client contexts](https://github.com/rishabhdev06/smart-ride-/blob/main/frontend/src/context/SubscriptionContext.jsx): `frontend/src/context/SubscriptionContext.jsx`

### Accounts and plans

- [User routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/user.routes.js): `Backend/routes/user.routes.js`
- [Captain routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/captain.routes.js): `Backend/routes/captain.routes.js`
- [JWT auth](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/middlewares/auth.middleware.js): `Backend/middlewares/auth.middleware.js`
- [User account](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/user.controller.js): `Backend/controllers/user.controller.js`
- [Captain account](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/captain.controller.js): `Backend/controllers/captain.controller.js`
- [Plan routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/plan.routes.js): `Backend/routes/plan.routes.js`
- [Subscription routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/subscription.routes.js): `Backend/routes/subscription.routes.js`
- [Plan service](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/plan.service.js): `Backend/services/plan.service.js`
- [Subscription service](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/subscription.service.js): `Backend/services/subscription.service.js`

### Ride operations

- [Ride routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/ride.routes.js): `Backend/routes/ride.routes.js`
- [Ride coordinator](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/controllers/ride.controller.js): `Backend/controllers/ride.controller.js`
- [Ride lifecycle](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/ride.service.js): `Backend/services/ride.service.js`

### Services and state

- [HTTP API](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/app.js): `Backend/app.js`
- **MongoDB**

### Maps and realtime

- [Map routes](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/routes/maps.routes.js): `Backend/routes/maps.routes.js`
- [Maps and matching](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/services/maps.service.js): `Backend/services/maps.service.js`
- **Geoapify**
- [Socket server](https://github.com/rishabhdev06/smart-ride-/blob/main/Backend/socket.js): `Backend/socket.js`

### Other components

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

## Connections

- Rider → Web app routes: uses
- Captain → Web app routes: uses
- Web app routes → Rider pages: routes to
- Web app routes → Captain pages: routes to
- Web app routes → Plan pages: routes to
- Rider pages → HTTP API: requests
- Captain pages → HTTP API: requests
- Plan pages → HTTP API: requests
- Client contexts → HTTP API: fetches state
- HTTP API → User routes: dispatches
- HTTP API → Captain routes: dispatches
- HTTP API → Plan routes: dispatches
- HTTP API → Subscription routes: dispatches
- HTTP API → Ride routes: dispatches
- HTTP API → Map routes: dispatches
- User routes → User account: dispatches
- User routes → JWT auth: authenticates
- Captain routes → Captain account: dispatches
- Captain routes → JWT auth: authenticates
- User account → MongoDB: reads/writes
- Captain account → MongoDB: reads/writes
- Plan routes → Plan service: dispatches
- Subscription routes → Subscription service: dispatches
- Plan service → MongoDB: reads/writes
- Subscription service → MongoDB: reads/writes
- Ride routes → JWT auth: authenticates
- Ride routes → Ride coordinator: dispatches
- Ride coordinator → Ride lifecycle: calls
- Ride coordinator → Subscription service: checks subscription
- Ride coordinator → Maps and matching: geocodes pickup
- Ride coordinator → Socket server: notifies captains
- Ride lifecycle → Subscription service: consumes/refunds quota
- Ride lifecycle → Maps and matching: gets route estimate
- Ride lifecycle → MongoDB: reads/writes
- Map routes → Maps and matching: dispatches
- Maps and matching → Geoapify: requests mapping data
- Maps and matching → MongoDB: reads captain locations
- Socket server → Captain: delivers ride events
- Socket server → Rider: delivers ride updates
