How glyphcoder/odoo_coryd works
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: api.js REST API Client · db.js Database Access · auth.js JWT Tenant Guard · main.jsx SPA Entry & Routing
Components 19
React Client
- SPA Entry & Routing · Bootstraps authenticated, role-oriented navigation.
client/src/main.jsx - Auth State
client/src/auth/AuthContext.jsx - REST API Client
client/src/api.js - Ride Workflows · Find, offer, and manage trip journeys.
client/src/pages/FindRide.jsx - Admin Dashboard
client/src/pages/AdminDashboard.jsx - Realtime Client
client/src/socket.js - Live Map & Audio · Displays location and establishes peer audio.
client/src/components/MapView.jsx - Payment Controls
client/src/components/RazorpayButton.jsx
Node Backend
- API & Socket Server · Runtime entry point for REST and realtime traffic.
server/src/index.js - JWT Tenant Guard · Establishes identity and organization context.
server/src/middleware/auth.js - Ride, Booking & Trip APIs · Owns lifecycle transitions and trip history.
server/src/routes/trips.js - Admin, Vehicle & Reporting APIs
- Trip Room Gateway · Authorizes trip rooms and relays location, chat, presence, and signaling.
server/src/sockets/index.js - Geo Proxy · Proxies geocoding and route calculation.
server/src/routes/geo.js - Payments & Wallet APIs
server/src/routes/payments.js - Database Access
server/src/db.js
Data & Integrations
- Tenant System of Record · Organization-scoped data with optional RLS.
db/schema.sql - Map & Routing Services
- Peer Audio · Browser peers carry audio after signaling.
Connections 22
- 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