A full-stack Inventory Management System built with React + Vite on the frontend and ASP.NET Core Web API + Entity Framework Core + SQL Server on the backend.
StockFlow is designed to demonstrate practical backend and full-stack development concepts such as JWT authentication, role-based authorization, layered architecture, inventory validation, atomic stock operations, audit logging, database constraints, dependency injection, and RESTful API design.
- JWT-based stateless authentication
- BCrypt password hashing
- Role-based access control with Admin and Employee roles
- Backend authorization using
[Authorize] - Admin-only operations protected at the API level
- JWT stored and attached to requests by Axios on the frontend
- Unauthorized actions return appropriate
401/403responses
- Create, view, update, and delete products
- Unique SKU validation
- Product search
- Pagination
- Minimum stock level configuration
- Create, view, update, and delete warehouses
- Store warehouse location details
- Manage inventory across multiple warehouses
- View current inventory levels
- Stock-in operations
- Stock-out operations
- Prevent stock from becoming negative
- Low-stock detection based on minimum stock level
- Track inventory separately for each product and warehouse
- Record every stock-in and stock-out operation
- Store product, warehouse, user, quantity, movement type, and timestamp
- Preserve historical movement records using restricted delete behavior
- Custom global exception handling middleware
- Dependency Injection
- EF Core migrations and database seeding
- LINQ-based database queries
- SQL Server constraints and indexes
- Consistent API error responses
- Built-in logging using
ILogger
- Swagger / OpenAPI integration
- Interactive API testing through Swagger UI
- Clearly separated REST endpoints for authentication, products, warehouses, inventory, and stock movements
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ React Client โ
โ Vite + Axios โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
HTTP + JWT Bearer
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ASP.NET Core Web API โ
โ โ
โ CORS / Exception Middlewareโ
โ โ โ
โ โผ โ
โ Controllers โ
โ โ โ
โ โผ โ
โ Services โ
โ Business Logic โ
โ โ โ
โ โผ โ
โ EF Core โ
โ DbContext โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ SQL Server โ
โ StockFlowDb โ
โโโโโโโโโโโโโโโ
Client Request
โ
โผ
Axios
โ
โผ
JWT Bearer Token
โ
โผ
ASP.NET Core Middleware
โ
โโโ Exception Handling
โโโ CORS
โ
โผ
Controller
โ
โโโ Authentication / Authorization
โโโ Request Validation
โ
โผ
Service Layer
โ
โโโ Business Rules
โโโ Inventory Validation
โโโ LINQ Queries
โโโ Stock Movement Logging
โ
โผ
EF Core DbContext
โ
โผ
SQL Server
| Layer | Technology |
|---|---|
| Frontend | React |
| Build Tool | Vite |
| Frontend Language | JavaScript ES6+ |
| Routing | React Router DOM |
| HTTP Client | Axios |
| Styling | Vanilla CSS |
| Backend | ASP.NET Core Web API |
| Language | C# |
| Framework | .NET 8 |
| ORM | Entity Framework Core 8 |
| Database | Microsoft SQL Server |
| Authentication | JWT Bearer |
| Password Hashing | BCrypt.Net-Next |
| API Documentation | Swagger / OpenAPI |
| Logging | ILogger |
StockFlow uses five main tables in SQL Server.
erDiagram
Users {
int Id PK
string Username UK
string Email UK
string PasswordHash
string Role
datetime CreatedAt
}
Products {
int Id PK
string Name
string SKU UK
string Description
decimal Price
int MinimumStockLevel
datetime CreatedAt
datetime UpdatedAt
}
Warehouses {
int Id PK
string Name
string Location
datetime CreatedAt
}
Inventory {
int Id PK
int ProductId FK
int WarehouseId FK
int Quantity
datetime LastUpdated
}
StockMovements {
int Id PK
int ProductId FK
int WarehouseId FK
int UserId FK
int MovementType
int Quantity
datetime CreatedAt
}
Users ||--o{ StockMovements : records
Products ||--o{ Inventory : stores
Products ||--o{ StockMovements : traces
Warehouses ||--o{ Inventory : houses
Warehouses ||--o{ StockMovements : logs
-
Unique indexes
Users.UsernameUsers.EmailProducts.SKU
-
Composite unique constraint
Inventory(ProductId, WarehouseId)- Ensures one inventory record exists for a product within a warehouse.
-
Historical integrity
StockMovementsuses restricted deletion behavior so historical records are not accidentally orphaned.
StockFlow uses JWT (JSON Web Tokens) for authentication.
Login
โ
โผ
Validate Username + Password
โ
โผ
Verify BCrypt Password Hash
โ
โผ
Generate JWT
โ
โผ
Return Token + Username + Role
โ
โผ
Frontend Stores Authentication Data
โ
โผ
Axios Sends:
Authorization: Bearer <token>
| Action | Admin | Employee |
|---|---|---|
| Login | โ | โ |
| View Products | โ | โ |
| Create / Edit / Delete Products | โ | โ |
| View Warehouses | โ | โ |
| Create / Edit / Delete Warehouses | โ | โ |
| View Inventory | โ | โ |
| Stock In | โ | โ |
| Stock Out | โ | โ |
| View Stock Movement History | โ | โ |
| Create User Accounts | โ | โ |
Important: Frontend role checks only control the UI. The backend remains the final authority for authorization.
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
POST |
/api/auth/login |
Public | Validate credentials and return JWT |
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
POST |
/api/users |
Admin | Create a new user |
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
GET |
/api/products |
All Users | Get products with search and pagination |
GET |
/api/products/{id} |
All Users | Get product by ID |
POST |
/api/products |
Admin | Create a product |
PUT |
/api/products/{id} |
Admin | Update a product |
DELETE |
/api/products/{id} |
Admin | Delete a product |
Example search:
GET /api/products?search=mouse
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
GET |
/api/warehouses |
All Users | Get all warehouses |
GET |
/api/warehouses/{id} |
All Users | Get warehouse by ID |
POST |
/api/warehouses |
Admin | Create a warehouse |
PUT |
/api/warehouses/{id} |
Admin | Update a warehouse |
DELETE |
/api/warehouses/{id} |
Admin | Delete a warehouse |
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
GET |
/api/inventory |
All Users | Get current inventory |
GET |
/api/inventory/low-stock |
All Users | Get low-stock products |
POST |
/api/inventory/stock-in |
All Users | Add stock and record movement |
POST |
/api/inventory/stock-out |
All Users | Remove stock after validation |
| Method | Endpoint | Authorization | Description |
|---|---|---|---|
GET |
/api/stock-movements |
All Users | Get stock movement history |
Stock In Request
โ
โผ
Find Product + Warehouse
โ
โผ
Increase Inventory Quantity
โ
โผ
Create StockMovement Record
โ
โผ
Save Changes
StockFlow validates available inventory before removing stock.
Current Stock = 10
Requested Stock Out = 15
โ
Insufficient Quantity
โ
โ 400 Bad Request
This prevents negative inventory values.
A product is considered low-stock when:
Current Quantity <= Minimum Stock Level
Low-stock products are highlighted on the Dashboard and Inventory page.
Every stock operation records:
Product
Warehouse
User
Movement Type
Quantity
Timestamp
Example:
Employee โ Warehouse A โ Laptop โ STOCK_IN โ +20
Employee โ Warehouse A โ Laptop โ STOCK_OUT โ -5
This provides a basic audit history of inventory changes.
StockFlow uses custom exception handling middleware to provide consistent API responses.
Example:
{
"success": false,
"message": "An unexpected error occurred."
}Detailed exception information is logged using ILogger, while the client receives a controlled response.
Once the backend is running, open:
http://localhost:5045/swagger
Swagger provides an interactive interface for:
- Viewing API endpoints
- Inspecting request models
- Testing API operations
- Checking response codes
- Testing authenticated endpoints
The project includes practical verification scenarios for important business rules.
Trigger an invalid entity request or an unhandled service error.
Expected:
Controlled API error response
+
Exception logged on the server
Try to remove more stock than currently available.
Example:
Available Stock: 5
Stock Out: 10
Expected:
400 Bad Request
The inventory quantity remains unchanged.
If:
Quantity <= MinimumStockLevel
the product is highlighted on the Dashboard and Inventory page.
StockFlow/
โ
โโโ Backend/
โ โโโ Controllers/
โ โโโ Services/
โ โโโ Models/
โ โโโ Data/
โ โโโ Middleware/
โ โโโ Migrations/
โ โโโ Program.cs
โ
โโโ Frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โโโ pages/
โ โ โโโ context/
โ โ โโโ services/
โ โโโ public/
โ โโโ package.json
โ
โโโ README.md
Install the following:
- .NET 8 SDK
- Node.js
- SQL Server LocalDB or SQL Server Express
- Git
git clone <your-repository-url>
cd StockFlowcd Backend
dotnet restoreApply EF Core migrations:
dotnet ef database updateThis creates the StockFlowDb database and applies the existing migrations with seed data.
dotnet runBackend:
http://localhost:5045
Swagger:
http://localhost:5045/swagger
Open a new terminal:
cd Frontend
npm install
npm run devFrontend:
http://localhost:5173
Seeded accounts are available for testing both roles.
| Role | Username | Password |
|---|---|---|
| ๐ Admin | admin |
Admin@123 |
| ๐ค Employee | employee |
Employee@123 |
โ ๏ธ These credentials are intended for local/demo usage only.
Business logic is separated from HTTP request handling.
Controller
โ
Service
โ
DbContext
โ
SQL Server
This keeps controllers lightweight and makes the backend easier to maintain.
ASP.NET Core Dependency Injection is used to provide services and database dependencies where required.
Entity Framework Core handles database access while LINQ is used for queries such as:
- Product search
- Pagination
- Inventory retrieval
- Low-stock filtering
- Stock movement history
Although the React UI hides restricted actions, authorization is enforced on the API itself.
This prevents users from bypassing UI restrictions by directly calling endpoints.
Stock-out operations validate available quantity before modifying inventory, preventing negative stock.
Planned improvements include:
- ๐ JWT refresh tokens
- ๐ Multi-warehouse stock transfers
- ๐๏ธ Soft deletes for products and warehouses
- ๐ Advanced inventory analytics
- ๐ More detailed reporting
- ๐ More advanced inventory filtering
Status: โ Completed
Current implementation includes:
- โ JWT authentication
- โ Admin / Employee RBAC
- โ Product CRUD
- โ Warehouse CRUD
- โ Inventory management
- โ Stock-in / stock-out
- โ Low-stock detection
- โ Stock movement history
- โ BCrypt password hashing
- โ EF Core migrations
- โ SQL Server database
- โ Global exception handling
- โ Dependency Injection
- โ Swagger / OpenAPI
- โ React + Vite frontend
Yash Barai
MCA Student | Full-Stack Developer
Built as a practical full-stack project to demonstrate ASP.NET Core Web API, C#, EF Core, SQL Server, React, authentication, authorization, inventory business logic, and clean backend architecture.
โญ If you found this project useful, consider giving the repository a star!