This project is a hotel room booking application built using Next.js and hosted on Azure. You can explore the application at https://hotel-x.azurewebsites.net/.
The project is organized into several key directories and files:
-
src/services/base/
: Contains the base service classes used for making HTTP requests.BaseService.ts
: An abstract class that sets up Axios for making HTTP requests. It includes error handling and request interceptors.BaseEntityService.ts
: ExtendsBaseService
to provide CRUD operations for entities. It handles JWT authentication and token refresh logic.
-
src/interfaces/
: Contains TypeScript interfaces for type safety.auth/IResultObject.ts
: Defines the structure of the result object returned by service methods.IJWTResponse.ts
: Defines the structure of the JWT response used for authentication.
-
src/pages/
: Contains the Next.js pages, which are automatically routed based on their file names.[id].tsx
: Dynamic routing is used to handle pages for individual hotel rooms, identified by their unique IDs.
-
src/components/
: Contains reusable React components used throughout the application. -
public/
: Contains static assets such as images and icons.
-
Bootstrap: The application uses Bootstrap for styling and responsive design.
-
Design Inspiration:
- The homepage design is inspired by cityboxhotels.com.
- The admin and user management CRUD functionality design follows a traditional ASP.NET MVC view design.
The application comes with pre-configured users for testing purposes:
-
Admin User
- UserName:
[email protected]
- Password:
Foo.Bar1
- UserName:
-
Guest User
- UserName:
[email protected]
- Password:
Guest.Pass1
- UserName:
When registering a new user through the application, the user will be created with regular user privileges.
-
Next.js Framework: Utilizes Next.js for its server-side rendering capabilities, which improve SEO and performance. The framework's built-in image optimization and dynamic routing features are particularly beneficial for a hotel booking application.
-
Dynamic Routing: The use of
[id].tsx
in thepages
directory allows for dynamic routing, making it easy to create pages for individual hotel rooms based on their IDs. -
Image Optimization: Next.js automatically optimizes images, ensuring fast load times and a better user experience.
-
JWT Authentication: The application uses JWT for secure authentication. The
BaseEntityService
class handles token refresh logic to maintain user sessions.
Our service supports the X-Road protocol, implemented via the X-Road-Client
header. This header is added to all HTTP requests made through the BaseService
class.
To get started with the project, follow these steps:
- Install Dependencies: Run
npm install
to install all necessary packages. - Run the Development Server: Use
npm run dev
to start the development server. The application will be available athttp://localhost:3000
. - Build for Production: Use
npm run build
to create an optimized production build.
The application is containerized using a multi-stage Dockerfile. It leverages Node.js 18 on Alpine Linux for a lightweight and efficient build. The Dockerfile includes stages for installing dependencies, building the application, and preparing a production-ready image with Next.js optimizations.
Create the image:
docker build -t hotelx-nextjs:latest .
Run the container
docker run -d -p 8080:80 hotelx-nextjs:latest
Create the image:
docker buildx build --progress=plain -t hotelx-nextjs:latest .
Create a tag:
docker tag hotelx-nextjs <your-docker-hub-profile>/hotelx-nextjs:latest
Push the image:
docker push <your-docker-hub-profile>/hotelx-nextjs:latest
Contributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or improvements.
This project is licensed under the MIT License.