# glyphcoder/odoo_coryd architecture

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

- Interactive diagram: https://gitdiagram.com/glyphcoder/odoo_coryd
- Repository: https://github.com/glyphcoder/odoo_coryd

## Overview

#### Purpose and Entry Points
Enterprise CoRYD is a multi-tenant employee carpooling platform: users offer/find rides, book and manage trips, share live location, chat/call, and settle fares; organization admins oversee users, vehicles, and reports. The React SPA starts at `client/src/main.jsx` and `client/src/App.jsx`. The Node API and Socket.IO server start at `server/src/index.js`.

#### Client Application
The Vite React client owns authenticated navigation, role-oriented dashboards, and trip workflows. Authentication state is centralized in `client/src/auth/AuthContext.jsx`; REST calls and realtime client setup are separated into `client/src/api.js` and `client/src/socket.js`. Core user journeys are implemented by `client/src/pages/FindRide.jsx`, `client/src/pages/OfferRide.jsx`, and `client/src/pages/TripDetail.jsx`; administrative oversight is in `client/src/pages/AdminDashboard.jsx`.

#### API and Authorization Boundary
Express exposes JWT-protected `/api` route groups, with login/signup as the public boundary. JWT middleware in `server/src/middleware/auth.js` establishes identity and organization context before route handlers. Domain APIs are divided across `server/src/routes/rides.js`, `server/src/routes/bookings.js`, `server/src/routes/trips.js`, and related payment, wallet, vehicle, reporting, and admin route modules. Server configuration and PostgreSQL access are centralized in `server/src/config.js` and `server/src/db.js`.

#### Tenant Data Model and Isolation
PostgreSQL/Supabase is the system of record. The schema at `db/schema.sql` models organization-scoped tenant data, while `db/migrations/add_vehicle_documents.sql` evolves vehicle support. Tenant isolation is designed through organization-filtered queries, composite organization-aware foreign keys, and optional Postgres RLS policies in `db/rls.sql`. Database provisioning and demo data execution flow through `server/migrate.js` and `server/scripts/seed.js`.

#### Ride, Booking, and Trip Lifecycle
A driver publishes a ride; riders search and create bookings; the resulting trip progresses through status transitions and produces trip history, messages, and location pings. Server-side lifecycle ownership is concentrated in `server/src/routes/rides.js`, `server/src/routes/bookings.js`, and `server/src/routes/trips.js`. The UI consumes this flow primarily through `client/src/pages/FindRide.jsx` and `client/src/pages/TripDetail.jsx`.

#### Realtime Trips and Communications
Socket.IO provides a per-trip realtime boundary: participants join only authorized trip rooms, then exchange location updates, chat, presence, and WebRTC signaling. The server implementation is `server/src/sockets/index.js`; the client socket transport is `client/src/socket.js`. Live map rendering and peer audio behavior reside in `client/src/components/MapView.jsx`, `client/src/components/AudioCallOverlay.jsx`, and `client/src/hooks/useWebRTC.js`. Browser Geolocation feeds live tracking; WebRTC carries peer-to-peer audio after Socket.IO signaling.

#### External Services and Integrations
The runtime requires Node 18+ and PostgreSQL 14+ or Supabase. Geocoding, reverse lookup, and route calculation are proxied through `server/src/routes/geo.js`, using public Nominatim, OpenStreetMap, and OSRM services. Payment/wallet handling is split between `server/src/routes/payments.js` and `server/src/routes/wallet.js`, with Razorpay-oriented client controls in `client/src/components/RazorpayButton.jsx` and `client/src/components/RazorpayQR.jsx`; non-wallet card/UPI behavior is currently sandbox-oriented.

