# cloakersan69-sys/engg1410_mp2_partsinventory architecture

> Architecture diagram of the GitHub repository cloakersan69-sys/engg1410_mp2_partsinventory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloakersan69-sys/engg1410_mp2_partsinventory
- Repository: https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory

## Overview

This is a command-line parts inventory tool. A user supplies an inventory file and a command; `main.c` validates arguments, loads the inventory, dispatches listing, searching, low-stock, value, or restock work, and frees the in-memory data. Restocking updates the matched part and saves the inventory file. The implementation is small: `inventory.c` provides both file persistence and inventory operations, with `inventory.h` defining their shared data structures and interface. The README gives no further capability details; the graph follows the sampled source.

Main entry points: [`main.c`](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/main.c) (Command Dispatcher), [`inventory.h`](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.h) (Inventory Data Model), [`inventory.c`](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c) (Inventory Listing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command Line"]
  node_cli["Command Dispatcher<br/>[main.c]"]
end

subgraph group_domain["Inventory Operations"]
  node_model["Inventory Data Model<br/>[inventory.h]"]
  node_listing["Inventory Listing<br/>[inventory.c]"]
  node_search["Part Search<br/>[inventory.c]"]
  node_lowstock["Low-Stock Report<br/>[inventory.c]"]
  node_valuation["Inventory Valuation<br/>[inventory.c]"]
  node_restock["Quantity Restock<br/>[inventory.c]"]
end

subgraph group_storage["File Persistence"]
  node_loader["Inventory Loader<br/>[inventory.c]"]
  node_saver["Inventory Saver<br/>[inventory.c]"]
  node_datafile[("Inventory File")]
end

node_user(("CLI User"))

node_user -->|"runs command"| node_cli
node_cli -->|"loads file"| node_loader
node_loader -->|"reads records"| node_datafile
node_cli -->|"lists parts"| node_listing
node_cli -->|"finds part"| node_search
node_cli -->|"reports low stock"| node_lowstock
node_cli -->|"calculates value"| node_valuation
node_cli -->|"updates quantity"| node_restock
node_cli -->|"saves inventory"| node_saver
node_saver -->|"writes records"| node_datafile
node_listing -->|"reads inventory"| node_model
node_search -->|"searches parts"| node_model
node_lowstock -->|"checks quantities"| node_model
node_valuation -->|"sums part values"| node_model
node_restock -->|"updates part"| node_model
node_loader -->|"populates inventory"| node_model
node_saver -->|"reads inventory"| node_model
node_listing -->|"prints each part"| node_listing
node_lowstock -->|"prints matching parts"| node_listing

click node_cli "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/main.c"
click node_model "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.h"
click node_listing "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_search "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_lowstock "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_valuation "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_restock "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_loader "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"
click node_saver "https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_user toneBlue
class node_model,node_listing,node_search,node_lowstock,node_valuation,node_restock toneAmber
class node_loader,node_saver,node_datafile toneMint
```

## Components

### Command Line

- [Command Dispatcher](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/main.c): `main.c`

### Inventory Operations

- [Inventory Data Model](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.h): `inventory.h`
- [Inventory Listing](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- [Part Search](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- [Low-Stock Report](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- [Inventory Valuation](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- [Quantity Restock](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`

### File Persistence

- [Inventory Loader](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- [Inventory Saver](https://github.com/cloakersan69-sys/engg1410_mp2_partsinventory/blob/main/inventory.c): `inventory.c`
- **Inventory File**

### Other components

- **CLI User**

## Connections

- CLI User → Command Dispatcher: runs command (evidence: `main.c`)
- Command Dispatcher → Inventory Loader: loads file (evidence: `main.c`)
- Inventory Loader → Inventory File: reads records (evidence: `inventory.c`)
- Command Dispatcher → Inventory Listing: lists parts (evidence: `main.c`)
- Command Dispatcher → Part Search: finds part (evidence: `main.c`)
- Command Dispatcher → Low-Stock Report: reports low stock (evidence: `main.c`)
- Command Dispatcher → Inventory Valuation: calculates value (evidence: `main.c`)
- Command Dispatcher → Quantity Restock: updates quantity (evidence: `main.c`)
- Command Dispatcher → Inventory Saver: saves inventory (evidence: `main.c`)
- Inventory Saver → Inventory File: writes records (evidence: `inventory.c`)
- Inventory Listing → Inventory Data Model: reads inventory (evidence: `inventory.c`)
- Part Search → Inventory Data Model: searches parts (evidence: `inventory.c`)
- Low-Stock Report → Inventory Data Model: checks quantities (evidence: `inventory.c`)
- Inventory Valuation → Inventory Data Model: sums part values (evidence: `inventory.c`)
- Quantity Restock → Inventory Data Model: updates part (evidence: `inventory.c`)
- Inventory Loader → Inventory Data Model: populates inventory (evidence: `inventory.c`)
- Inventory Saver → Inventory Data Model: reads inventory (evidence: `inventory.c`)
- Inventory Listing → Inventory Listing: prints each part (evidence: `inventory.c`)
- Low-Stock Report → Inventory Listing: prints matching parts (evidence: `inventory.c`)
