Stock_Ease is a web-based inventory management system designed to track products, manage stock levels, monitor inventory health through alerts, and integrate with simulated weight sensors for real-time updates.
- Product Management: Maintain a catalog of products including details like name, barcode, quantity/weight tracking, minimum stock thresholds, expiry dates, and associated sensor IDs. Full CRUD (Create, Read, Update, Delete) operations are supported.
- Transaction Tracking: Record manual stock adjustments (incoming/outgoing) associated with specific users and products.
- User Management: Basic user tracking with roles.
- Alerting System:
- Automatically generates alerts when product levels (quantity or weight) fall below predefined thresholds.
- Includes logic for restocking periods to prevent alert fatigue.
- Distinguishes between unread (active) and read (historical) alerts.
- Provides an alert history view.
- Weight Sensor Integration:
- Tracks product levels based on data received from simulated external weight sensors via a dedicated API endpoint (
/api/weightintegration/screendata
). - Supports configuring products for either quantity-based or weight-based tracking.
- Displays the last known weight reported by sensors.
- Tracks product levels based on data received from simulated external weight sensors via a dedicated API endpoint (
- Real-time UI Updates: Utilizes SignalR to provide immediate visual feedback on the product list page when weight sensor data is updated, without requiring a page refresh.
- Reporting: Basic structure for generating inventory reports.
- Sensor Monitoring: Displays the status of connected sensors.
- Core Framework: ASP.NET Core 8 MVC
- Language: C# 12
- Database: Microsoft SQL Server
- Object-Relational Mapper (ORM): Entity Framework Core 8
- Frontend: Razor Views (CSHTML), HTML5, CSS3, Bootstrap 5, JavaScript
- Real-time Communication: ASP.NET Core SignalR
- Testing: MSTest (Unit Testing), T-SQL (Database Integrity Checks)
- Development Environment: Visual Studio 2022+, .NET 8 SDK
The application follows the Model-View-Controller (MVC) architectural pattern, promoting separation of concerns. It leverages ASP.NET Core's built-in Dependency Injection (DI) container for managing services like the DbContext
, SignalR HubContext
, and custom services (WeightSensorStatusService
).
- Models: Define domain entities (
Product
,User
, etc.) and theDbContext
for EF Core interactions. - Views: Razor views (
.cshtml
) render the user interface using HTML, CSS, and JavaScript. - Controllers: Handle HTTP requests, interact with models and services, and select views to render.
- Services: Encapsulate specific business logic (e.g.,
WeightSensorStatusService
for managing sensor state and restocking timers).
(Note: The SensorId
in Product
conceptually links to an external sensor system.)
-
Prerequisites:
- .NET 8 SDK or later.
- Microsoft SQL Server (Express, Developer, or Standard edition). Ensure the server instance is running.
- (Optional) Python 3 for running the sensor simulation script.
-
Clone the Repository:
git clone <repository-url> cd Stock_Ease
-
Configure Database Connection:
- Open the
Stock_Ease/appsettings.json
file. - Locate the
ConnectionStrings
section:"ConnectionStrings": { "Stock_EaseContext": "Data Source=Cr33p3r;Initial Catalog=stock_ease;Integrated Security=True;Encrypt=False;Trust Server Certificate=True" }
- The current connection string uses Integrated Security (Windows Authentication) to connect to the SQL Server instance named
Cr33p3r
and the databasestock_ease
. - If this configuration works for your environment, you can skip this step.
- Otherwise, update the
Data Source
(server name/instance),Initial Catalog
(database name), and authentication details (e.g., switch to SQL Server authentication withUser ID
andPassword
if needed) to match your SQL Server setup.
- Open the
-
Apply Database Migrations:
- Open a terminal or command prompt in the
Stock_Ease
directory (the one containingStock_Ease.csproj
). - Run the following command to create the database and apply the schema:
dotnet ef database update --project Stock_Ease/Stock_Ease.csproj
- (Note: If you don't have the EF Core tools installed, run
dotnet tool install --global dotnet-ef
first.)
- Open a terminal or command prompt in the
-
Run the Application:
- You can run the application using the .NET CLI:
dotnet run --project Stock_Ease/Stock_Ease.csproj
- Alternatively, open the
Stock_Ease.sln
file in Visual Studio and press F5 or click the "Start Debugging" button. - The application should be accessible at the URLs specified in
Stock_Ease/Properties/launchSettings.json
(typicallyhttps://localhost:xxxx
andhttp://localhost:yyyy
).
- You can run the application using the .NET CLI:
-
(Optional) Run Sensor Simulation:
- Navigate to the
Stock_Ease/external_scripts
directory. - Ensure the API URL in
ocr_sender.py
matches the running application's URL (if different from the default). - Run the script:
python ocr_sender.py
- This will start sending simulated weight data to the application's API endpoint, triggering real-time updates if configured.
- Navigate to the