Skip to content

Shiva0208/goride

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚕 GoRide — Cab Booking App

Full-stack cab booking platform with 3 roles: Customer, Driver, and Admin.

Tech Stack

Layer Technology
Frontend Next.js 14 (App Router) + Tailwind
Backend Node.js + Express
Database PostgreSQL + Prisma ORM
Auth JWT (JSON Web Tokens)

Prerequisites

Make sure these are installed on your machine:


1. Setup Database

Your PostgreSQL must be running. Create the database:

# macOS (Homebrew)
psql -U postgres -c "CREATE DATABASE goride;"

# Windows — run in psql shell or pgAdmin
CREATE DATABASE goride;

2. Setup Backend API

# Open terminal in VS Code → cd to api folder
cd api

# Install dependencies
npm install

# Push database schema (creates all tables)
npx prisma db push

# Seed sample data
node prisma/seed.js

# Start the API server
npm run dev

The API runs at: http://localhost:4000 Test it: http://localhost:4000/api/health


3. Setup Frontend

# Open a NEW terminal in VS Code → cd to web folder
cd web

# Install dependencies
npm install

# Start Next.js dev server
npm run dev

The web app runs at: http://localhost:3000


4. Open in Browser

Go to: http://localhost:3000

Login Credentials (after seeding):

Role Email Password
Customer rahul@example.com password123
Customer priya@example.com password123
Driver amit@driver.com password123
Driver suresh@driver.com password123
Admin admin@goride.com admin123

5. VS Code Setup (Recommended)

  1. Open VS Code
  2. File → Open Folder → select the GoRide folder
  3. Open two terminals (Ctrl+` then the + button):
    • Terminal 1: cd api && npm run dev
    • Terminal 2: cd web && npm run dev

API Endpoints

Auth

Method Endpoint Description
POST /api/auth/customer/login Customer login
POST /api/auth/customer/register Customer register
POST /api/auth/driver/login Driver login
POST /api/auth/driver/register Driver register
POST /api/auth/admin/login Admin login
GET /api/auth/me Get current user

Rides (Customer)

Method Endpoint Description
POST /api/rides Request a ride
GET /api/rides/estimate Get fare estimate
GET /api/rides/active Get active ride
GET /api/rides/history Ride history
POST /api/rides/:id/cancel Cancel ride
POST /api/rides/:id/rate Rate a ride

Driver

Method Endpoint Description
GET /api/driver/available-rides See open ride requests
POST /api/driver/rides/:id/accept Accept a ride
PUT /api/driver/rides/:id/status Update ride status
GET /api/driver/active-ride Current active ride
GET /api/driver/rides/history Ride history
GET /api/driver/earnings Earnings summary
PUT /api/driver/availability Toggle online/offline

Admin

Method Endpoint Description
GET /api/admin/dashboard Stats overview
GET /api/admin/customers List customers
PUT /api/admin/customers/:id/toggle-status Block/unblock
GET /api/admin/drivers List drivers
PUT /api/admin/drivers/:id/verify Verify driver
GET /api/admin/rides All rides
GET /api/admin/fare-settings Get fare config
PUT /api/admin/fare-settings/:type Update fare

Folder Structure

GoRide/
├── api/                        # Backend
│   ├── prisma/
│   │   ├── schema.prisma       # Database schema (6 models)
│   │   └── seed.js             # Sample data seeder
│   ├── src/
│   │   ├── config/prisma.js    # Prisma client singleton
│   │   ├── controllers/        # Business logic
│   │   │   ├── authController.js
│   │   │   ├── rideController.js
│   │   │   ├── driverController.js
│   │   │   └── adminController.js
│   │   ├── middleware/
│   │   │   ├── auth.js         # JWT verification
│   │   │   └── role.js         # Role-based access guard
│   │   ├── routes/             # Express routers
│   │   └── utils/
│   │       ├── jwt.js          # Sign/verify tokens
│   │       └── fare.js         # Fare calculation (Haversine)
│   ├── .env
│   ├── package.json
│   └── server.js               # Entry point (port 4000)
│
└── web/                        # Frontend (Next.js 14)
    ├── app/
    │   ├── (auth)/
    │   │   ├── login/          # Unified login (3 roles)
    │   │   ├── register/       # Customer signup
    │   │   └── driver-register/# Driver signup
    │   ├── customer/
    │   │   ├── dashboard/      # Welcome + recent rides
    │   │   ├── book/           # 3-step booking flow
    │   │   ├── active-ride/    # Live tracking + rating
    │   │   └── history/        # Ride history with pagination
    │   ├── driver/
    │   │   ├── dashboard/      # Stats + active ride controls
    │   │   ├── rides/          # Available ride requests
    │   │   └── earnings/       # Earnings breakdown + history
    │   └── admin/
    │       ├── dashboard/      # Platform stats + recent rides
    │       ├── customers/      # Manage + block customers
    │       ├── drivers/        # Verify + manage drivers
    │       ├── rides/          # All rides with filters
    │       └── fares/          # Edit fare per vehicle type
    ├── components/
    │   ├── Navbar.tsx           # Role-aware navigation
    │   └── StatusBadge.tsx      # Ride status badge
    ├── lib/
    │   ├── api.ts               # Axios instance + interceptors
    │   └── auth.ts              # Auth helpers (getUser, logout)
    ├── .env.local
    └── package.json

Common Errors

Error Fix
Can't reach database server Start PostgreSQL: brew services start postgresql@16 (Mac) or net start postgresql-x64-16 (Windows)
P1001: Can't reach database Check DATABASE_URL in api/.env — update username/password
EADDRINUSE 4000 Port in use. Change PORT in api/.env
EADDRINUSE 3000 Next.js port in use. Run npm run dev -- -p 3001
Login not working Make sure seed ran: node prisma/seed.js
API 401 errors Token expired — log out and log back in

Windows Notes

# If psql not in PATH, add to environment variables:
# C:\Program Files\PostgreSQL\16\bin

# Create database in psql shell:
psql -U postgres
CREATE DATABASE goride;
\q

# Then run api setup as above

About

Full-stack cab booking app with web, API, and mobile — built with Next.js, Express, Prisma, PostgreSQL, and Expo React Native

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors