A modern, scalable ride-booking platform built with a TypeScript monorepo architecture using Turborepo. This system provides comprehensive functionality for riders, drivers, and administrators similar to popular ride-sharing services like Uber or Lyft.
- π Role-based Authentication: Secure JWT-based auth for riders, drivers, and admins
- π Ride Management: Complete ride lifecycle from request to completion
- π° Transaction Processing: Integrated payment and earnings system
- ποΈ Scalable Architecture: Modular monorepo structure with shared packages
This monorepo contains the following apps and packages:
backend: Express.js REST API with MongoDB integration- User authentication and authorization
- Ride management system
- Driver and rider functionality
- Admin panel APIs
- Transaction processing
frontend: React + Vite application for the user interface- Modern Vite build system for fast development
- Responsive design with TailwindCSS
- Role-based UI components
- Redux Toolkit for state management
- Real-time updates
@repo/db: Database utilities and MongoDB connector with Redis support@repo/utils: Common utilities including:- JWT token management
- Password hashing
- Email providers (Gmail, Resend)
- OTP generation
- Transaction ID generation
- URL slug utilities
@repo/math: Mathematical utilities for fare calculations and parsing@repo/ui: Shared React component library (using Radix UI and TailwindCSS)
@repo/eslint-config: ESLint configurations for Next.js and React@repo/prettier-config: Prettier formatting configurations@repo/typescript-config: TypeScript configurations for different project types
Each package/app is 100% TypeScript with strict type checking.
- Node.js >= 18.0.0
- pnpm >= 8.0.0 (recommended package manager)
- MongoDB database
-
Clone the repository:
git clone <repository-url> cd ride-booking-system
-
Install dependencies:
pnpm install
-
Environment Setup:
# Copy environment files cp apps/backend/.env.example apps/backend/.env cp apps/frontend/.env.example apps/frontend/.env -
Configure Environment Variables:
Backend (.env):
# Server Configuration PORT=3000 HOST=localhost NODE_ENV=development DB_URI="mongodb://127.0.0.1:27017/practice" # JWT Configuration JWT_ACCESS_SECRET="access" JWT_ACCESS_EXPIRES="15m" JWT_REFRESH_SECRET="refresh" JWT_REFRESH_EXPIRES="1d" # Hash Salt PASSWORD_HASH_SALT=12
Frontend (.env):
VITE_BASE_URL="http://localhost:3001/api/v1" VITE_GEOCODING_API_KEY="your_geocoding_api_key_here"
# Run all applications in development mode
pnpm dev
# Run only the backend
pnpm backend
# Run specific app
pnpm dev --filter=frontend
pnpm dev --filter=backend# Build all packages and apps
pnpm build
# Start production server
cd apps/backend && pnpm startThe backend provides a comprehensive REST API with the following endpoints:
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login and receive JWTs |
| POST | /auth/refresh-token |
Refresh access token |
| POST | /auth/logout |
Invalidate token/logout |
| POST | /auth/forgot-password |
Request password reset email |
| POST | /auth/reset-password |
Reset password with token |
| POST | /auth/change-password |
Change password (authenticated) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /otp/send |
Send OTP to email or SMS |
| POST | /otp/verify |
Verify OTP provided by the user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /user/me |
Get current user info (self) |
| PATCH | /user/me |
Update profile info |
| DELETE | /user/me |
Deactivate or delete own account |
| GET | /user/:id |
Get public profile of a user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /drivers/apply |
Apply to become a driver |
| GET | /drivers/me |
Get driver profile |
| PATCH | /drivers/me/status |
Update online/availability status |
| GET | /drivers/me/earnings |
View earning history |
| GET | /drivers/:id |
Get Driver Details by Id |
| Method | Endpoint | Description |
|---|---|---|
| GET | /rides/fare |
Estimate fare of a ride |
| POST | /rides/request |
Rider requests a new ride |
| PATCH | /rides/:id/accept |
Driver accepts ride |
| PATCH | /rides/:id/picked |
Update ride status to PICKED_UP |
| PATCH | /rides/:id/transit |
Update ride status to IN_TRANSIT |
| PATCH | /rides/:id/complete |
Update ride status to COMPLETED |
| PATCH | /rides/:id/cancel |
Cancel ride before pickup |
| GET | /rides/me |
List ride history for current user |
| GET | /rides/:id |
Get ride details |
| GET | /rides/requests/nearby |
Get all requested rides near the drivers location |
| GET | /rides/activeRides |
Get all active ride of driver |
PATCH /api/v1/transactions/pay- Process ride payment
GET /api/v1/admin/users- List all usersGET /api/v1/admin/drivers- List all driversGET /api/v1/admin/rides- List all ridesPATCH /api/v1/admin/drivers/:id/approve- Approve driver applicationPATCH /api/v1/admin/users/:id/block- Block user account
For detailed API documentation, see API_Design.md.
ride-booking-system/
βββ apps/
β βββ backend/ # Express.js API server
β β βββ src/
β β β βββ modules/ # Feature modules (auth, user, ride, etc.)
β β β βββ middlewares/ # Express middlewares
β β β βββ utils/ # Utility functions
β β β βββ types/ # TypeScript type definitions
β β β βββ configs/ # Configuration files
β β βββ dist/ # Compiled JavaScript
β βββ frontend/ # React + Vite application
β βββ src/
β βββ public/
β βββ dist/
βββ packages/
β βββ db/ # Database utilities
β βββ utils/ # Shared utilities
β βββ math/ # Mathematical functions
β βββ ui/ # React components
βββ configs/
β βββ eslint-config/ # ESLint configurations
β βββ prettier-config/ # Prettier configurations
β βββ typescript-config/ # TypeScript configurations
βββ turbo.json # Turborepo configuration
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
The backend is configured for deployment on platforms like Vercel, Railway, or any Node.js hosting service.
# Build for production
pnpm build --filter=backend
# Start production server
cd apps/backend && pnpm startThe frontend can be deployed to Vercel, Netlify, Cloudflare Pages, or any static hosting service.
# Build for production
pnpm build --filter=frontend
# Preview production build locally
pnpm preview --filter=frontend
# Deploy to Cloudflare (if configured)
pnpm deploy --filter=frontend# Development
pnpm dev # Run all apps in development
pnpm backend # Run only backend
pnpm dev --filter=* # Run specific app
# Building
pnpm build # Build all packages and apps
pnpm build --filter=* # Build specific package
# Code Quality
pnpm lint # Lint all packages
pnpm format # Format code with Prettier
pnpm check-types # Type check all packages
# Cleaning
pnpm clean # Clean all build artifactsTip
Vercel Remote Cache is free for all plans. Get started today at vercel.com.
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
cd my-turborepo
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
turbo login
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
npx turbo login
yarn exec turbo login
pnpm exec turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
turbo link
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
npx turbo link
yarn exec turbo link
pnpm exec turbo link
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software in accordance with the terms of the MIT License.