Backend Developed - S3-G31-Kotlin-QueueHub/mobile-app-android GitHub Wiki
Backend Developed
This backend is responsible for handling the business logic of a virtual queue management service, designed to streamline the process of managing queues at various locations. The system is connected to a PostgreSQL database where it dynamically creates and manages tables for users, queues, places, queue-place relationships, and turns. These tables store key information such as user profiles, queue assignments, place details, and user interactions with the queues.
The backend exposes a variety of endpoints that allow external applications, such as the QueueHub app, to access and manage this data effectively. These endpoints provide essential features like user authentication, adding users to queues, managing waiting times, and retrieving information about restaurants and places. The logic supports adding users to a queue, handling turn completion or cancellations, and providing real-time insights into waiting times, making the queueing process seamless and efficient.
To ensure the service is scalable and easy to deploy, Docker and Docker Compose were used. These tools containerize the backend service and the PostgreSQL database, allowing for a consistent and isolated environment. Docker Compose orchestrates the creation of multiple virtualized instances that ensure both the backend and database are deployed together, simplifying the overall setup. This structure not only allows for easy scaling and maintenance but also ensures that the service is portable and can be deployed across different environments with minimal configuration.
Postman Collection:
There are three files of Postman collections:
-
One is useful to add users to a queue automatically in loop.
-
The second is for adding user manually.
-
The third is a set of useful functions for make testing easier
How to run it:
To run this project, you must have Docker and Docker Compose on your computer or Vm.
The command is:
docker compose up --build
Summary of Endpoints and Main Logic:
GET /ping
Verifies that the service is running by responding with "pong".
GET /users
Retrieves a list of all users.
GET /restaurants/top/{top} and /restaurants
Fetches a list of restaurant locations, with an option to limit the number of results.
POST /users
Adds a new user to the database. The password is hashed with a "salt" for security.
POST /restaurants
Adds a new restaurant or location.
POST /restaurant/{idRestaurant}/cola
Adds a queue (waiting line) to a restaurant.
POST /cola/{colaId}/user/{userId}
Assigns a position in the queue to a user.
PUT /cola/{colaId}/user/{userId}
Ends or cancels a user's position in the queue.
GET /turns/{idCola}/{idUser}
Retrieves the assigned queue position for a specific user in a specific queue.
PATCH /users/{id}
Updates a user's information.
POST /users/auth
Authenticates a user and generates a Bearer token.
GET /places/shortest-time-lasthour
Retrieves information on the average waiting times in the last hour, categorized by time slots.
https://github.com/S3-G31-Kotlin-QueueHub/QueueHubBackend/actions/new