- Overview
- Architecture
- Features
- Technologies Used
- Folder Structure
- Getting Started
- Usage
- API Endpoints
- Entities
- AutoMapper Setup
- Behaviors
- Contributing
The Inventory Management System is a comprehensive solution for managing categories, products, product details, product inventory, and suppliers. It is built using a clean architecture approach, with a separation of concerns between the API, application logic, and infrastructure. The system allows users to perform CRUD (Create, Read, Update, Delete) operations on the five entities: Category, Product, ProductDetail, ProductInventory, and Supplier.
The project follows a layered architecture, adhering to the principles of clean architecture and CQRS (Command Query Responsibility Segregation). The main layers are:
- API: Handles HTTP requests and responses.
- Application: Contains business logic, including commands, queries, and pipeline behaviors.
- Core: Contains the domain models and interfaces.
- Infrastructure: Contains the implementations of the interfaces defined in the Core layer, such as database access.
- CRUD operations for Categories, Products, ProductDetails, ProductInventories, and Suppliers.
- Validation, logging, and performance monitoring using MediatR pipeline behaviors.
- AutoMapper integration for mapping between domain models and DTOs.
- Frontend built with React and Tailwind CSS, providing a responsive user interface.
-
Backend:
- ASP.NET Core
- Entity Framework Core
- AutoMapper
- FluentValidation
- SQL Server
-
Frontend:
- React
- TypeScript
- Vite
- Tailwind CSS
- Axios
InventoryService/
├── Api/ # API layer containing controllers
├── Application/ # Application layer containing business logic
│ ├── Behaviors/ # MediatR pipeline behaviors (Validation, Logging, Performance)
│ ├── Mappings/ # AutoMapper profiles
│ ├── Services/ # Application services
│ └── DTOs/ # Data Transfer Objects (DTOs)
├── Core/ # Core layer containing domain models and interfaces
├── Infrastructure/ # Infrastructure layer containing database access
├── Migrations/ # EF Core migrations
└── Properties/ # Application properties and settingsinventory-frontend/
├── public/ # Static assets
├── src/ # Source files
│ ├── components/ # React components
│ ├── pages/ # React pages
│ ├── services/ # API service calls
│ ├── interfaces/ # TypeScript interfaces
│ ├── App.tsx # Main app component
│ ├── main.tsx # Entry point
│ └── index.css # Global CSS
└── vite.config.ts # Vite configurationBefore you begin, ensure you have the following installed on your machine:
- .NET 6 SDK
- Node.js (version 14 or higher)
- SQL Server (or use Docker for a containerized instance)
- Clone the repository:
git clone https://github.com/iaashu98/inventory-management-system.git
cd inventory-management-system/InventoryService- Restore NuGet packages:
dotnet restore- Update the database: Ensure your SQL Server is running and update the database using Entity Framework Core migrations:
dotnet ef database update- Run the backend:
dotnet run- Navigate to the frontend directory:
cd inventory-management-system/inventory-frontend- Install npm dependencies:
npm install- Run the frontend:
npm run devTo start the backend server, navigate to the InventoryService directory and run:
dotnet runThe API will be available at http://localhost:5000.
To start the frontend development server, navigate to the inventory-frontend directory and run:
npm run devThe frontend will be available at http://localhost:3000.
Category
- GET /api/categories: Retrieve all categories.
- GET /api/categories/{id}: Retrieve a category by ID.
- POST /api/categories: Create a new category.
- PUT /api/categories/{id}: Update an existing category.
- DELETE /api/categories/{id}: Delete a category.
- SEARCH /api/categories/search/{searchtext}: Search a category.
Product
- GET /api/products: Retrieve all products.
- GET /api/products/{id}: Retrieve a product by ID.
- GET /api/products/{name}: Retrieve a product by Name.
- POST /api/products: Create a new product.
- PUT /api/products/{id}: Update an existing product.
- DELETE /api/products/{id}: Delete a product.
- SEARCH /api/products/search/{searchtext}: Search a product.
ProductDetail
- GET /api/productdetails: Retrieve all product details.
- GET /api/productdetails/{id}: Retrieve product details by ID.
- POST /api/productdetails: Create new product details.
- PUT /api/productdetails/{id}: Update existing product details.
- DELETE /api/productdetails/{id}: Delete product details.
- SEARCH /api/productdetails/search/{searchtext}: Search a product details.
ProductInventory
- GET /api/productinventories: Retrieve all product inventories.
- GET /api/productinventories/{id}: Retrieve product inventory by ID.
- POST /api/productinventories: Create a new product inventory.
- PUT /api/productinventories/{id}: Update an existing product inventory.
- DELETE /api/productinventories/{id}: Delete a product inventory.
Supplier
- GET /api/suppliers: Retrieve all suppliers.
- GET /api/suppliers/{id}: Retrieve a supplier by ID.
- POST /api/suppliers: Create a new supplier.
- PUT /api/suppliers/{id}: Update an existing supplier.
- DELETE /api/suppliers/{id}: Delete a supplier.
- SEARCH /api/suppliers/search/{searchtext}: Search a supplier.
Represents a category to which products belong. It contains fields such as CategoryID, CategoryName, and Description.
Represents a product in the inventory. It contains fields such as ProductID, ProductName, CategoryID, SupplierID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, and Discontinued.
Represents additional details about a product, such as ProductDetailID, ProductID, Description, Specifications, WarrantyPeriod, and Manufacturer.
Represents the inventory details of a product, including InventoryID, ProductID, Quantity, WarehouseLocation, and LastUpdated.
Represents a supplier from whom products are sourced. It includes fields such as SupplierID, SupplierName, ContactName, Address, City, PostalCode, Country, Phone, and Email.
AutoMapper is used to map between domain models and DTOs. The mapping profiles are located in the Application/Mappings folder.
To add a new mapping, create a profile in the Mappings folder:
public class NewEntityProfile : Profile
{
public NewEntityProfile()
{
CreateMap<NewEntity, NewEntityDTO>().ReverseMap();
}
}MediatR pipeline behaviors are used for cross-cutting concerns like validation, logging, and performance monitoring. These behaviors are located in the Application/Behaviors folder.
It ensures that all incoming requests are validated according to the rules defined using FluentValidation.
Logs details about the requests and responses, which is helpful for debugging and monitoring.
Monitors the time taken to execute a request, logging warnings for slow operations.
Contributions are welcome! Please fork this repository, create a new branch, and submit a pull request. Ensure that your code adheres to the existing code style and includes appropriate tests.