Live URL: https://a2-ochre-five.vercel.app
Backend REST API for managing a vehicle rental system. It handles:
- User registration, login and role-based access (admin, customer)
- Vehicle inventory with availability tracking
- Booking creation, cancellation and returns with price calculation
- Authentication with JWT and bcrypt-based password hashing
- Role-based authorization (admin and customer)
- CRUD operations for vehicles
- User management with admin and self-service update
- Booking management with:
- Automatic total price calculation
- Vehicle availability updates
- Status handling:
active,cancelled,returned
- PostgreSQL database with schema initialization on startup
- Centralized error handling with consistent JSON responses
- Node.js
- TypeScript
- Express.js
- PostgreSQL (via
pg) - bcryptjs
- jsonwebtoken
- dotenv
- Node.js (LTS)
- PostgreSQL instance
npm installCreate a .env file in the project root:
CONNECTION_STR=postgresql://USER:PASSWORD@HOST:PORT/DB_NAME?sslmode=require
PORT=5000
JWT_SECRET=your_jwt_secret
NODE_ENV=developmentThe application will automatically create required tables on startup using the connection string.
Make sure the database in CONNECTION_STR already exists.
npm run devServer runs by default on:
http://localhost:5000
npm run build
npm startPOST /api/v1/auth/signup– Register a new userPOST /api/v1/auth/signin– Login and receive JWT token
Include JWT for protected routes:
Authorization: Bearer <token>- Vehicles –
/api/v1/vehicles - Users –
/api/v1/users - Bookings –
/api/v1/bookings
Detailed request/response formats are in api.http examples in the project root.