Skip to content

A RideSharing application for admins to manage the database and find the insights from the data from the explorer with modern user friendly interface.

Notifications You must be signed in to change notification settings

SridharVadla45/RideSharingApp--Database-explorer

Repository files navigation

RideShare Admin Management Portal

A comprehensive admin dashboard for managing a ride-sharing platform database. Built with Express.js, Prisma ORM, and MySQL.

πŸ“‹ Project Overview

This is a professional database management system designed for administrators to manage all aspects of a ride-sharing platform including users, drivers, vehicles, rides, payments, and ratings.

Key Features

  • πŸ—„οΈ Data Browser - View and explore all database tables
  • βž• Add Records - Create new entries with dynamic form generation
  • πŸ“Š Analytics Dashboard - Budget forecasting, top drivers analysis, and metrics
  • πŸ” Secure Authentication - JWT-based admin authentication
  • πŸ’Ύ Transaction Support - Atomic operations (e.g., register driver + vehicle)
  • πŸ“ˆ Real-time Charts - Data visualization with Chart.js

πŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • MySQL database
  • npm or yarn

Installation

  1. Clone the repository (if applicable) or navigate to the project directory:

    cd RideSharingApp
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory:

    DATABASE_URL="mysql://root:password@localhost:3306/ridesharedb"
    SERVER_PORT=4000
    JWT_SECRET="your-super-secret-key-change-this"
    JWT_EXPIRES_IN="7d"
  4. Start MySQL with Docker (optional):

    docker-compose up -d
  5. Set up the database:

    # Generate Prisma Client
    npx prisma generate
    
    # Create database tables
    npx prisma db push
    
    # Seed database with sample data (optional)
    npx prisma db seed
  6. Build Tailwind CSS:

    npm run build
  7. Start the server:

    # Development mode (with hot reload)
    npm run dev
    
    # Production mode
    npm start
  8. Access the application: Open your browser and navigate to:

    http://localhost:4000
    

πŸ—οΈ Project Structure

RideSharingApp/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma          # Database schema
β”‚   └── seed.js                # Sample data seeding
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ env.js             # Environment configuration
β”‚   β”‚   └── prisma.js          # Prisma client
β”‚   β”œβ”€β”€ controllers/           # Request handlers
β”‚   β”‚   β”œβ”€β”€ analytics.controller.js
β”‚   β”‚   β”œβ”€β”€ auth.controller.js
β”‚   β”‚   β”œβ”€β”€ schema.controller.js
β”‚   β”‚   β”œβ”€β”€ table.controller.js
β”‚   β”‚   └── transaction.controller.js
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── auth.middleware.js # JWT authentication
β”‚   β”œβ”€β”€ repositories/
β”‚   β”‚   └── utility.repository.js
β”‚   β”œβ”€β”€ routes/                # API routes
β”‚   β”‚   β”œβ”€β”€ analytics.route.js
β”‚   β”‚   β”œβ”€β”€ auth.route.js
β”‚   β”‚   β”œβ”€β”€ schema.route.js
β”‚   β”‚   β”œβ”€β”€ table.route.js
β”‚   β”‚   └── transaction.route.js
β”‚   β”œβ”€β”€ views/                 # EJS templates
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   └── login.ejs
β”‚   β”‚   └── dashboard.ejs
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── input.css          # Tailwind input
β”‚   └── app.js                 # Express app entry
β”œβ”€β”€ public/
β”‚   └── css/
β”‚       └── output.css         # Compiled Tailwind
β”œβ”€β”€ .env                       # Environment variables
β”œβ”€β”€ docker-compose.yml         # MySQL container
└── package.json

πŸ”Œ API Endpoints

Authentication

  • POST /auth/login - Admin login
  • POST /auth/register - Register new admin
  • GET /auth/login - Login page

Protected Endpoints (require JWT token)

  • GET /api/schema - Get database schema
  • GET /api/tables/:tableName - Get table data
  • POST /api/tables/:tableName - Add record to table
  • GET /api/analytics/forecast - Budget forecast
  • GET /api/analytics/top-drivers - Top drivers analysis
  • GET /api/analytics/table/:tableName - Table analytics
  • POST /api/transactions/register-driver-vehicle - Register driver + vehicle

πŸ“Š Database Schema

Core Tables

  1. user - Riders who book rides
  2. driver - Drivers who provide rides
  3. vehicle - Vehicles used for rides
  4. ride - Trip/ride records
  5. payment - Payment transactions
  6. payment_method - User payment preferences
  7. card - Card payment details
  8. cash - Cash payment records
  9. rating - User reviews and ratings
  10. driver_vehicle - Links drivers to their vehicles
  11. books - Links users to their ride bookings

🎯 Usage Guide

Logging In

  1. Navigate to http://localhost:4000
  2. Use credentials from seeded users or create new account
  3. Default admin credentials (if seeded):

Data Browser

  1. Click "Data Browser" in the sidebar
  2. Select a table from the dropdown
  3. Click "Load Data" to view records
  4. Tables display with all columns and data

Adding Records

  1. Click "Add Records" in the sidebar
  2. Select a table
  3. Click "Generate Form"
  4. Fill in the required fields
  5. Click "Save Record"

Special Transaction: Register Driver + Vehicle

  1. Go to "Add Records"
  2. Click "New Driver + Vehicle"
  3. Fill in driver details (name, email, phone)
  4. Fill in vehicle details (type, model, license plate)
  5. Click "Register All"
  6. This atomically creates driver, vehicle, and links them

Analytics

  1. Click "Analytics" in the sidebar
  2. Choose a tool:
    • Budget Forecast: Set inflation rate, run projection
    • Top Drivers: Set count and type (best/worst)
    • Custom Query: (Placeholder for SQL execution)
  3. View results in formatted tables

πŸ”’ Security

  • JWT Authentication: All API routes protected
  • Password Hashing: bcryptjs with salt rounds
  • SQL Injection Prevention: Parameterized queries via Prisma
  • CORS Protection: Configured for specific origins
  • Helmet: Security HTTP headers
  • Input Validation: Express-validator

🎨 Customization

Theme Colors

Edit src/views/dashboard.ejs CSS to customize:

  • Primary: #4f46e5 (Indigo)
  • Success: #10b981 (Emerald)
  • Error: #ef4444 (Red)
  • Background: #f9fafb (Gray-50)

Adding New Tables

  1. Update prisma/schema.prisma
  2. Run npx prisma db push
  3. Update repositories/utility.repository.js if needed
  4. Create controller/route if custom logic needed

πŸ› Troubleshooting

Database Connection Issues

# Check MySQL is running
docker ps

# Test connection
npx prisma studio

Prisma Client Errors

# Regenerate Prisma Client
npx prisma generate

# Reset database
npx prisma migrate reset

Port Already in Use

Change SERVER_PORT in .env to a different port (e.g., 5000)

Token Errors

Clear localStorage in browser:

localStorage.removeItem('rideSharingToken')

πŸ“ NPM Scripts

npm start              # Start production server
npm run dev            # Start with nodemon + Tailwind watch
npm run build          # Build Tailwind CSS
npm run tailwind:watch # Watch Tailwind changes

🀝 Contributing

This is a database project for SMU Semester 1. For issues or improvements, contact the development team.

πŸ“„ License

ISC - Internal Educational Project

πŸ‘₯ Credits

  • Database Design: Ride-sharing schema with Prisma ORM
  • Frontend: EJS, TailwindCSS, Chart.js
  • Backend: Express.js, MySQL
  • Authentication: JWT, bcryptjs

Built with ❀️ for SMU Database Course

About

A RideSharing application for admins to manage the database and find the insights from the data from the explorer with modern user friendly interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors