# Supply Chain Tracking System
## Overview
This tutorial outlines the process of creating a blockchain-based supply chain tracking system using Ignite CLI. The system enables businesses to transparently track products from production to delivery.
## Key Components
1. **Product Registration:** Recording unique product identifiers.
2. **Tracking Movements:** Logging product movements or status changes.
3. **Verification and Audits:** Facilitating product history verification and audits.
4. **Stakeholder Participation:** Assigning roles and access levels to various stakeholders.
## Steps for Development
### Step 1: Initial Chain Setup
Initiate your blockchain project with Ignite CLI:
```bash
ignite scaffold chain supplychain && cd supplychain
```
### Step 2: Module Development
Create modules for product management and audit:
```bash
ignite scaffold module product
ignite scaffold module audit
```
### Step 3: Defining Data Structures
Define data structures for products and their movements.
We're scaffolding a list for the products and map the movements with their productID accordingly.
```bash
ignite scaffold list product name description origin --module product
ignite scaffold map movement productID location timestamp --module product
```
### Step 4: Working with the Product
**Registering a Product**
To register a product, you would use the `create-product` message you've defined in Step 4. Here's how you could present it:
```bash
supplychaind tx product create-product "Eco-friendly T-shirt" "100% organic cotton, size M" "Factory 1, Country ElSalvador" --from alice --chain-id supplychain
```
Show your product:
```bash
supplychaind query product show-product 0
```
First input is the `name`, second the `description`, and third `origin` correspond to the product's origin. `--from` specifies the blockchain address of the user performing the registration (likely a manufacturer `alice` in this context).
**Recording Product Movement**
To log a product's movement, the **`recordMovement`** message comes into play:
```bash
supplychaind tx product create-movement "0" "0" "Distribution Center 678, City DEF" "23/12/2023 3:00" --from bob --chain-id supplychain
```
```bash
supplychaind tx product create-movement "1" "0" "Distribution Center 123, City XYZ" "23/12/2023 8:00" --from bob --chain-id supplychain
```
Show the movement:
```bash
supplychaind query product show-movement 0
supplychaind query product show-movement 1
```
Clarify that `productID`, first input, is the unique identifier of the product being moved, as well as ID. `location` as third parameter specifies the new location of the product, and a timestamp recorded when the product arrived. `--from` is the address of the user (probably a transporter or distributor).
**Tracking Product Status**
List all existing products with:
```bash
supplychaind query product list-product
```
For tracking the current status or location of a product, a user would query the system using the productID:
```bash
supplychaind query product show-product 0
```
This command retrieves details of the product, including its current status or location. It's a straightforward way for any stakeholder to check on a product.
**Verifying Product Movement History**
To verify a product's movement history, stakeholders can use the following command:
```bash
supplychaind query product show-movement 0
```
This command provides a history of all recorded movements for the specified product, offering transparency and traceability for audits or verification processes.
### Conclusion
By following these steps, you'll create a robust supply chain tracking system, leveraging the power and versatility of Ignite CLI. This system will enhance transparency and efficiency in product tracking and verification.
Next steps are frontend development, testing, debugging, and deploying the network.