GO-Hotel-Reservation is a Go-based web application for hotel reservations. It is built using the Fiber web framework and MongoDB as the database. This project provides a simple and scalable solution for managing hotel information, room bookings, user authentication, and more.
- User authentication with JWT
- Hotel and room management
- Room booking and reservation handling
- Role-based access control (admin and user roles)
- API versioning with Fiber
- MongoDB integration for data storage
Before you begin, make sure you have the following prerequisites installed:
-
Clone the repository:
git clone https://github.com/Adarsh-jaiss/GO-Hotel-reservation.git cd GO-Hotel-reservation
-
Install dependencies:
go mod download
-
Set up the environment variables:
Create a
.env
file in the project root and add the following:HTTP_LISTEN_ADDRESS=:3000 JWT_SECRET=your_secret_key MONGO_DB_NAME=hotel-reservation MONGO_DB_URL=mongodb://your_mongodb_host:your_mongodb_port/
-
Seed the database with some initial values, so that you can test the API's using those values
make seed
-
Run the application:
go run main.go
The application should now be accessible at http://localhost:3000
.
This guide provides step-by-step instructions on how to build and run the GO-Hotel-Reservation project using Docker.
Make sure you have the following prerequisites installed on your system:
-
You can install it via this simple command
docker run --name mongob -d mongo:latest -p 27017:27017
and run a docker container via
docker run --rm --name my_mongo_container -d mongo:latest
Note : Don't forget to configure the enviroment variables before running the application,otherwise it will not start and throw an error
git clone https://github.com/YourUsername/GO-Hotel-reservation.git
cd GO-Hotel-reservation
go mod download
make seed
make docker
If you have exited out of docker container, use this command to create another container out of the docker image
docker run -p 3000:3000 --rm --name hotel-reservation 4fde40842494
You can configure the application by modifying the values in the .env
file. Make sure to update the MongoDB connection details and set a secure JWT secret.
The API endpoints are documented in the API Documentation file.
Run tests using the following command:
make test
I haven't implemented few things such as Database migration, adding up another database layer (maybe postgress), Pagination, Custom Test Cases for all the handlers, and some other API functionalities like creating admin directly via post method but in future maybe I'll apply those as well.