A premium, single-page web application (SPA) with a glassmorphic dashboard design for managing product inventory values, sales states, and stock calculations. Built with Node.js, Express, MongoDB, and modern Vanilla CSS.
- Dashboard Statistics:
- Inventory Value: Sum of totals of all available/unsold items.
- Total Sales: Sum of totals of all sold items.
- Available Stock: Count of active items in stock.
- Products Sold: Count of sold items.
- Dynamic Search & Filtering: Real-time name search and filter tabs (All, Available, Sold).
- Sorting Options: Sort inventory by date added, unit price, and quantity.
- Glassmorphic UI: Beautiful dark mode theme using blur effects, harmonious color accents, and smooth hover/modal entry animations.
- Modals for Actions: Custom-built modal popups with form validation, replacing native browser prompts for adding, editing, selling, and deleting products.
- Real-time Cost Preview: Displays calculated totals as you type price/quantity values in the form.
- Toast Notifications: Modern status toasts for UI alerts.
- Auto-Calculated Totals: Backend server validates inputs and automatically computes
total = price * quantityto keep data robust.
- Frontend: HTML5, Vanilla JavaScript (ES6+), Vanilla CSS (Custom properties, CSS Grid/Flexbox, backdrop filters, keyframe animations), Google Fonts (Outfit).
- Backend: Node.js, Express.js (v5), MongoDB/Mongoose (Object Data Modeling).
- Hosting / Deployments: Setup for deploying static frontend files to GitHub Pages and the backend API to Render.
The MongoDB collection uses the following Product schema definition (models/Product.js):
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name |
String | Yes | - | Name of the product (whitespaces auto-trimmed) |
price |
Number | Yes | - | Positive unit price of the product |
quantity |
Number | Yes | - | Positive integer quantity |
total |
Number | Yes | - | Computed total value (price * quantity) |
sold |
Boolean | Yes | false |
Whether the product has been sold |
sellDate |
Date | No | - | Timestamp when the product was marked sold |
sellNote |
String | No | - | Optional note containing sale comments |
- URL:
/api/products - Method:
POST - Body:
{ "name": "Mechanical Keyboard", "price": 89.99, "quantity": 5 } - Response:
201 Created
- URL:
/api/products - Method:
GET - Response:
200 OK(Array of products sorted newest first)
- URL:
/api/products/:id - Method:
PUT - Body (Optional fields):
{ "name": "RGB Mechanical Keyboard", "price": 95.00, "quantity": 4 } - Response:
200 OK(Updated product object)
- URL:
/api/products/:id/sell - Method:
PUT - Body:
{ "sellNote": "Sold to office client" } - Response:
200 OK(Updated product object withsold: true)
- URL:
/api/products/:id - Method:
DELETE - Response:
200 OK
- Open a terminal and install dependencies:
npm install
- Create a
.envfile in the root directory:PORT=5000 MONGO_URI=your_mongodb_connection_string
- Start the local server:
The backend API will run on http://localhost:5000.
node server.js
- Simply double-click
index.htmlto open it in a browser, or run a local static file server. - The frontend script dynamically detects if it is running on
localhost/127.0.0.1and will connect to your local backend. Otherwise, it defaults to the production Render API.