How amit2003dh/co-ride-app works
Purpose and deployment
Co-Ride is a MERN ride-sharing marketplace: authenticated users offer rides, discover/book rides, manage active/history views, submit reviews/feedback, and use rider/passenger/admin capabilities. The React/Vite client is deployed to Vercel; the Express API is intended for Render and persists data in MongoDB Atlas.
Application entry points
• Client bootstrap and route composition: client/src/main.jsx, client/src/App.jsx.
• API process and Socket.IO server bootstrap: server/server.js.
• Database connection boundary: server/config/db.js.
• Environment-specific client/server settings are represented by client/.env.example and server/.env.example.
Frontend navigation and access control
React Router pages form the user workflow: public home/login/registration, ride search/offer/dashboard/profile, active rides, ride history, and administration. Route guards separate authenticated and admin-only flows via client/src/components/PrivateRoute.jsx and client/src/components/AdminRoute.jsx.
Key product screens are client/src/pages/FindRidePage.jsx, client/src/pages/OfferRidePage.jsx, and client/src/pages/ActiveRidePage.jsx; dashboard variants are client/src/pages/DashboardPage.jsx and client/src/pages/AdminDashboardPage.jsx.
Client state and API boundary
Redux Toolkit centralizes domain state. Each domain pairs a slice with a service that calls the backend: authentication (client/src/store/auth/authSlice.js, client/src/store/auth/authService.js), rides (client/src/store/ride/rideSlice.js, client/src/store/ride/rideService.js), and payments (client/src/store/payment/paymentSlice.js, client/src/store/payment/paymentService.js). The root store is client/src/store/store.js.
UI components consume this state and drive interactive ride operations, including map/chat-oriented views in client/src/components/LiveMap.jsx and client/src/components/ChatBox.jsx. Socket.IO-client supports real-time interactions.
HTTP API and authorization pipeline
Express routes partition the API by domain: server/routes/auth.js, server/routes/rides.js, server/routes/payment.js, server/routes/admin.js, plus user, review, and feedback routes. Routes delegate request handling to corresponding controllers, notably server/controllers/authController.js, server/controllers/rideController.js, and server/controllers/paymentController.js.
JWT authentication is enforced at the middleware boundary in server/middleware/authMiddleware.js; privileged operations add server/middleware/adminMiddleware.js. This makes controllers responsible for domain operations after identity/role validation.
Core persistence model
MongoDB/Mongoose is the system of record. server/models/User.js owns accounts, credentials, and roles; server/models/Ride.js represents offered/booked ride lifecycle data. Reputation and support data are modeled separately in server/models/Review.js and server/models/Feedback.js.
Primary flow: a user authenticates, the client stores/uses authenticated state, protected requests reach ride controllers, ride changes persist through Mongoose, and UI state is refreshed or updated through Redux and real-time Socket.IO events.
Supporting product boundaries
Payment handling is isolated behind server/routes/payment.js and server/controllers/paymentController.js, with client orchestration in client/src/store/payment/paymentService.js. Reviews and feedback similarly remain distinct domains through server/controllers/reviewController.js and server/controllers/feedbackController.js, surfaced by client/src/components/ReviewModal.jsx and client/src/components/FeedbackModal.jsx.
Components 19
React Client
Vite app deployed to Vercel.
- App & routes · Bootstraps the client and composes product routes.
client/src/main.jsx - Route guards · Separates authenticated and admin-only routes.
client/src/components/PrivateRoute.jsx - Ride workflow pages · Find, offer, active ride, and dashboard experiences.
client/src/pages/FindRidePage.jsx - Redux store · Central client domain state.
client/src/store/store.js - Auth slice & service · Maintains session state and calls auth APIs.
client/src/store/auth/authService.js - Ride slice & service · Manages ride discovery and lifecycle requests.
client/src/store/ride/rideService.js - Payment slice & service · Orchestrates payment API requests.
client/src/store/payment/paymentService.js - Live map & chat · Interactive views consume real-time updates.
client/src/components/LiveMap.jsx
Express API
Render-targeted API and real-time server.
- API & Socket.IO server · Hosts HTTP APIs and real-time connections.
server/server.js - Domain routes · Auth, rides, payments, admin, user, review, and feedback endpoints.
server/routes/rides.js - JWT & admin middleware · Validates identity and privileged access before controllers.
server/middleware/authMiddleware.js - Auth controller · Handles authentication operations.
server/controllers/authController.js - Ride controller · Executes offered and booked ride lifecycle operations.
server/controllers/rideController.js - Payment controller · Isolated payment handling boundary.
server/controllers/paymentController.js - Review & feedback controllers · Handles reputation and support submissions.
server/controllers/reviewController.js - Database connection · Connects the API to MongoDB Atlas.
server/config/db.js
MongoDB Atlas
Mongoose-backed system of record.
- User model · Accounts, credentials, and roles.
server/models/User.js - Ride model · Offered and booked ride lifecycle data.
server/models/Ride.js - Review & feedback models · Reputation and support records.
server/models/Review.js
Connections 24
- App & routes → Route guards: applies access control
- App & routes → Ride workflow pages: renders routes
- Ride workflow pages → Redux store: reads and dispatches
- Redux store → Auth slice & service: contains
- Redux store → Ride slice & service: contains
- Redux store → Payment slice & service: contains
- Ride workflow pages → Live map & chat: uses
- Auth slice & service → API & Socket.IO server: auth HTTP
- Ride slice & service → API & Socket.IO server: ride HTTP
- Payment slice & service → API & Socket.IO server: payment HTTP
- Live map & chat → API & Socket.IO server: Socket.IO
- API & Socket.IO server → Domain routes: mounts
- Domain routes → JWT & admin middleware: protects requests
- JWT & admin middleware → Auth controller: authorizes auth operations
- JWT & admin middleware → Ride controller: authorizes ride operations
- JWT & admin middleware → Payment controller: authorizes payment operations
- JWT & admin middleware → Review & feedback controllers: authorizes submissions
- Auth controller → User model: reads and writes
- Ride controller → Ride model: reads and writes
- Review & feedback controllers → Review & feedback models: writes
- Database connection → User model: connects
- Database connection → Ride model: connects
- Database connection → Review & feedback models: connects
- API & Socket.IO server → Live map & chat: ride events