A modern hotel booking platform built with Express.js, TypeScript, and Prisma. This application provides a complete booking system with user authentication, hotel management, and reservation capabilities.
- User Authentication: JWT-based authentication with role-based access (Customer/Owner)
- Hotel Management: CRUD operations for hotels and rooms
- Booking System: Room booking with availability checking
- Database: PostgreSQL with Prisma ORM
- Validation: Input validation using Zod schemas
- Security: Password hashing with bcrypt and middleware protection
- Runtime: Bun
- Framework: Express.js
- Database: PostgreSQL with Prisma ORM
- Language: TypeScript
- Authentication: JWT with bcrypt
- Validation: Zod
hotel-booking-platform/
├── src/
│ ├── controllers/ # Request handlers
│ │ ├── auth.controller.ts # User authentication logic
│ │ ├── hotel.controller.ts # Hotel management logic
│ │ └── booking.controller.ts # Booking logic
│ ├── middleware/ # Express middleware
│ │ ├── authmiddleware.ts # JWT authentication middleware
│ │ └── validate.ts # Request validation middleware
│ ├── routes/ # API routes
│ │ ├── auth.routes.ts # Authentication endpoints
│ │ ├── hotel.routes.ts # Hotel endpoints
│ │ └── booking.routes.ts # Booking endpoints
│ ├── types/ # TypeScript type definitions
│ │ └── express.d.ts # Express type extensions
│ ├── validators/ # Zod validation schemas
│ │ ├── auth.validator.ts # Auth validation schemas
│ │ ├── hotel.validator.ts # Hotel validation schemas
│ │ └── booking.validator.ts # Booking validation schemas
│ └── index.ts # Application entry point
├── generated/
│ └── prisma/ # Auto-generated Prisma client
├── db.ts # Prisma client configuration
├── prisma.config.ts # Prisma configuration
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env # Environment variables
└── README.md # Project documentation
POST /signup- User registrationPOST /login- User login
GET /- List all hotelsPOST /- Create new hotel (owner only)GET /:id- Get hotel by IDPUT /:id- Update hotel (owner only)DELETE /:id- Delete hotel (owner only)
POST /- Create bookingGET /user/:userId- Get user bookingsGET /hotel/:hotelId- Get hotel bookings
- Bun runtime
- PostgreSQL database
- Install dependencies:
bun install- Set up environment variables in
.env:
DATABASE_URL=postgresql://username:password@localhost:5432/hotel_db
JWT_SECRET=your_jwt_secret
PORT=3000- Run the application:
bun run devThe application uses the following main entities:
- Users: Customer and Owner accounts
- Hotels: Hotel information managed by owners
- Rooms: Room details within hotels
- Bookings: Room reservations
- Reviews: Hotel reviews by customers
This project was created using bun init in Bun v1.3.6. Bun is a fast all-in-one JavaScript runtime.