Skip to content

About

Smart Stock is a demo inventory and sales management project for tracking products, stock, transactions, authentication, and audit activity using a web frontend, Node.js backend, and MySQL database.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Smart Stock

Smart Stock is a full-stack inventory and sales management system built for tracking products, stock movement, transactions, user authentication, and audit events. The project includes a Node.js/Express backend and a frontend dashboard for monitoring inventory operations.

Features

  • Product inventory management
  • Category-based organization
  • Transaction tracking for stock movement
  • User authentication and login flow
  • Audit log tracking for system actions
  • Sales/analytics dashboard views
  • MySQL database integration
  • Static frontend served by the backend

Tech Stack

  • Frontend: HTML, CSS, JavaScript
  • Backend: Node.js, Express
  • Database: MySQL
  • Driver: mysql2
  • Environment management: dotenv

Project Structure

smart-stock-main/
+-- index.html
+-- LICENSE
+-- README.md
+-- oracle_script.sql
+-- css/
�   +-- style.css
+-- js/
�   +-- app.js
�   +-- controllers.js
�   +-- data.js
+-- views/
�   +-- analytics.html
�   +-- audit.html
�   +-- dashboard.html
�   +-- inventory.html
�   +-- login.html
�   +-- scanner.html
�   +-- transactions.html
+-- backend/
�   +-- .env.example
�   +-- .env
�   +-- db.js
�   +-- package.json
�   +-- schema.sql
�   +-- server.js
�   +-- mysql-data/
�   +-- routes/
�       +-- audit.js
�       +-- auth.js
�       +-- categories.js
�       +-- products.js
�       +-- transactions.js
+-- .gitignore

Prerequisites

Before running the app, make sure the following are installed:

  • Node.js (v18 or later recommended)
  • npm
  • MySQL Server 8.0 or compatible version
  • A configured MySQL user with access to a local database

Setup Instructions

1. Clone the repository

git clone <your-github-repo-url>
cd smart-stock-main

2. Install backend dependencies

cd backend
npm install

3. Configure database credentials

Create a .env file inside the backend folder.

Example template:

PORT=3001
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=smart_stock

Replace the placeholder password with your local database password. The project includes a template file at backend/.env.example.

4. Start MySQL and create the database

Make sure MySQL is running on your system.

You can import the schema using:

cd backend
Get-Content schema.sql -Raw | "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -u root -p -h 127.0.0.1 -P 3306

If your MySQL installation path is different, update the path to mysql.exe accordingly.

5. Run the backend

cd backend
npm run dev

The server will start and serve the frontend from the project root.

6. Open the app

Open the following in your browser:

http://localhost:3001

Default Behavior

  • The backend serves static frontend files from the parent project directory.
  • The app runs on port 3001 by default.
  • The DB name is smart_stock unless changed in .env.

API Overview

The backend exposes routes under /api for:

  • Products
  • Transactions
  • Categories
  • Authentication
  • Audit logs

Example endpoints include:

/api/products
/api/transactions
/api/categories
/api/auth/login
/api/audit
/api/health

Important Notes

  • Do not commit any real .env file to GitHub.
  • The repository already includes .gitignore entries for .env, backend/.env, and other generated files.
  • If MySQL is not running or credentials are wrong, the app will fail to connect and exit.

Troubleshooting

MySQL connection errors

Check:

  • MySQL service is running
  • DB_HOST and DB_PORT are correct
  • DB_USER and DB_PASSWORD match your actual MySQL user
  • The smart_stock database has been created/imported

Dependency install issues

cd backend
npm install

Running from the wrong location

Always run the app from the backend directory:

cd backend
npm run dev

GitHub Push Steps

Once the project is ready, initialize Git and push to your remote repository:

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin <your-github-repository-url>
git push -u origin main

License

This project is licensed under the MIT License. See LICENSE for details.

About

Smart Stock is a demo inventory and sales management project for tracking products, stock, transactions, authentication, and audit activity using a web frontend, Node.js backend, and MySQL database.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages