# vinay99199/ride-share architecture

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

- Interactive diagram: https://gitdiagram.com/vinay99199/ride-share
- Repository: https://github.com/vinay99199/ride-share

## Overview

Ride-sharing backend with an evidenced registration and login path: clients reach the Express API, which routes authentication requests to the controller; registration verifies organization domains, stores user data, sends OTP email, and login issues JWTs. The README describes passenger bookings, driver approval and ride management, but this tree contains no corresponding controllers or routes; the graph therefore shows their available data models without inventing runtime flows. Source excerpts establish authentication wiring, while domain model connections are not shown.

Main entry points: [`backend/src/controllers/auth.controller.js`](https://github.com/vinay99199/ride-share/blob/main/backend/src/controllers/auth.controller.js) (Auth Controller), [`backend/src/routes/auth.routes.js`](https://github.com/vinay99199/ride-share/blob/main/backend/src/routes/auth.routes.js) (Auth Routes), [`backend/src/app.js`](https://github.com/vinay99199/ride-share/blob/main/backend/src/app.js) (Express API), [`backend/src/server.js`](https://github.com/vinay99199/ride-share/blob/main/backend/src/server.js) (Server Startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Authentication"]
  node_express_app["Express API<br/>[app.js]"]
  node_auth_routes["Auth Routes<br/>[auth.routes.js]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.js]"]
  node_auth_middleware["Token Middleware<br/>[auth.middleware.js]"]
  node_server["Server Startup<br/>[server.js]"]
end

subgraph group_identity["Identity Services"]
  node_user_model[("User Records<br/>[User.js]")]
  node_organization_model[("Organizations<br/>[Organization.js]")]
  node_email_service["OTP Email<br/>[email.js]"]
  node_jwt_generator["JWT Generator<br/>[generateToken.js]"]
  node_mongo_config["Mongo Connection<br/>[db.js]"]
end

subgraph group_ride_domain["Ride Domain"]
  node_ride_model[("Ride Records<br/>[Ride.js]")]
  node_booking_model[("Booking Records<br/>[Booking.js]")]
  node_vehicle_model[("Vehicle Records<br/>[Vehicle.js]")]
  node_rating_model[("Ratings<br/>[Rating.js]")]
  node_report_model[("Reports<br/>[Report.js]")]
end

node_client(("User or Client"))
node_mongodb[("MongoDB")]
node_mail_provider["Gmail SMTP"]

node_client -->|"sends requests"| node_express_app
node_express_app -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_auth_routes -->|"protects profile"| node_auth_middleware
node_server -->|"starts app"| node_express_app
node_server -->|"connects database"| node_mongo_config
node_mongo_config -->|"connects to"| node_mongodb
node_auth_controller -->|"reads and writes"| node_user_model
node_auth_controller -->|"checks organization"| node_organization_model
node_auth_controller -->|"sends OTP"| node_email_service
node_auth_controller -->|"creates token"| node_jwt_generator
node_auth_middleware -->|"loads user"| node_user_model
node_email_service -->|"sends mail"| node_mail_provider

click node_express_app "https://github.com/vinay99199/ride-share/blob/main/backend/src/app.js"
click node_auth_routes "https://github.com/vinay99199/ride-share/blob/main/backend/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/vinay99199/ride-share/blob/main/backend/src/controllers/auth.controller.js"
click node_auth_middleware "https://github.com/vinay99199/ride-share/blob/main/backend/src/middleware/auth.middleware.js"
click node_server "https://github.com/vinay99199/ride-share/blob/main/backend/src/server.js"
click node_user_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/User.js"
click node_organization_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Organization.js"
click node_email_service "https://github.com/vinay99199/ride-share/blob/main/backend/src/utils/email.js"
click node_jwt_generator "https://github.com/vinay99199/ride-share/blob/main/backend/src/utils/generateToken.js"
click node_mongo_config "https://github.com/vinay99199/ride-share/blob/main/backend/src/config/db.js"
click node_ride_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Ride.js"
click node_booking_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Booking.js"
click node_vehicle_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Vehicle.js"
click node_rating_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Rating.js"
click node_report_model "https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Report.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_express_app,node_auth_routes,node_auth_controller,node_auth_middleware,node_server,node_client toneBlue
class node_user_model,node_organization_model,node_email_service,node_jwt_generator,node_mongo_config,node_mongodb toneAmber
class node_ride_model,node_booking_model,node_vehicle_model,node_rating_model,node_report_model toneMint
class node_mail_provider toneIndigo
```

## Components

### API and Authentication

- [Express API](https://github.com/vinay99199/ride-share/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth Routes](https://github.com/vinay99199/ride-share/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Auth Controller](https://github.com/vinay99199/ride-share/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Token Middleware](https://github.com/vinay99199/ride-share/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [Server Startup](https://github.com/vinay99199/ride-share/blob/main/backend/src/server.js): `backend/src/server.js`

### Identity Services

- [User Records](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Organizations](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Organization.js): `backend/src/models/Organization.js`
- [OTP Email](https://github.com/vinay99199/ride-share/blob/main/backend/src/utils/email.js): `backend/src/utils/email.js`
- [JWT Generator](https://github.com/vinay99199/ride-share/blob/main/backend/src/utils/generateToken.js): `backend/src/utils/generateToken.js`
- [Mongo Connection](https://github.com/vinay99199/ride-share/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### Ride Domain

- [Ride Records](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Ride.js): `backend/src/models/Ride.js`
- [Booking Records](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Booking.js): `backend/src/models/Booking.js`
- [Vehicle Records](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Vehicle.js): `backend/src/models/Vehicle.js`
- [Ratings](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Rating.js): `backend/src/models/Rating.js`
- [Reports](https://github.com/vinay99199/ride-share/blob/main/backend/src/models/Report.js): `backend/src/models/Report.js`

### Other components

- **User or Client**
- **MongoDB**
- **Gmail SMTP**

## Connections

- User or Client → Express API: sends requests (evidence: `backend/src/app.js`)
- Express API → Auth Routes: mounts routes (evidence: `backend/src/app.js`)
- Auth Routes → Auth Controller: dispatches requests (evidence: `backend/src/routes/auth.routes.js`)
- Auth Routes → Token Middleware: protects profile (evidence: `backend/src/routes/auth.routes.js`)
- Server Startup → Express API: starts app (evidence: `backend/src/server.js`)
- Server Startup → Mongo Connection: connects database (evidence: `backend/src/server.js`)
- Mongo Connection → MongoDB: connects to (evidence: `backend/src/config/db.js`)
- Auth Controller → User Records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Auth Controller → Organizations: checks organization (evidence: `backend/src/controllers/auth.controller.js`)
- Auth Controller → OTP Email: sends OTP (evidence: `backend/src/controllers/auth.controller.js`)
- Auth Controller → JWT Generator: creates token (evidence: `backend/src/controllers/auth.controller.js`)
- Token Middleware → User Records: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- OTP Email → Gmail SMTP: sends mail (evidence: `backend/src/utils/email.js`)
