# mher0919/netride architecture

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

- Interactive diagram: https://gitdiagram.com/mher0919/netride
- Repository: https://github.com/mher0919/netride

## Overview

This repository is a ride-hailing platform: rider and driver mobile apps sit alongside an operations dashboard and sponsor portal, with a backend for ride dispatch, routing, payments, rewards, and administration. The principal ride path includes request handling, driver matching, fare calculation, and settlement; sponsor funding and rewards form distinct supporting workflows. Source excerpts and the index establish several service dependencies, but do not expose the backend’s full route wiring or most frontend API calls, so those links are omitted or marked unverified.

Main entry points: [`backend/src/services/dispatch-engine.service.ts`](https://github.com/mher0919/netride/blob/master/backend/src/services/dispatch-engine.service.ts) (Driver matching), [`backend/src/modules/sponsor/sponsor-portal.controller.ts`](https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/sponsor-portal.controller.ts) (Sponsor portal API), [`backend/src/modules/admin/admin.controller.ts`](https://github.com/mher0919/netride/blob/master/backend/src/modules/admin/admin.controller.ts) (Admin operations), [`backend/src/modules/ride/ride.controller.ts`](https://github.com/mher0919/netride/blob/master/backend/src/modules/ride/ride.controller.ts) (Ride handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client applications"]
  node_rider["Rider app"]
  node_driver["Driver app"]
  node_adminui["Admin dashboard<br/>[App.tsx]"]
  node_sponsorui["Sponsor portal<br/>[App.tsx]"]
end

subgraph group_core["Ride platform"]
  node_rideapi["Ride handling<br/>[ride.controller.ts]"]
  node_rideservice["Ride lifecycle<br/>[ride.service.ts]"]
  node_dispatch["Driver matching"]
  node_driverdomain["Driver operations<br/>[driver.service.ts]"]
  node_routing["Route engines"]
  node_adminapi["Admin operations"]
end

subgraph group_money["Payments and rewards"]
  node_payments["Payment processing<br/>[stripe.gateway.ts]"]
  node_withdrawals["Driver withdrawals"]
  node_ledger[("Financial ledger")]
  node_rewards["Ride rewards"]
  node_promo["Promotions<br/>[promo.service.ts]"]
  node_credits["Ride credits<br/>[credits.service.ts]"]
end

subgraph group_sponsor["Sponsor services"]
  node_sponsorapi["Sponsor portal API"]
  node_sponsordomain["Sponsor budgets<br/>[sponsor.service.ts]"]
  node_redemption["Special redemption"]
end

subgraph group_foundation["Runtime infrastructure"]
  node_database["Database connection<br/>[database.ts]"]
  node_redis["Redis connection<br/>[redis.ts]"]
end

node_operator(("Operations staff"))
node_rideractor(("Rider"))
node_driveractor(("Driver"))
node_sponsoractor(("Sponsor user"))
node_postgres[("PostgreSQL")]
node_redisservice[("Redis service")]

node_rideractor -.->|"uses"| node_rider
node_driveractor -.->|"uses"| node_driver
node_operator -.->|"uses"| node_adminui
node_sponsoractor -.->|"uses"| node_sponsorui
node_rider -.->|"requests rides"| node_rideapi
node_driver -.->|"updates rides"| node_rideapi
node_adminui -.->|"calls API"| node_adminapi
node_sponsorui -.->|"calls API"| node_sponsorapi
node_rideapi -->|"delegates"| node_rideservice
node_rideapi -.->|"dispatches"| node_dispatch
node_dispatch -->|"checks eligibility"| node_driverdomain
node_dispatch -->|"reads ride data"| node_rideservice
node_dispatch -.->|"gets route"| node_routing
node_dispatch -.->|"calculates fare share"| node_payments
node_dispatch -->|"queries"| node_database
node_dispatch -->|"queries"| node_redis
node_rideservice -->|"triggers ride rewards"| node_rewards
node_rideapi -->|"uses fare pricing"| node_payments
node_adminapi -->|"reads financial data"| node_ledger
node_adminapi -->|"manages rides"| node_rideservice
node_adminapi -->|"queries"| node_database
node_adminapi -->|"reads live state"| node_redis
node_rewards -->|"applies promotions"| node_promo
node_rewards -->|"applies credits"| node_credits
node_rewards -.->|"settles ride"| node_ledger
node_sponsorapi -->|"manages sponsors"| node_sponsordomain
node_sponsorapi -->|"handles redemption"| node_redemption
node_sponsorapi -->|"uses payments"| node_payments
node_sponsorapi -->|"handles withdrawals"| node_withdrawals
node_sponsorapi -->|"records finances"| node_ledger
node_sponsordomain -->|"uses ledger amounts"| node_ledger
node_database -->|"connects"| node_postgres
node_redis -->|"connects"| node_redisservice

click node_adminui "https://github.com/mher0919/netride/blob/master/apps/admin_dashboard/src/App.tsx"
click node_sponsorui "https://github.com/mher0919/netride/blob/master/apps/sponsor_portal/src/App.tsx"
click node_rideapi "https://github.com/mher0919/netride/blob/master/backend/src/modules/ride/ride.controller.ts"
click node_rideservice "https://github.com/mher0919/netride/blob/master/backend/src/modules/ride/ride.service.ts"
click node_dispatch "https://github.com/mher0919/netride/blob/master/backend/src/services/dispatch-engine.service.ts"
click node_driverdomain "https://github.com/mher0919/netride/blob/master/backend/src/modules/driver/driver.service.ts"
click node_routing "https://github.com/mher0919/netride/blob/master/backend/src/modules/routing/google-routes.engine.ts"
click node_adminapi "https://github.com/mher0919/netride/blob/master/backend/src/modules/admin/admin.controller.ts"
click node_payments "https://github.com/mher0919/netride/blob/master/backend/src/modules/payments/stripe.gateway.ts"
click node_withdrawals "https://github.com/mher0919/netride/blob/master/backend/src/modules/payments/withdrawal.service.ts"
click node_ledger "https://github.com/mher0919/netride/blob/master/backend/src/services/financial-ledger.service.ts"
click node_rewards "https://github.com/mher0919/netride/blob/master/backend/src/services/reward-engine.service.ts"
click node_promo "https://github.com/mher0919/netride/blob/master/backend/src/modules/promo/promo.service.ts"
click node_credits "https://github.com/mher0919/netride/blob/master/backend/src/modules/credits/credits.service.ts"
click node_sponsorapi "https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/sponsor-portal.controller.ts"
click node_sponsordomain "https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/sponsor.service.ts"
click node_redemption "https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/special-redemption.service.ts"
click node_database "https://github.com/mher0919/netride/blob/master/backend/src/config/database.ts"
click node_redis "https://github.com/mher0919/netride/blob/master/backend/src/config/redis.ts"

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_rider,node_driver,node_adminui,node_sponsorui,node_sponsoractor toneBlue
class node_rideapi,node_rideservice,node_dispatch,node_driverdomain,node_routing,node_adminapi,node_postgres,node_redisservice toneAmber
class node_payments,node_withdrawals,node_ledger,node_rewards,node_promo,node_credits toneMint
class node_sponsorapi,node_sponsordomain,node_redemption toneRose
class node_database,node_redis,node_operator,node_rideractor,node_driveractor toneIndigo
```

## Components

### Client applications

- **Rider app**
- **Driver app**
- [Admin dashboard](https://github.com/mher0919/netride/blob/master/apps/admin_dashboard/src/App.tsx): `apps/admin_dashboard/src/App.tsx`
- [Sponsor portal](https://github.com/mher0919/netride/blob/master/apps/sponsor_portal/src/App.tsx): `apps/sponsor_portal/src/App.tsx`

### Ride platform

- [Ride handling](https://github.com/mher0919/netride/blob/master/backend/src/modules/ride/ride.controller.ts): `backend/src/modules/ride/ride.controller.ts`
- [Ride lifecycle](https://github.com/mher0919/netride/blob/master/backend/src/modules/ride/ride.service.ts): `backend/src/modules/ride/ride.service.ts`
- [Driver matching](https://github.com/mher0919/netride/blob/master/backend/src/services/dispatch-engine.service.ts): `backend/src/services/dispatch-engine.service.ts`
- [Driver operations](https://github.com/mher0919/netride/blob/master/backend/src/modules/driver/driver.service.ts): `backend/src/modules/driver/driver.service.ts`
- [Route engines](https://github.com/mher0919/netride/blob/master/backend/src/modules/routing/google-routes.engine.ts): `backend/src/modules/routing/google-routes.engine.ts`
- [Admin operations](https://github.com/mher0919/netride/blob/master/backend/src/modules/admin/admin.controller.ts): `backend/src/modules/admin/admin.controller.ts`

### Payments and rewards

- [Payment processing](https://github.com/mher0919/netride/blob/master/backend/src/modules/payments/stripe.gateway.ts): `backend/src/modules/payments/stripe.gateway.ts`
- [Driver withdrawals](https://github.com/mher0919/netride/blob/master/backend/src/modules/payments/withdrawal.service.ts): `backend/src/modules/payments/withdrawal.service.ts`
- [Financial ledger](https://github.com/mher0919/netride/blob/master/backend/src/services/financial-ledger.service.ts): `backend/src/services/financial-ledger.service.ts`
- [Ride rewards](https://github.com/mher0919/netride/blob/master/backend/src/services/reward-engine.service.ts): `backend/src/services/reward-engine.service.ts`
- [Promotions](https://github.com/mher0919/netride/blob/master/backend/src/modules/promo/promo.service.ts): `backend/src/modules/promo/promo.service.ts`
- [Ride credits](https://github.com/mher0919/netride/blob/master/backend/src/modules/credits/credits.service.ts): `backend/src/modules/credits/credits.service.ts`

### Sponsor services

- [Sponsor portal API](https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/sponsor-portal.controller.ts): `backend/src/modules/sponsor/sponsor-portal.controller.ts`
- [Sponsor budgets](https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/sponsor.service.ts): `backend/src/modules/sponsor/sponsor.service.ts`
- [Special redemption](https://github.com/mher0919/netride/blob/master/backend/src/modules/sponsor/special-redemption.service.ts): `backend/src/modules/sponsor/special-redemption.service.ts`

### Runtime infrastructure

- [Database connection](https://github.com/mher0919/netride/blob/master/backend/src/config/database.ts): `backend/src/config/database.ts`
- [Redis connection](https://github.com/mher0919/netride/blob/master/backend/src/config/redis.ts): `backend/src/config/redis.ts`

### Other components

- **Operations staff**
- **Rider**
- **Driver**
- **Sponsor user**
- **PostgreSQL**
- **Redis service**

## Connections

- Rider → Rider app: uses
- Driver → Driver app: uses
- Operations staff → Admin dashboard: uses
- Sponsor user → Sponsor portal: uses
- Rider app → Ride handling: requests rides
- Driver app → Ride handling: updates rides
- Admin dashboard → Admin operations: calls API
- Sponsor portal → Sponsor portal API: calls API
- Ride handling → Ride lifecycle: delegates (evidence: `backend/src/modules/ride/ride.controller.ts`)
- Ride handling → Driver matching: dispatches
- Driver matching → Driver operations: checks eligibility (evidence: `backend/src/services/dispatch-engine.service.ts`)
- Driver matching → Ride lifecycle: reads ride data (evidence: `backend/src/services/dispatch-engine.service.ts`)
- Driver matching → Route engines: gets route
- Driver matching → Payment processing: calculates fare share
- Driver matching → Database connection: queries (evidence: `backend/src/services/dispatch-engine.service.ts`)
- Driver matching → Redis connection: queries (evidence: `backend/src/services/dispatch-engine.service.ts`)
- Ride lifecycle → Ride rewards: triggers ride rewards (evidence: `backend/src/services/reward-engine.service.ts`)
- Ride handling → Payment processing: uses fare pricing (evidence: `backend/src/modules/ride/ride.controller.ts`)
- Admin operations → Financial ledger: reads financial data (evidence: `backend/src/modules/admin/admin.controller.ts`)
- Admin operations → Ride lifecycle: manages rides (evidence: `backend/src/modules/admin/admin.controller.ts`)
- Admin operations → Database connection: queries (evidence: `backend/src/modules/admin/admin.controller.ts`)
- Admin operations → Redis connection: reads live state (evidence: `backend/src/modules/admin/admin.controller.ts`)
- Ride rewards → Promotions: applies promotions (evidence: `backend/src/services/reward-engine.service.ts`)
- Ride rewards → Ride credits: applies credits (evidence: `backend/src/services/reward-engine.service.ts`)
- Ride rewards → Financial ledger: settles ride
- Sponsor portal API → Sponsor budgets: manages sponsors (evidence: `backend/src/modules/sponsor/sponsor-portal.controller.ts`)
- Sponsor portal API → Special redemption: handles redemption (evidence: `backend/src/modules/sponsor/sponsor-portal.controller.ts`)
- Sponsor portal API → Payment processing: uses payments (evidence: `backend/src/modules/sponsor/sponsor-portal.controller.ts`)
- Sponsor portal API → Driver withdrawals: handles withdrawals (evidence: `backend/src/modules/sponsor/sponsor-portal.controller.ts`)
- Sponsor portal API → Financial ledger: records finances (evidence: `backend/src/modules/sponsor/sponsor-portal.controller.ts`)
- Sponsor budgets → Financial ledger: uses ledger amounts (evidence: `backend/src/modules/sponsor/sponsor.service.ts`)
- Database connection → PostgreSQL: connects (evidence: `backend/src/config/database.ts`)
- Redis connection → Redis service: connects (evidence: `backend/src/config/redis.ts`)
