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.
- 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
- Frontend: HTML, CSS, JavaScript
- Backend: Node.js, Express
- Database: MySQL
- Driver: mysql2
- Environment management: dotenv
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
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
git clone <your-github-repo-url>
cd smart-stock-maincd backend
npm installCreate 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_stockReplace the placeholder password with your local database password. The project includes a template file at backend/.env.example.
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 3306If your MySQL installation path is different, update the path to mysql.exe accordingly.
cd backend
npm run devThe server will start and serve the frontend from the project root.
Open the following in your browser:
http://localhost:3001
- The backend serves static frontend files from the parent project directory.
- The app runs on port
3001by default. - The DB name is
smart_stockunless changed in.env.
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
- Do not commit any real
.envfile to GitHub. - The repository already includes
.gitignoreentries 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.
Check:
- MySQL service is running
DB_HOSTandDB_PORTare correctDB_USERandDB_PASSWORDmatch your actual MySQL user- The
smart_stockdatabase has been created/imported
cd backend
npm installAlways run the app from the backend directory:
cd backend
npm run devOnce 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 mainThis project is licensed under the MIT License. See LICENSE for details.