# zahinaizat/stockmate architecture

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

- Interactive diagram: https://gitdiagram.com/zahinaizat/stockmate
- Repository: https://github.com/zahinaizat/stockmate

## Overview

StockMate is a PHP web app for tracking household inventory, reviewing low-stock and expiry alerts, and finding purchase options. Users register or sign in, manage stock, and view a dashboard; they can also revisit item history, update account details, or search shopping results. PHP pages own these workflows and use a shared PDO connection. Evidence is limited to the supplied excerpts and source index; relationships for unsampled pages are omitted unless a shown link or call establishes them.

Main entry points: [`htdocs/config.php`](https://github.com/zahinaizat/stockmate/blob/main/htdocs/config.php) (PDO Configuration), [`database/stockmate_DB_infinityfree_redeploy.sql`](https://github.com/zahinaizat/stockmate/blob/main/database/stockmate_DB_infinityfree_redeploy.sql) (MySQL Database), [`htdocs/login.php`](https://github.com/zahinaizat/stockmate/blob/main/htdocs/login.php) (Sign In), [`htdocs/items.php`](https://github.com/zahinaizat/stockmate/blob/main/htdocs/items.php) (Inventory List)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Account"]
  node_register["Registration<br/>[register.php]"]
  node_login["Sign In<br/>[login.php]"]
  node_account["Account Settings<br/>[account.php]"]
end

subgraph group_inventory["Stock Management"]
  node_items["Inventory List<br/>[items.php]"]
  node_edit["Edit Items<br/>[edit_items.php]"]
  node_quantity["Quantity Update"]
  node_history["Item History<br/>[item_history.php]"]
  node_prefill["Re-register Item"]
end

subgraph group_insights["Alerts and Dashboard"]
  node_dashboard["Dashboard<br/>[my_page.php]"]
  node_alerts["Alert API<br/>[alerts.php]"]
end

subgraph group_purchase["Purchase Assistance"]
  node_purchaseform["Purchase Search Form<br/>[form.php]"]
  node_results["Shopping Results<br/>[result.php]"]
end

subgraph group_runtime["Runtime and Data"]
  node_config["PDO Configuration<br/>[config.php]"]
  node_database[("MySQL Database")]
end

node_visitor(("User"))
node_rakuten{{"Rakuten API"}}
node_emailjs{{"EmailJS"}}

node_visitor -->|"registers"| node_register
node_visitor -->|"signs in"| node_login
node_visitor -->|"manages stock"| node_items
node_visitor -->|"views"| node_dashboard
node_visitor -->|"searches"| node_purchaseform
node_register -->|"creates user"| node_database
node_register -->|"redirects"| node_login
node_login -->|"checks credentials"| node_database
node_login -->|"redirects"| node_dashboard
node_login -->|"sends notice"| node_emailjs
node_account -->|"updates account"| node_database
node_items -->|"reads and writes"| node_database
node_items -->|"posts quantity"| node_quantity
node_items -.->|"links to edit"| node_edit
node_edit -->|"updates stock"| node_database
node_history -->|"reads history"| node_database
node_history -->|"opens re-register"| node_prefill
node_prefill -->|"submits item"| node_items
node_dashboard -->|"reads dashboard data"| node_database
node_dashboard -->|"fetches alerts"| node_alerts
node_alerts -->|"logs alerts"| node_database
node_purchaseform -->|"submits search"| node_results
node_results -->|"requests products"| node_rakuten
node_results -->|"returns to search"| node_purchaseform
node_register -->|"loads connection"| node_config
node_login -->|"loads connection"| node_config
node_account -->|"loads connection"| node_config
node_items -->|"loads connection"| node_config
node_edit -->|"loads connection"| node_config
node_history -->|"loads connection"| node_config
node_dashboard -->|"loads connection"| node_config
node_alerts -->|"loads connection"| node_config
node_purchaseform -->|"loads connection"| node_config
node_results -->|"loads connection"| node_config
node_prefill -->|"loads connection"| node_config
node_quantity -->|"loads connection"| node_config

click node_register "https://github.com/zahinaizat/stockmate/blob/main/htdocs/register.php"
click node_login "https://github.com/zahinaizat/stockmate/blob/main/htdocs/login.php"
click node_account "https://github.com/zahinaizat/stockmate/blob/main/htdocs/account.php"
click node_items "https://github.com/zahinaizat/stockmate/blob/main/htdocs/items.php"
click node_edit "https://github.com/zahinaizat/stockmate/blob/main/htdocs/edit_items.php"
click node_quantity "https://github.com/zahinaizat/stockmate/blob/main/htdocs/update_quantity.php"
click node_history "https://github.com/zahinaizat/stockmate/blob/main/htdocs/item_history.php"
click node_prefill "https://github.com/zahinaizat/stockmate/blob/main/htdocs/prefill_register.php"
click node_dashboard "https://github.com/zahinaizat/stockmate/blob/main/htdocs/my_page.php"
click node_alerts "https://github.com/zahinaizat/stockmate/blob/main/htdocs/alerts.php"
click node_purchaseform "https://github.com/zahinaizat/stockmate/blob/main/htdocs/form.php"
click node_results "https://github.com/zahinaizat/stockmate/blob/main/htdocs/result.php"
click node_config "https://github.com/zahinaizat/stockmate/blob/main/htdocs/config.php"
click node_database "https://github.com/zahinaizat/stockmate/blob/main/database/stockmate_DB_infinityfree_redeploy.sql"

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_register,node_login,node_account,node_visitor toneBlue
class node_items,node_edit,node_quantity,node_history,node_prefill toneAmber
class node_dashboard,node_alerts,node_rakuten toneMint
class node_purchaseform,node_results toneRose
class node_config,node_database,node_emailjs toneIndigo
```

## Components

### Identity and Account

- [Registration](https://github.com/zahinaizat/stockmate/blob/main/htdocs/register.php): `htdocs/register.php`
- [Sign In](https://github.com/zahinaizat/stockmate/blob/main/htdocs/login.php): `htdocs/login.php`
- [Account Settings](https://github.com/zahinaizat/stockmate/blob/main/htdocs/account.php): `htdocs/account.php`

### Stock Management

- [Inventory List](https://github.com/zahinaizat/stockmate/blob/main/htdocs/items.php): `htdocs/items.php`
- [Edit Items](https://github.com/zahinaizat/stockmate/blob/main/htdocs/edit_items.php): `htdocs/edit_items.php`
- [Quantity Update](https://github.com/zahinaizat/stockmate/blob/main/htdocs/update_quantity.php): `htdocs/update_quantity.php`
- [Item History](https://github.com/zahinaizat/stockmate/blob/main/htdocs/item_history.php): `htdocs/item_history.php`
- [Re-register Item](https://github.com/zahinaizat/stockmate/blob/main/htdocs/prefill_register.php): `htdocs/prefill_register.php`

### Alerts and Dashboard

- [Dashboard](https://github.com/zahinaizat/stockmate/blob/main/htdocs/my_page.php): `htdocs/my_page.php`
- [Alert API](https://github.com/zahinaizat/stockmate/blob/main/htdocs/alerts.php): `htdocs/alerts.php`

### Purchase Assistance

- [Purchase Search Form](https://github.com/zahinaizat/stockmate/blob/main/htdocs/form.php): `htdocs/form.php`
- [Shopping Results](https://github.com/zahinaizat/stockmate/blob/main/htdocs/result.php): `htdocs/result.php`

### Runtime and Data

- [PDO Configuration](https://github.com/zahinaizat/stockmate/blob/main/htdocs/config.php): `htdocs/config.php`
- [MySQL Database](https://github.com/zahinaizat/stockmate/blob/main/database/stockmate_DB_infinityfree_redeploy.sql): `database/stockmate_DB_infinityfree_redeploy.sql`

### Other components

- **User**
- **Rakuten API**
- **EmailJS**

## Connections

- User → Registration: registers (evidence: `htdocs/register.php`)
- User → Sign In: signs in (evidence: `htdocs/login.php`)
- User → Inventory List: manages stock (evidence: `htdocs/items.php`)
- User → Dashboard: views (evidence: `htdocs/my_page.php`)
- User → Purchase Search Form: searches (evidence: `htdocs/form.php`)
- Registration → MySQL Database: creates user (evidence: `htdocs/register.php`)
- Registration → Sign In: redirects (evidence: `htdocs/register.php`)
- Sign In → MySQL Database: checks credentials (evidence: `htdocs/login.php`)
- Sign In → Dashboard: redirects (evidence: `htdocs/login.php`)
- Sign In → EmailJS: sends notice (evidence: `htdocs/login.php`)
- Account Settings → MySQL Database: updates account (evidence: `htdocs/account.php`)
- Inventory List → MySQL Database: reads and writes (evidence: `htdocs/items.php`)
- Inventory List → Quantity Update: posts quantity (evidence: `htdocs/items.php`)
- Inventory List → Edit Items: links to edit
- Edit Items → MySQL Database: updates stock (evidence: `htdocs/edit_items.php`)
- Item History → MySQL Database: reads history (evidence: `htdocs/item_history.php`)
- Item History → Re-register Item: opens re-register (evidence: `htdocs/item_history.php`)
- Re-register Item → Inventory List: submits item (evidence: `htdocs/prefill_register.php`)
- Dashboard → MySQL Database: reads dashboard data (evidence: `htdocs/my_page.php`)
- Dashboard → Alert API: fetches alerts (evidence: `htdocs/my_page.php`)
- Alert API → MySQL Database: logs alerts (evidence: `htdocs/alerts.php`)
- Purchase Search Form → Shopping Results: submits search (evidence: `htdocs/form.php`)
- Shopping Results → Rakuten API: requests products (evidence: `htdocs/result.php`)
- Shopping Results → Purchase Search Form: returns to search (evidence: `htdocs/result.php`)
- Registration → PDO Configuration: loads connection (evidence: `htdocs/register.php`)
- Sign In → PDO Configuration: loads connection (evidence: `htdocs/login.php`)
- Account Settings → PDO Configuration: loads connection (evidence: `htdocs/account.php`)
- Inventory List → PDO Configuration: loads connection (evidence: `htdocs/items.php`)
- Edit Items → PDO Configuration: loads connection (evidence: `htdocs/edit_items.php`)
- Item History → PDO Configuration: loads connection (evidence: `htdocs/item_history.php`)
- Dashboard → PDO Configuration: loads connection (evidence: `htdocs/my_page.php`)
- Alert API → PDO Configuration: loads connection (evidence: `htdocs/alerts.php`)
- Purchase Search Form → PDO Configuration: loads connection (evidence: `htdocs/form.php`)
- Shopping Results → PDO Configuration: loads connection (evidence: `htdocs/result.php`)
- Re-register Item → PDO Configuration: loads connection (evidence: `htdocs/prefill_register.php`)
- Quantity Update → PDO Configuration: loads connection (evidence: `htdocs/update_quantity.php`)