Main entry points: [`client/src/api.js`](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/api.js) (REST API Client), [`server/src/db.js`](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/db.js) (Database Access), [`server/src/middleware/auth.js`](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/middleware/auth.js) (JWT Tenant Guard), [`client/src/main.jsx`](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/main.jsx) (SPA Entry & Routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_entry["SPA Entry &amp; Routing<br/>React/Vite<br/>[main.jsx]"]
  node_auth_context["Auth State<br/>React context<br/>[AuthContext.jsx]"]
  node_client_api["REST API Client<br/>HTTP client<br/>[api.js]"]
  node_ride_pages["Ride Workflows<br/>React pages<br/>[FindRide.jsx]"]
  node_admin_dashboard["Admin Dashboard<br/>React page<br/>[AdminDashboard.jsx]"]
  node_socket_client["Realtime Client<br/>Socket.IO client<br/>[socket.js]"]
  node_live_trip_ui["Live Map &amp; Audio<br/>React/WebRTC<br/>[MapView.jsx]"]
  node_payment_ui["Payment Controls<br/>React component<br/>[RazorpayButton.jsx]"]
end

subgraph group_server["Node Backend"]
  node_api_server["API &amp; Socket Server<br/>Express/Socket.IO<br/>[index.js]"]
  node_jwt_auth["JWT Tenant Guard<br/>Express middleware<br/>[auth.js]"]
  node_domain_routes["Ride, Booking &amp; Trip APIs<br/>Express routes<br/>[trips.js]"]
  node_admin_support_routes["Admin, Vehicle &amp; Reporting APIs<br/>Express routes"]
  node_realtime_server["Trip Room Gateway<br/>Socket.IO handlers<br/>[index.js]"]
  node_geo_proxy["Geo Proxy<br/>Express routes<br/>[geo.js]"]
  node_payments_wallet["Payments &amp; Wallet APIs<br/>Express routes<br/>[payments.js]"]
  node_database_access["Database Access<br/>PostgreSQL client<br/>[db.js]"]
end

subgraph group_data["Data &amp; Integrations"]
  node_tenant_database[("Tenant System of Record<br/>PostgreSQL/Supabase<br/>[schema.sql]")]
  node_geo_services{{"Map &amp; Routing Services<br/>Nominatim/OSM/OSRM"}}
  node_webrtc_peers(("Peer Audio<br/>WebRTC"))
end

node_client_entry -->|"uses"| node_auth_context
node_client_entry -->|"routes to"| node_ride_pages
node_client_entry -->|"routes to"| node_admin_dashboard
node_auth_context -->|"authenticates requests"| node_client_api
node_ride_pages -->|"ride and booking calls"| node_client_api
node_admin_dashboard -->|"admin calls"| node_client_api
node_client_api -->|"JWT-protected /api"| node_api_server
node_payment_ui -->|"payment requests"| node_client_api
node_api_server -->|"protects routes"| node_jwt_auth
node_jwt_auth -->|"tenant context"| node_domain_routes
node_jwt_auth -->|"tenant context"| node_admin_support_routes
node_jwt_auth -->|"tenant context"| node_payments_wallet
node_api_server -->|"geo endpoints"| node_geo_proxy
node_domain_routes -->|"lifecycle persistence"| node_database_access
node_admin_support_routes -->|"tenant administration"| node_database_access
node_payments_wallet -->|"wallet records"| node_database_access
node_database_access -->|"queries"| node_tenant_database
node_geo_proxy -->|"proxies requests"| node_geo_services
node_socket_client -->|"authorized trip rooms"| node_realtime_server
node_live_trip_ui -->|"location and signaling"| node_socket_client
node_realtime_server -->|"validates trip access"| node_database_access
node_socket_client -.->|"signals peers"| node_webrtc_peers

click node_client_entry "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/main.jsx"
click node_auth_context "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/auth/AuthContext.jsx"
click node_client_api "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/api.js"
click node_ride_pages "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/pages/FindRide.jsx"
click node_admin_dashboard "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/pages/AdminDashboard.jsx"
click node_socket_client "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/socket.js"
click node_live_trip_ui "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/components/MapView.jsx"
click node_payment_ui "https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/components/RazorpayButton.jsx"
click node_api_server "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/index.js"
click node_jwt_auth "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/middleware/auth.js"
click node_domain_routes "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/trips.js"
click node_realtime_server "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/sockets/index.js"
click node_geo_proxy "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/geo.js"
click node_payments_wallet "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/payments.js"
click node_database_access "https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/db.js"
click node_tenant_database "https://github.com/glyphcoder/odoo_coryd/blob/main/db/schema.sql"

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_client_entry,node_auth_context,node_client_api,node_ride_pages,node_admin_dashboard,node_socket_client,node_live_trip_ui,node_payment_ui toneBlue
class node_api_server,node_jwt_auth,node_domain_routes,node_admin_support_routes,node_realtime_server,node_geo_proxy,node_payments_wallet,node_database_access toneAmber
class node_tenant_database,node_geo_services,node_webrtc_peers toneMint
```

## Components

### React Client

- [SPA Entry & Routing](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/main.jsx): React/Vite · Bootstraps authenticated, role-oriented navigation. · `client/src/main.jsx`
- [Auth State](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/auth/AuthContext.jsx): React context · `client/src/auth/AuthContext.jsx`
- [REST API Client](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/api.js): HTTP client · `client/src/api.js`
- [Ride Workflows](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/pages/FindRide.jsx): React pages · Find, offer, and manage trip journeys. · `client/src/pages/FindRide.jsx`
- [Admin Dashboard](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/pages/AdminDashboard.jsx): React page · `client/src/pages/AdminDashboard.jsx`
- [Realtime Client](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/socket.js): Socket.IO client · `client/src/socket.js`
- [Live Map & Audio](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/components/MapView.jsx): React/WebRTC · Displays location and establishes peer audio. · `client/src/components/MapView.jsx`
- [Payment Controls](https://github.com/glyphcoder/odoo_coryd/blob/main/client/src/components/RazorpayButton.jsx): React component · `client/src/components/RazorpayButton.jsx`

### Node Backend

- [API & Socket Server](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/index.js): Express/Socket.IO · Runtime entry point for REST and realtime traffic. · `server/src/index.js`
- [JWT Tenant Guard](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/middleware/auth.js): Express middleware · Establishes identity and organization context. · `server/src/middleware/auth.js`
- [Ride, Booking & Trip APIs](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/trips.js): Express routes · Owns lifecycle transitions and trip history. · `server/src/routes/trips.js`
- **Admin, Vehicle & Reporting APIs**: Express routes
- [Trip Room Gateway](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/sockets/index.js): Socket.IO handlers · Authorizes trip rooms and relays location, chat, presence, and signaling. · `server/src/sockets/index.js`
- [Geo Proxy](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/geo.js): Express routes · Proxies geocoding and route calculation. · `server/src/routes/geo.js`
- [Payments & Wallet APIs](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/routes/payments.js): Express routes · `server/src/routes/payments.js`
- [Database Access](https://github.com/glyphcoder/odoo_coryd/blob/main/server/src/db.js): PostgreSQL client · `server/src/db.js`

### Data & Integrations

- [Tenant System of Record](https://github.com/glyphcoder/odoo_coryd/blob/main/db/schema.sql): PostgreSQL/Supabase · Organization-scoped data with optional RLS. · `db/schema.sql`
- **Map & Routing Services**: Nominatim/OSM/OSRM
- **Peer Audio**: WebRTC · Browser peers carry audio after signaling.

## Connections

- SPA Entry & Routing → Auth State: uses
- SPA Entry & Routing → Ride Workflows: routes to
- SPA Entry & Routing → Admin Dashboard: routes to
- Auth State → REST API Client: authenticates requests
- Ride Workflows → REST API Client: ride and booking calls
- Admin Dashboard → REST API Client: admin calls
- REST API Client → API & Socket Server: JWT-protected /api
- Payment Controls → REST API Client: payment requests
- API & Socket Server → JWT Tenant Guard: protects routes
- JWT Tenant Guard → Ride, Booking & Trip APIs: tenant context
- JWT Tenant Guard → Admin, Vehicle & Reporting APIs: tenant context
- JWT Tenant Guard → Payments & Wallet APIs: tenant context
- API & Socket Server → Geo Proxy: geo endpoints
- Ride, Booking & Trip APIs → Database Access: lifecycle persistence
- Admin, Vehicle & Reporting APIs → Database Access: tenant administration
- Payments & Wallet APIs → Database Access: wallet records
- Database Access → Tenant System of Record: queries
- Geo Proxy → Map & Routing Services: proxies requests
- Realtime Client → Trip Room Gateway: authorized trip rooms
- Live Map & Audio → Realtime Client: location and signaling
- Trip Room Gateway → Database Access: validates trip access
- Realtime Client → Peer Audio: signals peers
