A Java Servlet-based Inventory Management Web Application using MVC architecture and PostgreSQL
A Java Servlet-based Inventory Management System built using MVC architecture and PostgreSQL.
This project demonstrates real-world use of Servlets, JDBC, and Database Integration in a clean, modular structure.
- DEO (Data Entry Operator): Add new products (with supplier validation and unique product IDs).
- POS (Point of Sale Staff): Perform sales, reduce stock, and calculate total price dynamically.
- MGR (Manager): View products with stock levels below 50 for restocking decisions.
| Layer | Technology |
|---|---|
| Frontend | HTML5 |
| Backend | Java Servlets (Jakarta EE) |
| Database | PostgreSQL |
| Design Pattern | MVC (Model-View-Controller) |
| Server | Apache Tomcat 11 |
| Language | Java (JDK 17+) |
InventoryApp/
βββ src/
β βββ main/
β βββ java/
β β βββ com/
β β βββ company/
β β βββ controller/ # Servlets
β β βββ dao/ # Data Access Objects
β β βββ model/ # Entity Classes
β β βββ service/ # Business Logic
β β βββ util/ # Utilities
β βββ webapp/
β βββ WEB-INF/
β β βββ web.xml # Deployment Descriptor
β β βββ classes/
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
β βββ views/ # JSP pages
β βββ index.html # Login Page
βββ pom.xml # Maven Configuration
βββ README.md
βββ .gitignore
βββ LICENSECREATE DATABASE Inventory;
\c Inventory;
CREATE TABLE users (
userid VARCHAR(20) PRIMARY KEY,
password VARCHAR(50),
fullname VARCHAR(50),
role VARCHAR(10) CHECK (role IN ('DEO','POS','MGR'))
);
INSERT INTO users VALUES
('admin','admin123','Administrator','MGR'),
('nish','nish123','The Great Nish','DEO'),
('user1','user123','Sample User 1','POS');
CREATE TABLE supplier (
supplierid VARCHAR(20) PRIMARY KEY,
name VARCHAR(50),
contact VARCHAR(15),
email VARCHAR(50)
);
CREATE TABLE product (
productid VARCHAR(20) PRIMARY KEY,
name VARCHAR(50),
supplierid VARCHAR(20) REFERENCES supplier(supplierid),
stockavailable INT,
openingstock INT,
lastsupplydate DATE,
unitprice NUMERIC(10,2)
);graph TD
A[User Access Login Page] --> B[Enter Credentials]
B --> C{Validation}
C -->|Invalid| D[Show Error Message]
C -->|Valid| E{Check User Role}
E -->|MGR| F[Redirect to Manager Dashboard]
E -->|DEO| G[Redirect to DEO Dashboard]
E -->|POS| H[Redirect to POS Dashboard]
F --> I[Access Manager Features]
G --> J[Access DEO Features]
H --> K[Access POS Features]
- User enters credentials on login page
- System validates against database
- Redirects to role-specific dashboard based on user role
Main Task: Add Products
- Fill product form with details
- System validates supplier exists
- Checks product ID uniqueness
- Adds product to database
- Updates inventory records
Main Task: Process Sales
- Enter product ID to search
- System shows product details & stock
- Enter quantity to sell
- Automatic price calculation
- Stock automatically deducted
- Sales transaction recorded
Main Tasks: Monitor & Analyze
- View low stock alerts (stock < 50)
- Check sales reports and analytics
- Monitor inventory health
- Manage user accounts and roles
Login β Role Check β Dashboard β Perform Actions β Logout
β
DEO: Add Products β Validate β Save to DB
POS: Sell Products β Calculate β Update Stock
MGR: View Reports β Analyze β Make Decisions
flowchart TD
subgraph Frontend
A[Login Interface]
B[DEO Dashboard]
C[POS Dashboard]
D[Manager Dashboard]
end
subgraph Backend
E[Authentication Service]
F[Product Service]
G[Sales Service]
H[Report Service]
end
subgraph Database
I[Users Table]
J[Products Table]
K[Suppliers Table]
L[Sales Table]
end
A --> E
E --> I
B --> F
F --> J
F --> K
C --> G
G --> J
G --> L
D --> H
H --> J
H --> L
H --> I
+------------------+ +---------------------+ +--------------------+
| View | ---> | Controller | ---> | Model |
| (JSP/HTML) | | (Servlets) | | (DAO + Entities) |
+------------------+ +---------------------+ +--------------------+
β β β
| | |
+------------------+ +---------------------+ +--------------------+
| User Interface | | Business Logic | | Database Layer |
| Forms & Pages | | Request Handling | | JDBC & SQL |
+------------------+ +---------------------+ +--------------------+
- π§© Role-Based Dashboard UI: Enhance each role (DEO, POS, MGR) with interactive HTML dashboards using AJAX for real-time updates.
- π¦ Sales History Tracking: Maintain a
Salestable to store transaction details and generate periodic sales reports. - π Low Stock Alerts: Automatically email or notify managers when stock drops below a defined threshold.
- π Analytics Module: Integrate charts (using Chart.js) to visualize sales and stock trends.
- βοΈ Cloud Deployment: Host the application on AWS / Render using PostgreSQL Cloud for real-world scalability.
- π§ AI-Powered Stock Prediction: Use a lightweight ML model to forecast product demand and optimize inventory.
Nishant (The Great Nish)
- πΌ Developer & Architect of InventoryApp
- π¬ Passionate about Java, AI/ML, and Cybersecurity
- π GitHub: @nishant-cipher
- π§ Contact: nishant.cipher@gmail.com
This project is licensed under the MIT License β youβre free to use, modify, and distribute it with attribution. MIT License Copyright (c) 2025 Nishant