Problem 1: Hotel Booking System (RESTful apis, only backend)
Write API:
-
create/update/delete hotel.
- POST to create hotel.
- PUT to update hotel.
- DELETE to soft delete hotel.
-
create rooms for a hotel.
- POST to create room.
- POST to create multiple room.
-
create/update/delete users.
- POST to create users.
- PUT to update users.
- DELETE to soft delete users.
-
make booking for a user of a room for a specific date range.
- POSt to make booking for using post-json parameters for user,hotel,room,date range.
-
fetch all available rooms with hotel for a date range.
- GET to fetch all available room across all hotel
- GET to fetch all available room across specific hotel
NodeJs
Mysql
"body-parser": "^1.18.3",
"chai-http": "^4.2.0",
"chai-json-schema": "^1.5.0",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"mysql": "^2.16.0",
"winston": "^3.1.0"
"chai": "^4.2.0",
"mocha": "^5.2.0",
"nodemon": "^1.18.4",
"request": "^2.88.0"
- Get all the node dependencies installed.
- Get Mysql installed.
- Create database - hotel
- Update .env file with db credential
- Import hotel_api.sql to database.
- API DOCUMENTATION
- Import
Hotel_api.postman_collection.json
collection in postman to run the APIs.
- Browse to root folder of app via terminal.
- Type
node start
to start the application. - Hit the APIs from postman collection imported ealier.
- Start application using
node start
- Browse to test folder via terminal
- Type
npm test
Currently there are 3 test cases
GET
To get all the rooms available in all hotelGET
To get all the rooms available with specific hotelPOST
To create new hotel
we are using winston module for error logging. Errors will be prinited on console and stored in a file name all_logs.log in logs folder. Errors are stored with timestamp and thier log level.
- For scalability and to handle huge traffic we can use In Memory database like Redis.
- Here we are using Mysql RDBMS, for which we are using connection pooling technic, so that we can cache and resuse connections. Current pool size = 100.
- Folder Structure
- Controller - All Rest based controllers which get the request from routes and pass it to models.
- Models - All Models are related to each controller and they perfome database realted operations.
- Routes - Contains
indes.js
file which contains handles for all http request based on http methods. - Services - All the services which can be used acrossed application are stored here eg : mysql, logger.
- Node_modules : Conatins 3rd party modules installed via npm.
- Test : Contains 'test.js' file which as above mentioned 3 test cases.
- Logs : Stores the logs files for future investigation.
- .env : Contains enviorment specific data and included in git ignore.
- Commit your code in github project with proper comments and send in your project link.
- README for settingup the project.
- Design/Write your application assuming scale for lakhs of hotels and users( We have used connection pool, redis can be used.
- RESTful api recommended
- Implement using node (use any framework).
- Use database of your preference.
- Unit Test (good to have).
- Please if you are assuming anything mention the assumption in comment/readme.