╔════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ ║
║ ██╗███╗ ██╗██╗ ██╗███████╗███╗ ██╗████████╗ ██████╗ ██████╗██╗ ██╗ ║
║ ██║████╗ ██║██║ ██║██╔════╝████╗ ██║╚══██╔══╝██╔═══██╗██╔══██╗╚██╗ ██╔╝ ║
║ ██║██╔██╗ ██║██║ ██║█████╗ ██╔██╗ ██║ ██║ ██║ ██║██████╔╝ ╚████╔╝ ║
║ ██║██║╚██╗██║╚██╗ ██╔╝██╔══╝ ██║╚██╗██║ ██║ ██║ ██║██╔══██╗ ╚██╔╝ ║
║ ██║██║ ╚████║ ╚████╔╝ ███████╗██║ ╚████║ ██║ ╚██████╔╝██║ ██║ ██║ ║
║ ╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ║
║ ║
║ ███╗ ███╗ █████╗ ███╗ ██╗ █████╗ ██████╗ ███████╗███╗ ███╗███████╗███╗ ██╗████████╗ ║
║ ████╗ ████║██╔══██╗████╗ ██║██╔══██╗██╔════╝ ██╔════╝████╗ ████║██╔════╝████╗ ██║╚══██╔══╝ ║
║ ██╔████╔██║███████║██╔██╗ ██║███████║██║ ███╗█████╗ ██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ║
║ ██║╚██╔╝██║██╔══██║██║╚██╗██║██╔══██║██║ ██║██╔══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ║
║ ██║ ╚═╝ ██║██║ ██║██║ ╚████║██║ ██║╚██████╔╝███████╗██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ║
║ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ║
║ ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════╝
A comprehensive Spring Boot application for multi-warehouse inventory management with advanced tracking and analytics
Features • Tech Stack • Getting Started • API Documentation • License
Inventory Management System is an enterprise-grade Spring Boot application designed for comprehensive inventory tracking across multiple warehouses. It provides complete functionality for managing products, stock levels, suppliers, purchases, sales, and inter-warehouse transfers with advanced features like batch tracking, expiry management, and inventory valuation.
This project demonstrates:
- Multi-warehouse inventory management
- Complex JPA entity relationships
- RESTful API design with comprehensive endpoints
- Service layer architecture with business logic
- Advanced querying and reporting capabilities
- ✅ Multi-Warehouse Support - Track inventory across multiple warehouse locations
- ✅ Product Management - Comprehensive product catalog with SKU and barcode support
- ✅ Stock Tracking - Real-time stock levels with batch and lot number tracking
- ✅ Supplier Management - Vendor management with ratings and payment terms
- ✅ Purchase Orders - Complete purchase order lifecycle management
- ✅ Sales Orders - Sales order processing with payment tracking
- ✅ Stock Transfers - Inter-warehouse stock transfer with approval workflow
- 📊 Inventory Valuation - Support for FIFO, LIFO, and Average costing methods
- 📅 Expiry Tracking - Batch and expiry date management for perishable goods
- 🔔 Low Stock Alerts - Automatic alerts when stock falls below reorder levels
- 📈 Analytics Ready - Date range queries for reporting and forecasting
- 🏷️ Barcode/QR Support - Product identification via barcode scanning
- 💰 Financial Tracking - Cost price, selling price, and profit margin tracking
| Technology | Version | Purpose |
|---|---|---|
| Java | 21 | Programming Language |
| Spring Boot | 4.0.1 | Application Framework |
| Spring Data JPA | 4.0.1 | Data Access Layer |
| Hibernate | (via Spring Boot) | ORM Framework |
| MySQL | 8.0+ | Relational Database |
| Maven | 4.0.0 | Build Tool |
| Spring Boot DevTools | 4.0.1 | Development Utilities |
Represents items in the inventory system
- Product information (name, SKU, barcode, description)
- Pricing (cost price, selling price)
- Category and unit of measurement
- Reorder level for low stock alerts
Represents storage locations
- Warehouse identification (code, name)
- Location details (address, city, state, country)
- Contact information
- Capacity tracking
- Active/inactive status
Tracks inventory levels in warehouses
- Product-warehouse relationship
- Quantity tracking
- Batch and lot number
- Expiry and manufacturing dates
- Valuation method (FIFO/LIFO/Average)
Manages vendor information
- Supplier details (code, name, contact)
- Payment terms and credit limit
- Rating system (1-5 stars)
- Active/inactive status
Purchase order management
- Order tracking (PO number, dates)
- Supplier and product relationship
- Quantity and pricing
- Order status (Pending, Confirmed, Shipped, Delivered, Cancelled)
- Batch and expiry tracking
Sales order processing
- Order tracking (SO number, dates)
- Customer information
- Quantity, pricing, discount, and tax
- Payment status (Unpaid, Partially Paid, Paid, Refunded)
- Order status (Pending, Confirmed, Processing, Shipped, Delivered, Cancelled, Returned)
Inter-warehouse stock transfers
- Transfer tracking (transfer number, dates)
- Source and destination warehouses
- Product and quantity
- Transfer status (Pending, Approved, In Transit, Received, Cancelled, Rejected)
- Approval workflow (initiated by, approved by, received by)
- Java Development Kit (JDK) 21 or higher
- Maven 3.6+
- MySQL 8.0+ installed and running
- Git for cloning the repository
-
Clone the repository
git clone https://github.com/Dronanaik/Java_Backend.git cd Java_Backend/InventoryManagement -
Create MySQL Database
mysql -u root -p
Then execute:
CREATE DATABASE inventory_management; EXIT;
-
Configure Database Connection
Edit
src/main/resources/application.properties:spring.datasource.username=your_mysql_username spring.datasource.password=your_mysql_password
-
Install Dependencies
mvn clean install
mvn spring-boot:runThe application will start on http://localhost:8080
http://localhost:8080/api
GET /products- Get all productsGET /products/{id}- Get product by IDGET /products/sku/{sku}- Get product by SKUGET /products/barcode/{barcode}- Get product by barcodeGET /products/category/{category}- Get products by categoryGET /products/search?name={name}- Search products by namePOST /products- Create new productPUT /products/{id}- Update productDELETE /products/{id}- Delete product
GET /warehouses- Get all warehousesGET /warehouses/{id}- Get warehouse by IDGET /warehouses/code/{code}- Get warehouse by codeGET /warehouses/active- Get active warehousesGET /warehouses/city/{city}- Get warehouses by cityPOST /warehouses- Create new warehousePUT /warehouses/{id}- Update warehouseDELETE /warehouses/{id}- Delete warehouse
GET /stocks- Get all stocksGET /stocks/{id}- Get stock by IDGET /stocks/product/{productId}- Get stocks by productGET /stocks/warehouse/{warehouseId}- Get stocks by warehouseGET /stocks/product/{productId}/warehouse/{warehouseId}- Get stock by product and warehouseGET /stocks/expiring?beforeDate={date}- Get expiring stocksGET /stocks/low-stock- Get low stock itemsPOST /stocks- Create new stockPUT /stocks/{id}- Update stockDELETE /stocks/{id}- Delete stock
GET /suppliers- Get all suppliersGET /suppliers/{id}- Get supplier by IDGET /suppliers/code/{code}- Get supplier by codeGET /suppliers/active- Get active suppliersGET /suppliers/rating/{rating}- Get suppliers by ratingPOST /suppliers- Create new supplierPUT /suppliers/{id}- Update supplierDELETE /suppliers/{id}- Delete supplier
GET /purchases- Get all purchasesGET /purchases/{id}- Get purchase by IDGET /purchases/order/{orderNumber}- Get purchase by order numberGET /purchases/supplier/{supplierId}- Get purchases by supplierGET /purchases/status/{status}- Get purchases by statusGET /purchases/date-range?startDate={start}&endDate={end}- Get purchases by date rangePOST /purchases- Create new purchasePUT /purchases/{id}- Update purchaseDELETE /purchases/{id}- Delete purchase
GET /sales- Get all salesGET /sales/{id}- Get sale by IDGET /sales/order/{orderNumber}- Get sale by order numberGET /sales/status/{status}- Get sales by statusGET /sales/payment-status/{paymentStatus}- Get sales by payment statusGET /sales/date-range?startDate={start}&endDate={end}- Get sales by date rangeGET /sales/customer?name={name}- Search sales by customer namePOST /sales- Create new salePUT /sales/{id}- Update saleDELETE /sales/{id}- Delete sale
GET /transfers- Get all transfersGET /transfers/{id}- Get transfer by IDGET /transfers/number/{transferNumber}- Get transfer by numberGET /transfers/from-warehouse/{warehouseId}- Get transfers from warehouseGET /transfers/to-warehouse/{warehouseId}- Get transfers to warehouseGET /transfers/status/{status}- Get transfers by statusPOST /transfers- Create new transferPUT /transfers/{id}- Update transferDELETE /transfers/{id}- Delete transfer
The application uses complex JPA relationships:
Product (1) ────< (N) Stock >──── (1) Warehouse
│
Supplier (1) ────< (N) Purchase >──── (1) Product
>──── (1) Warehouse
Product (1) ────< (N) Sale >──── (1) Warehouse
Product (1) ────< (N) Transfer
Warehouse (1) ──< (N) Transfer (from)
Warehouse (1) ──< (N) Transfer (to)
Key Relationships:
- Product → Stock: One-to-Many (One product can exist in multiple warehouses)
- Warehouse → Stock: One-to-Many (One warehouse can store multiple products)
- Supplier → Purchase: One-to-Many (One supplier can have multiple purchase orders)
- Product → Purchase/Sale/Transfer: One-to-Many relationships for tracking
The following sequence diagrams illustrate the request flow through the application layers for various inventory management operations:
sequenceDiagram
participant Client
participant Controller as ProductController
participant Service as ProductService
participant Repository as ProductRepository
participant DB as MySQL Database
Client->>Controller: POST /api/products
Note over Client,Controller: Request Body: Product JSON<br/>(name, SKU, barcode, pricing)
Controller->>Service: createProduct(product)
activate Service
Service->>Repository: save(product)
activate Repository
Repository->>DB: INSERT INTO products
activate DB
Note over DB: Auto-generate ID<br/>Set timestamps
DB-->>Repository: Product Entity (with ID)
deactivate DB
Repository-->>Service: Product Entity
deactivate Repository
Service-->>Controller: Product Entity
deactivate Service
Controller-->>Client: 201 Created + Product JSON
Note over Controller,Client: Response: Created Product
sequenceDiagram
participant Client
participant StockController
participant StockService
participant StockRepo as StockRepository
participant ProductRepo as ProductRepository
participant WarehouseRepo as WarehouseRepository
participant DB as MySQL Database
Client->>StockController: POST /api/stocks
Note over Client: Stock with Product ID<br/>& Warehouse ID
StockController->>StockService: createStock(stock)
activate StockService
StockService->>ProductRepo: findById(productId)
activate ProductRepo
ProductRepo->>DB: SELECT * FROM products WHERE id=?
DB-->>ProductRepo: Product Entity
deactivate ProductRepo
StockService->>WarehouseRepo: findById(warehouseId)
activate WarehouseRepo
WarehouseRepo->>DB: SELECT * FROM warehouses WHERE id=?
DB-->>WarehouseRepo: Warehouse Entity
deactivate WarehouseRepo
StockService->>StockRepo: save(stock)
activate StockRepo
StockRepo->>DB: INSERT INTO stocks
Note over DB: Link Product & Warehouse<br/>Set batch, expiry dates
DB-->>StockRepo: Stock Entity
deactivate StockRepo
StockRepo-->>StockService: Stock Entity
deactivate StockService
StockService-->>StockController: Stock Entity
StockController-->>Client: 201 Created
sequenceDiagram
participant Client
participant PurchaseController
participant PurchaseService
participant PurchaseRepo as PurchaseRepository
participant StockService
participant DB as MySQL Database
rect rgb(200, 220, 250)
Note over Client,DB: 1. Create Purchase Order
Client->>PurchaseController: POST /api/purchases
Note over Client: PO with Supplier, Product,<br/>Quantity, Status: PENDING
PurchaseController->>PurchaseService: createPurchase(purchase)
activate PurchaseService
PurchaseService->>PurchaseRepo: save(purchase)
PurchaseRepo->>DB: INSERT INTO purchases
DB-->>PurchaseService: Purchase (PENDING)
deactivate PurchaseService
PurchaseService-->>Client: 201 Created
end
rect rgb(220, 250, 220)
Note over Client,DB: 2. Update Status to DELIVERED
Client->>PurchaseController: PUT /api/purchases/{id}
Note over Client: Update status: DELIVERED
PurchaseController->>PurchaseService: updatePurchase(id, updated)
activate PurchaseService
PurchaseService->>PurchaseRepo: save(updated)
PurchaseRepo->>DB: UPDATE purchases SET status='DELIVERED'
Note over PurchaseService: Trigger Stock Update
PurchaseService->>StockService: updateStock(productId, warehouseId, +quantity)
activate StockService
StockService->>DB: UPDATE stocks SET quantity = quantity + ?
deactivate StockService
DB-->>PurchaseService: Updated Purchase
deactivate PurchaseService
PurchaseService-->>Client: 200 OK
end
sequenceDiagram
participant Client
participant API as Sale API
participant Service as Business Logic
participant DB as Database
Client->>API: POST /api/sales
API->>Service: Process Sale Order
activate Service
Service->>DB: Check Stock Availability
DB-->>Service: Stock Status
alt Stock Available
Service->>DB: Create Sale Record
Service->>DB: Reduce Stock Quantity
DB-->>Service: Success
Service-->>API: Sale Created
API-->>Client: 201 Created
else Insufficient Stock
Service-->>API: Stock Unavailable
API-->>Client: 400 Bad Request
end
deactivate Service
Phase 1: Initiate Transfer
sequenceDiagram
participant Client
participant API as Transfer API
participant Service as Business Logic
participant DB as Database
Client->>API: POST /api/transfers
API->>Service: Create Transfer Request
activate Service
Service->>DB: Check Stock in Source Warehouse
DB-->>Service: Stock Status
alt Stock Available
Service->>DB: Save Transfer (Status: PENDING)
DB-->>Service: Transfer Created
Service-->>API: Transfer Entity
API-->>Client: 201 Created
else Insufficient Stock
Service-->>API: Stock Unavailable
API-->>Client: 400 Bad Request
end
deactivate Service
Phase 2: Execute Transfer
sequenceDiagram
participant Client
participant API as Transfer API
participant Service as Business Logic
participant DB as Database
Client->>API: PUT /api/transfers/{id}
API->>Service: Execute Transfer
activate Service
Service->>DB: BEGIN TRANSACTION
Service->>DB: Reduce Stock from Source
Service->>DB: Add Stock to Destination
Service->>DB: Update Transfer Status (RECEIVED)
Service->>DB: COMMIT TRANSACTION
DB-->>Service: Success
Service-->>API: Transfer Completed
API-->>Client: 200 OK
deactivate Service
sequenceDiagram
participant Client
participant StockController
participant StockService
participant StockRepo as StockRepository
participant ProductRepo as ProductRepository
participant DB as MySQL Database
Client->>StockController: GET /api/stocks/low-stock
StockController->>StockService: getLowStockItems()
activate StockService
StockService->>StockRepo: findLowStockItems()
activate StockRepo
StockRepo->>DB: SELECT s.*, p.* FROM stocks s<br/>JOIN products p ON s.product_id = p.id<br/>WHERE s.quantity <= p.reorder_level
activate DB
Note over DB: Complex JOIN query<br/>comparing stock vs reorder level
DB-->>StockRepo: List<Stock> with Product details
deactivate DB
StockRepo-->>StockService: List<Stock>
deactivate StockRepo
StockService-->>StockController: List<Stock>
deactivate StockService
StockController-->>Client: 200 OK + Low Stock Items
Note over Client: Alert: Products need reordering
sequenceDiagram
participant Main as Application.java
participant Spring as Spring Boot
participant JPA as JPA/Hibernate
participant DB as MySQL Database
Main->>Spring: SpringApplication.run()
activate Spring
Spring->>Spring: Component Scanning
Note over Spring: Scan packages:<br/>- com.inventory.product<br/>- com.inventory.warehouse<br/>- com.inventory.stock<br/>- com.inventory.supplier<br/>- com.inventory.purchase<br/>- com.inventory.sale<br/>- com.inventory.transfer
Spring->>Spring: Initialize Beans
Note over Spring: - Controllers (7)<br/>- Services (7)<br/>- Repositories (7)
Spring->>JPA: Initialize JPA
activate JPA
JPA->>DB: Connect to Database
activate DB
DB-->>JPA: Connection Established
JPA->>DB: Validate/Update Schema
Note over DB: ddl-auto=update<br/>Create/Update Tables:<br/>products, warehouses, stocks,<br/>suppliers, purchases, sales, transfers
DB-->>JPA: Schema Ready
deactivate DB
deactivate JPA
Spring-->>Main: Application Started
deactivate Spring
Note over Main: Server running on port 8080
sequenceDiagram
participant Client
participant Controller
participant Service
participant Repository
participant DB
rect rgb(200, 220, 250)
Note over Client,DB: CREATE Operation
Client->>Controller: POST /api/{entity}
Controller->>Service: create{Entity}(entity)
Service->>Repository: save(entity)
Repository->>DB: INSERT
DB-->>Client: 201 Created
end
rect rgb(220, 250, 220)
Note over Client,DB: READ Operation
Client->>Controller: GET /api/{entity}/{id}
Controller->>Service: get{Entity}(id)
Service->>Repository: findById(id)
Repository->>DB: SELECT
DB-->>Client: 200 OK + Data
end
rect rgb(250, 240, 200)
Note over Client,DB: UPDATE Operation
Client->>Controller: PUT /api/{entity}/{id}
Controller->>Service: update{Entity}(id, updated)
Service->>Repository: save(updated)
Repository->>DB: UPDATE
DB-->>Client: 200 OK + Updated Data
end
rect rgb(250, 220, 220)
Note over Client,DB: DELETE Operation
Client->>Controller: DELETE /api/{entity}/{id}
Controller->>Service: delete{Entity}(id)
Service->>Repository: deleteById(id)
Repository->>DB: DELETE
DB-->>Client: 200 OK + Message
end
sequenceDiagram
participant Client
participant Controller
participant Service
participant Repository
participant DB
Client->>Controller: GET /api/products/999
Controller->>Service: getProduct(999)
activate Service
Service->>Repository: findById(999)
activate Repository
Repository->>DB: SELECT * FROM products WHERE id=999
activate DB
DB-->>Repository: Empty Result
deactivate DB
Repository-->>Service: Optional.empty()
deactivate Repository
Service->>Service: Handle Not Found
Service-->>Controller: throw Exception / null
deactivate Service
Controller-->>Client: 404 Not Found
Note over Client: Error: Product not found
Key Components:
- Controller Layer: Handles HTTP requests/responses, validates input, manages REST endpoints
- Service Layer: Contains business logic, transaction management, orchestrates operations
- Repository Layer: Data access abstraction using Spring Data JPA with custom queries
- Database: MySQL persistence with complex relationships and constraints
- Transaction Management: Ensures data consistency for multi-step operations (transfers, sales)
- Stock Management: Real-time inventory tracking with automatic updates on purchases/sales
Special Features:
- Multi-Warehouse Support: Stock tracking across different warehouse locations
- Transaction Safety: ACID compliance for critical operations like transfers
- Advanced Queries: Custom repository methods for low stock alerts, expiry tracking
- Status Workflows: State management for purchases, sales, and transfers
- Automatic Timestamps:
@PrePersistand@PreUpdatelifecycle callbacks
This project is licensed under the MIT License:
MIT License
Copyright (c) 2025 Java Backend Projects
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
⭐ If you find this project helpful, please consider giving it a star!
Made with ❤️ using Spring Boot & Java