Problem & Solution
Problem
Vehicle rental and ride-booking marketplaces require complex orchestration: users need to discover nearby vehicles, partners need onboarding and verification, bookings need payment and commission handling, rides need real-time tracking, and all parties need secure communication.
Solution
Built a full-stack Next.js marketplace with geospatial vehicle discovery using GeoJSON, eight-step partner onboarding with video KYC, automated commission calculations, real-time ride tracking, OTP-based confirmations, and AI-powered messaging.
Technical Metrics
Technology Stack
Frontend
Backend
Geospatial
Realtime
Integrations
Other
User Roles & Features
User
- Search vehicles by location and type
- View nearby vehicles within 10km on interactive map
- Filter by vehicle category, price, availability
- Book vehicles with date/time selection
- Make payments via Razorpay
- Track ride in real-time
- Chat with partner using AI-assisted messaging
- Confirm pickup with OTP
- Rate and review completed rides
Partner
- Complete eight-step onboarding with video KYC
- Upload vehicle details and photos
- Manage availability and pricing
- Accept or decline booking requests
- Navigate to pickup location
- Confirm pickup with customer OTP
- Update ride status in real-time
- Confirm drop with OTP
- View earnings with platform commission breakdown
- Track payment history
Admin
- Review and approve partner applications
- Verify video KYC submissions
- Manage vehicle listings and categories
- Monitor active bookings
- Handle disputes and support
- Configure platform commission rates
- Generate reports and analytics
- Manage user and partner accounts
Booking Lifecycle
Search Vehicle
User enters location; GeoJSON query finds vehicles within 10km radius using geospatial indexing
Select
User views vehicle details, partner rating, pricing, and availability
Book
User selects dates/times, confirms booking request
Pay
Razorpay payment with HMAC verification; amount includes platform commission
Partner Confirmation
Partner receives notification, accepts or declines booking
Pickup OTP
User receives OTP; partner confirms pickup by entering OTP
Live Ride
Socket.IO broadcasts real-time location; user tracks ride on map
Drop OTP
Partner enters drop OTP to complete ride; triggers payment settlement
Complete
Booking marked complete; commission calculated; earnings updated; user can rate
Partner Onboarding Workflow
Personal Information
Name, contact details, address, date of birth
Identity Verification
Government ID upload and verification
Video KYC
ZegoCloud video call with admin for identity verification
Vehicle Registration
Vehicle registration documents and verification
Vehicle Details
Make, model, year, category, seating capacity
Vehicle Photos
Upload vehicle photos to Cloudinary
Pricing & Availability
Set rental rates and availability schedule
Bank Details
Bank account for earnings settlement
System Architecture
Rydex uses Next.js 14 with TypeScript for full-stack development, MongoDB with geospatial indexing for vehicle discovery, Socket.IO for real-time features, and integrates services for payments, video KYC, and AI assistance.
Frontend Application
React.js, Next.js 14, TypeScript, Redux Toolkit
- User, partner, and admin interfaces
- Interactive maps
- Real-time tracking
- Chat system
- Multi-step onboarding
API Routes
Next.js API Routes, 43 endpoints
- Authentication & authorization
- Vehicle CRUD
- Geospatial queries
- Booking management
- Payment processing
- Commission calculations
- Onboarding workflows
Database
MongoDB, Mongoose, 6 models
- User & partner profiles
- Vehicle listings with geospatial indexes
- Booking records
- Payment & earnings
- Reviews & ratings
- Onboarding status
Geospatial Layer
GeoJSON, Leaflet, MongoDB geospatial indexes
- Vehicle proximity search
- Radius-based discovery
- Route visualization
- Location tracking
Real-Time Layer
Socket.IO
- Live ride tracking
- Instant messaging
- Booking notifications
- Status updates
External Services
Razorpay, ZegoCloud, Cloudinary, Gemini AI
- Payment processing
- Video KYC verification
- Image storage
- AI chat assistance
Key Engineering Features
Geospatial Vehicle Discovery
MongoDB 2dsphere index enables efficient proximity queries. GeoJSON stores vehicle locations; Leaflet displays results on interactive map. 10km radius search using $near operator.
Eight-Step Partner Onboarding
Progressive workflow guides partners through registration. Each step validates before advancing. ZegoCloud video KYC provides real-time identity verification with admin.
Platform Commission Engine
10% platform commission calculated on each booking. Earnings split: user payment → platform commission → partner earnings. Real-time calculation and transparent display.
OTP-Based Confirmations
Two-stage verification: pickup OTP confirms ride start; drop OTP confirms completion. Prevents fraud and creates audit trail.
Real-Time Ride Tracking
Socket.IO rooms per ride. Partner app broadcasts location updates; user sees live position on map. Optimized update frequency balances accuracy and performance.
Video KYC Integration
ZegoCloud enables real-time video calls between partner and admin for identity verification. Records verification status and timestamp.
Engineering Decisions & Tradeoffs
GeoJSON and MongoDB 2dsphere index for vehicle discovery
Rationale: Native geospatial support in MongoDB. 2dsphere index enables efficient proximity queries. GeoJSON is standard for geographic data.
Tradeoffs: MongoDB geospatial features are powerful but limited compared to PostGIS. For current scale, MongoDB is sufficient.
Multi-step onboarding workflow with state machine
Rationale: Complex onboarding requires progressive disclosure and validation. State machine ensures proper sequence and prevents skipping steps.
Tradeoffs: More complex than single form, but significantly better UX and data quality.
Platform commission calculated at booking time
Rationale: Commission rate might change; calculating and storing at booking prevents historical data issues. Clear separation of user payment, commission, and partner earnings.
Tradeoffs: Stored calculations use more space but provide accuracy and audit trail.
ZegoCloud for video KYC
Rationale: Specialized service handles video infrastructure complexity. Reliable video quality and recording capabilities.
Tradeoffs: Third-party dependency and cost; considered building custom but KYC reliability is critical.
Six Mongoose models for data separation
Rationale: Clear separation: User, Partner, Vehicle, Booking, Payment, Review. Easier to query and maintain than single combined model.
Tradeoffs: More models require more joins; used Mongoose populate for relationships.
OTP at both pickup and drop
Rationale: Two-party verification at critical transitions prevents 'ghost rides' and disputed completions.
Tradeoffs: Slight UX friction; considered GPS-based completion but OTP is more reliable.
Challenges & Solutions
Accurate geospatial search across varying locations
Solution: Implemented GeoJSON with proper coordinate order (longitude, latitude). Used 2dsphere index. Tested with various radius values to balance coverage and relevance.
Managing complex booking state across multiple actors
Solution: State machine with clear transitions: requested → accepted → pickup_confirmed → in_progress → drop_confirmed → completed. Each transition requires specific actor and event.
Commission calculations and earnings transparency
Solution: Store commission rate, user payment, commission amount, and partner earning at booking time. Display breakdown clearly in partner dashboard.
Eight-step onboarding without user fatigue
Solution: Save progress at each step; allow partial completion; clear progress indicator; estimated time remaining; skip non-critical steps initially.
Lessons Learned
- Geospatial features require careful index configuration and understanding of coordinate systems
- Multi-step workflows need clear state management and progress indication
- Marketplace platforms require careful balance of user, partner, and platform interests
- Commission and earnings calculations should be transparent and auditable
- Video KYC adds trust but requires reliable infrastructure
- Two-party verification (OTP) significantly reduces disputes and fraud
- Real-time features create better UX but add complexity to testing and debugging