This is a Node.js inventory server designed to run on a Linux machine or Raspberry Pi. It uses Express.js for the web framework and MySQL as the database.
This is written to work in pair with the barcode reader, but can be used on its own through the webpage.
Before you get started, make sure you have the following prerequisites installed:
- Node.js: Download and install Node.js.
- MySQL: Download and install MySQL.
-
Clone this repository to your Linux machine or Raspberry Pi:
git clone https://github.com/DennisDavydov/homeinvetorypi.git cd homeinventorypi
-
Install the required Node.js packages by running:
npm install
-
Create a MySQL database for the server. You can do this using the MySQL command-line tool or a GUI like phpMyAdmin. Make sure to note down the database name, username, and password.
-
After creating the database, run log into Mysql using:
mysql -uroot -p
Log into the database:
use databasename;
Create two tables by running the following query:
CREATE TABLE products (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
barcode VARCHAR(50),
name VARCHAR(100),
manufacturer VARCHAR(100),
category VARCHAR(100),
storage_place VARCHAR(100),
amount DECIMAL(10,2),
expiry_type VARCHAR(100),
expiry_date DATE,
unit VARCHAR(20)
);
CREATE TABLE product_templates (
barcode VARCHAR(50) NOT NULL PRIMARY KEY,
name VARCHAR(100),
manufacturer VARCHAR(100),
category VARCHAR(100),
storage_place VARCHAR(100),
amount DECIMAL(10,2),
expiry_type VARCHAR(100),
unit VARCHAR(20)
);
-
Open the
app.js
file and update the MySQL connection configuration with your database details:const connection = mysql.createConnection({ host: 'hostname', user: 'user', password: 'yourpassword', database: 'databasename' });
-
Run the server:
node app.js
The server should now be running on http://localhost:8080.
- Access the server in your web browser by navigating to http://localhost:8080.
- The server provides an interface to manage inventory data.
- You add, delete, and view inventory items.
- GET /: Access the home page with inventory data.
- POST /deleteRow: Delete a specific inventory item by providing its barcode in the request body.
If you would like to contribute to this project, feel free to fork the repository and submit pull requests with your changes.
- This project was created with Node.js, Express.js, and MySQL.