A full-stack application with Node.js backend and React frontend, connected to MySQL database to show data as bar chart and line chart. The work was a continuation of the Smart Beverage Vending Machine 2022 project, which was funded by the European Agricultural Fund for Rural Development (Finland's Rural Development Programme 2014–2020 EU Recovery Fund additional resources, rural innovation groups EIP). You can find more information about the project on the project website Älyjuoma-automaatti 2022. The work reported in the article was primarily carried out by Joni Rikula as a teaching assistant alongside his regular duties during 2024–2025.
Before you begin, ensure you have the following installed on your system:
git clone <your-repository-url>
cd <your-project-directory># Navigate to backend directory (if separate) or root directory
npm install# Navigate to frontend directory
cd frontend # or wherever your frontend code is located
npm installCreate a .env file in the root directory of your project and add the following environment variables:
PORT=4000
MYSQL_HOST=your_mysql_host
MYSQL_USER=your_mysql_username
MYSQL_DATABASE=your_database_name
MYSQL_PASSWORD=your_mysql_passwordImportant:
- Replace the placeholder values with your actual MySQL database credentials
- Never commit the
.envfile to version control for security reasons - Add
.envto your.gitignorefile
- Ensure your MySQL server is running
- Create the database specified in your
MYSQL_DATABASEenvironment variable - Make sure the user specified in
MYSQL_USERhas appropriate permissions to access the database
# From the root directory (or backend directory)
node server.jsThe backend server will start on port 4000 (or the port specified in your .env file).
# Navigate to frontend directory
cd frontend # adjust path as needed
npm startThe frontend development server will typically start on port 3000 and should automatically open in your browser.
project-root/
├── server.js # Backend entry point
├── package.json # Backend dependencies
├── .env # Environment variables (not in repo)
├── .gitignore # Git ignore file
├── frontend/ # Frontend application
│ ├── package.json # Frontend dependencies
│ └── src/ # Frontend source code
└── README.md # This file
- The backend server runs on the port specified in the
PORTenvironment variable - Server file:
server.js - Restart the server after making changes:
node server.js
- The frontend development server supports hot reloading
- Changes will automatically refresh in the browser
- Start command:
npm start
| Variable | Description | Example |
|---|---|---|
PORT |
Backend server port (needs to be 4000) | 4000 |
MYSQL_HOST |
MySQL server hostname/IP | localhost or 192.168.1.100 |
MYSQL_USER |
MySQL username | your_username |
MYSQL_DATABASE |
MySQL database name | your_database_name |
MYSQL_PASSWORD |
MySQL password | your_secure_password |
2025 Joni Rikula
Licensed under the MIT license. We are probably happy to help if you need a different open license.
Copyright 2025 HAMK Häme University of Applied Sciences