# Stock Management System (SMS) - StockHub Ltd

## 1. Entity Relationship Diagram (ERD) Text Representation
Because MongoDB is used, we model this with normalized references to ensure consistent data transactions while maintaining fast lookups.



### Entities & Cardinalities:
* **User**: Manages the system. (1 to Many with Products/Warehouses/Transactions conceptually, though isolated by system access).
* **Warehouse (1) <---> (M) StockTransaction**: A warehouse can host multiple transactions.
* **Product (1) <---> (M) StockTransaction**: A product can undergo multiple stock movements (Stock In / Stock Out).

 +------------------+               +----------------------+               +-------------------+
 |    WAREHOUSE     |               |  STOCK_TRANSACTION   |               |      PRODUCT      |
 +------------------+               +----------------------+               +-------------------+
 | PK | _id         |<---(1)   (M)-->| PK | _id             |<---(M)   (1)--->| PK | _id          |
 |    | wCode (UQ)  |               | FK | warehouseId     |               |    | pCode (UQ)   |
 |    | wName       |               | FK | productId       |               |    | pName        |
 |    | wLocation   |               |    | quantityMoved   |               |    | category     |
 +------------------+               |    | transactionType |               |    | quantityStock|
                                    |    | transactionDate |               |    | unitPrice    |
                                    +----------------------+               |    | supplierName |
                                                                           |    | dateReceived |
                                                                           +-------------------+
Markdown
### Key Relations & Constraints:
* `Product._id` maps to `StockTransaction.productId` (Foreign Key).
* `Warehouse._id` maps to `StockTransaction.warehouseId` (Foreign Key).
* `transactionType` is strictly restricted to an Enum: `['Stock In', 'Stock Out']`.
* When a `Stock In` transaction occurs, the system automatically increments `Product.quantityInStock`.
* When a `Stock Out` transaction occurs, the system automatically decrements `Product.quantityInStock`.

## 2. Project Directory Setup
Ensure your local folder structure is organized exactly like this:
Aisha_Koita_National_Practical_Exam_2026/
├── backend-project/
└── frontend-project/