Product Analysis: Vending Machine Simulation
Overview
The Vending Machine Simulation project is a web-based application that aims to simulate a real-life vending machine. It consists of two applications, a frontend built with React and Redux Saga, and a backend built with Node.js using the NestJS framework. The frontend facilitates user interaction with the vending machine, while the backend handles the business logic and data management.
Features
- Frontend with React & Redux Saga: The frontend application is built using React and utilizes Redux Saga for managing asynchronous actions. This allows for efficient state management and seamless user experience.
- Backend with Node.js and NestJS: The backend application is developed using Node.js and the NestJS framework. NestJS provides a structured and scalable architecture for developing server-side applications.
- Docker Support for Development: The project includes a docker-compose.yml file that facilitates easy setup and configuration of the development environment using Docker. This allows for containerization and portability of the application.
- MongoDB Integration: The backend integrates with MongoDB as the database for storing vending machine data. The project provides instructions on how to set up MongoDB and configure the backend accordingly.
- Swagger Documentation: The backend application generates Swagger documentation that can be accessed through the designated URL. This documentation provides detailed information about the API endpoints and their functionality.
Installation
To run the Vending Machine Simulation project, you can choose between running it with Docker or without Docker.
Running with Docker
- Ensure that Docker and Docker Compose are installed and properly configured on your machine.
- Clone the project repository and navigate to the root directory.
- Open the docker-compose.yml file and review the volumes attached to the services. Make sure they are accessible to Docker. If needed, modify the configuration accordingly.
- In the MongoDB service section of the docker-compose.yml file, ensure that the attached /data/db volume is correct. If not, adjust it to the desired directory or attach a custom directory.
- In the backend configuration, the default configuration from the docker-compose.yml file is already provided. If you made any changes to the docker-compose.yml file, make sure to update the backend configuration accordingly.
- Run the following command to start the application:
docker-compose up
- If the backend default running port is set to 7777, you can access the application by navigating to http://localhost:7777 in your web browser. The Swagger documentation can be accessed at http://localhost:7777/api.
Running without Docker (Prerequisites)
To run the application without Docker, ensure that the following prerequisites are installed on your machine:
- npx command globally
- MongoDB
Backend Installation
- Change directory to the backend folder of the project.
- Install the required packages by running the following command:
npm install
- In the config folder of the backend, there are configuration files related to the application database and others. Make sure to review and modify these files according to your running environment.
- To seed data for the vending machine and its products, run the following command:
npx seeders
- To run the backend application in development mode, use the following command:
npm run dev
- If the backend default running port is set to 7777, you can access the application by navigating to http://localhost:7777 in your web browser. The Swagger documentation can be accessed at http://localhost:7777/api.
Frontend Installation
- Change directory to the frontend application folder of the project.
- Install the required dependencies by running the following command:
npm install
- Copy the .env.example file and create a new .env file.
- In the .env file, add the backend base URL to the env key. For example:
REACT_APP_BACKEND_URL=http://localhost:7777
- To run the frontend application, use the following command:
npm start
- If everything goes well, you can access the application by navigating to http://localhost:3000 in your web browser.
Summary
The Vending Machine Simulation project is a web-based application that provides a realistic representation of a vending machine. With separate applications for the frontend and backend, it offers a seamless user experience and efficient data management. The project supports running with Docker for easy setup and configuration. By following the installation instructions, users can quickly install and run the application, whether with or without Docker.