A modern hotel booking website built with Next.js, TypeScript, and Prisma.
- User Authentication: Secure user registration and login system
- Room Booking: Browse and book hotel rooms
- Payment Processing: Multiple payment methods support
- Admin Panel: Manage bookings, rooms, and users
- Responsive Design: Mobile-first approach with Tailwind CSS
The application includes a complete user registration system with the following features:
- Full name, email, and password fields
- Real-time validation using Zod schemas
- Password hashing with bcrypt
- Duplicate email checking
- Automatic sign-in after successful registration
- Toast notifications for success/error feedback
- Loading states and form validation
- Password hashing using bcrypt with salt rounds
- Input validation and sanitization
- CSRF protection through Next.js server actions
- Unique email constraints in database
- Uses Prisma ORM with PostgreSQL
- User model with role-based access control
- Automatic UUID generation for user IDs
- Timestamp tracking for audit purposes
- Node.js 18+
- PostgreSQL database
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd serenity-hotel
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env.local
- Configure your database URL in
.env.local
:
DATABASE_URL="postgresql://username:password@localhost:5432/serenity_hotel"
- Run database migrations:
npx prisma migrate dev
- Seed the database (optional):
npm run db:seed
- Start the development server:
npm run dev
The application includes sample data for testing:
npm run db:seed
This will create:
- Admin user:
admin@example.com
/password
- Guest user:
guest@example.com
/password
POST /api/auth/[...nextauth]
- NextAuth.js authenticationPOST /api/auth/register
- User registration (server action)
- User registration and login
- Role-based access control (guest/admin)
- Session management with JWT
- Frontend: Next.js 14, React 18, TypeScript
- Styling: Tailwind CSS, shadcn/ui components
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth.js with JWT
- Password Hashing: bcrypt
- Validation: Zod schemas
- State Management: React hooks and server actions
src/
├── app/ # Next.js app router
│ ├── (auth)/ # Authentication routes
│ ├── api/ # API routes
│ └── globals.css # Global styles
├── components/ # React components
│ ├── auth/ # Authentication components
│ ├── ui/ # Reusable UI components
│ └── sections/ # Page sections
├── lib/ # Utility functions
│ ├── actions/ # Server actions
│ ├── auth.ts # NextAuth configuration
│ ├── encrypt.ts # Password hashing
│ └── validators.ts # Zod validation schemas
└── types/ # TypeScript type definitions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.