Skip to content

Repository files navigation

Uber Clone

A full-stack ride-booking demo with separate rider and captain apps, a Hono API, Prisma/PostgreSQL persistence, Redis-backed captain location storage, and Socket.IO infrastructure for live trip updates.

This repository is optimized as a portfolio/showcase project: the core ride lifecycle is complete and buildable, while production concerns such as automatic nearest-driver dispatch, rate limiting, monitoring, and broad test coverage are intentionally left as future work.

Highlights

  • Rider app for sign up, sign in, location selection, fare estimate, ride request, trip tracking, cancellation, and history.
  • Captain app for sign up, sign in, online/offline state, available ride list, manual ride acceptance, OTP pickup verification, trip completion/cancellation, location sharing, and history.
  • Backend API with JWT authentication, bcrypt password hashing, Prisma models, Hono routes, structured validation with Zod, and central error handling.
  • Trip lifecycle: REQUESTED -> ACCEPTED -> ON_TRIP -> COMPLETED, with cancellation support.
  • Redis helpers for captain geolocation and trip/captain location lookups.
  • Monorepo setup with Bun workspaces and Turborepo.

Tech Stack

Area Tools
Monorepo Bun, Turborepo
Rider app Next.js 16, React 19, Tailwind CSS, TanStack Query, Axios, MapLibre/Leaflet
Captain app Next.js 16, React 19, Tailwind CSS, TanStack Query, Axios, Leaflet
Backend Bun, Hono, Socket.IO, Prisma 7, PostgreSQL, Redis, Zod
Shared packages TypeScript config, ESLint config, reusable UI package

Repository Structure

uber/
  apps/
    user/       Rider-facing Next.js app
    captain/    Captain-facing Next.js app
    server/     Hono API, Prisma schema, Socket.IO integration
  packages/
    ui/         Shared UI package
    eslint-config/
    typescript-config/

Prerequisites

  • Bun 1.3+
  • Node.js 18+
  • PostgreSQL database
  • Redis instance

Hosted PostgreSQL/Redis services work fine for demo usage. Keep real secrets in .env files only; .env is ignored by Git.

Environment

Create apps/server/.env:

DATABASE_URL="postgresql://user:password@localhost:5432/uber_db"
REDIS_URL="redis://localhost:6379"
JWT_SECRET="replace-with-a-long-random-secret"
PORT=3000

The frontend API clients currently expect the backend at http://localhost:3000:

  • apps/user/lib/api.ts
  • apps/captain/lib/api.ts

If you change the backend port, update both clients or introduce a public environment variable.

Setup

bun install

Generate the Prisma client and apply migrations:

cd apps/server
bunx --bun prisma generate
bunx --bun prisma migrate dev

Start all apps from the repository root:

bun run dev

The dev scripts use portless hostnames:

  • Rider app: http://uber.localhost
  • Captain app: http://captain.uber.localhost
  • Backend API: http://localhost:3000 by default

Demo Flow

  1. Start the backend, rider app, and captain app with bun run dev.
  2. Sign up or sign in as a rider in the user app.
  3. Choose pickup/drop locations, select vehicle capacity, and request a ride.
  4. Sign up or sign in as a captain in the captain app.
  5. Go online, open available trips, and accept the rider's request.
  6. Ask the rider for the OTP, start the trip, then complete it.
  7. Confirm both rider and captain history pages show the completed trip.

Trip matching is currently manual: online captains choose from available requested trips. Redis location support is present, but automatic nearest-captain dispatch is future work.

Useful Commands

bun run dev              # Start all apps
bun run check-types      # Run type checks across the monorepo
bun run lint             # Run lint checks across the monorepo
bun run build:user       # Build the rider app
bun run build:captain    # Build the captain app
bun run build            # Build all configured build targets

Direct checks used for verification:

cd apps/server && bunx tsc --noEmit
cd apps/user && bunx tsc --noEmit
cd apps/captain && bunx tsc --noEmit
cd packages/ui && bunx tsc --noEmit

API Overview

Auth:

  • POST /auth/signup
  • POST /auth/signin
  • GET /auth/signout
  • POST /auth/forgot
  • POST /auth/reset?token=...

Rider:

  • GET /user
  • GET /user/verify
  • POST /user/verify
  • POST /user/request
  • POST /user/cancel
  • GET /user/trip/:id
  • GET /user/history
  • GET /user/ongoing
  • POST /price

Captain:

  • POST /captain/online
  • POST /captain/offline
  • POST /captain/location
  • GET /captain/trips/available
  • POST /captain/trips/:id/accept
  • POST /captain/pickup
  • POST /captain/complete
  • POST /captain/cancel
  • GET /captain/history

Current Scope

Done:

  • Demo-ready rider/captain trip lifecycle.
  • JWT auth for both roles.
  • Manual ride acceptance.
  • OTP-based pickup verification.
  • Redis-backed captain location updates.
  • Type checks and frontend builds passing.

Future improvements:

  • Automatic nearest-captain matching.
  • Rate limiting and stronger security hardening.
  • Admin dashboard and analytics.
  • More complete unit/integration tests.
  • Production deployment configuration and monitoring.

Notes for Reviewers

This is a learning/showcase implementation, not a production ride-hailing system. The intent is to demonstrate full-stack ownership across frontend apps, backend routes, persistence, authentication, real-time architecture, and pragmatic monorepo tooling.

About

A full-stack ride-sharing application built with modern web technologies.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages