A comprehensive admin dashboard for managing a ride-sharing platform database. Built with Express.js, Prisma ORM, and MySQL.
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.
- ποΈ 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
- Node.js (v16 or higher)
- MySQL database
- npm or yarn
-
Clone the repository (if applicable) or navigate to the project directory:
cd RideSharingApp -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile 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"
-
Start MySQL with Docker (optional):
docker-compose up -d
-
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
-
Build Tailwind CSS:
npm run build
-
Start the server:
# Development mode (with hot reload) npm run dev # Production mode npm start
-
Access the application: Open your browser and navigate to:
http://localhost:4000
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
POST /auth/login- Admin loginPOST /auth/register- Register new adminGET /auth/login- Login page
GET /api/schema- Get database schemaGET /api/tables/:tableName- Get table dataPOST /api/tables/:tableName- Add record to tableGET /api/analytics/forecast- Budget forecastGET /api/analytics/top-drivers- Top drivers analysisGET /api/analytics/table/:tableName- Table analyticsPOST /api/transactions/register-driver-vehicle- Register driver + vehicle
- user - Riders who book rides
- driver - Drivers who provide rides
- vehicle - Vehicles used for rides
- ride - Trip/ride records
- payment - Payment transactions
- payment_method - User payment preferences
- card - Card payment details
- cash - Cash payment records
- rating - User reviews and ratings
- driver_vehicle - Links drivers to their vehicles
- books - Links users to their ride bookings
- Navigate to
http://localhost:4000 - Use credentials from seeded users or create new account
- Default admin credentials (if seeded):
- Email: [email protected]
- Password: password123
- Click "Data Browser" in the sidebar
- Select a table from the dropdown
- Click "Load Data" to view records
- Tables display with all columns and data
- Click "Add Records" in the sidebar
- Select a table
- Click "Generate Form"
- Fill in the required fields
- Click "Save Record"
- Go to "Add Records"
- Click "New Driver + Vehicle"
- Fill in driver details (name, email, phone)
- Fill in vehicle details (type, model, license plate)
- Click "Register All"
- This atomically creates driver, vehicle, and links them
- Click "Analytics" in the sidebar
- Choose a tool:
- Budget Forecast: Set inflation rate, run projection
- Top Drivers: Set count and type (best/worst)
- Custom Query: (Placeholder for SQL execution)
- View results in formatted tables
- 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
Edit src/views/dashboard.ejs CSS to customize:
- Primary:
#4f46e5(Indigo) - Success:
#10b981(Emerald) - Error:
#ef4444(Red) - Background:
#f9fafb(Gray-50)
- Update
prisma/schema.prisma - Run
npx prisma db push - Update
repositories/utility.repository.jsif needed - Create controller/route if custom logic needed
# Check MySQL is running
docker ps
# Test connection
npx prisma studio# Regenerate Prisma Client
npx prisma generate
# Reset database
npx prisma migrate resetChange SERVER_PORT in .env to a different port (e.g., 5000)
Clear localStorage in browser:
localStorage.removeItem('rideSharingToken')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 changesThis is a database project for SMU Semester 1. For issues or improvements, contact the development team.
ISC - Internal Educational Project
- 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