# dec-olgen/oop architecture

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

- Interactive diagram: https://gitdiagram.com/dec-olgen/oop
- Repository: https://github.com/dec-olgen/oop

## Overview

Ward Stock is a PHP web application for managing ward inventory and staff/admin accounts. The main workflow is: a user logs in, reaches the shared home or inventory view, and authorized staff create or edit stock records; the home and dashboard surface low-stock and expiry warnings. Admins also manage accounts and inspect activity and audit logs. The sampled pages show direct MySQL access, role checks, and transactional audit writes. Other routes are represented from the file tree; their detailed behavior and wiring were not sampled.

Main entry points: [`includes/auth.php`](https://github.com/dec-olgen/oop/blob/main/includes/auth.php) (Session and Roles), [`sql/database.sql`](https://github.com/dec-olgen/oop/blob/main/sql/database.sql) (Ward Stock Database), [`shared/admin_and_staff_home.php`](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_home.php) (Home Summary), [`shared/admin_and_staff_dashboard.php`](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_dashboard.php) (Inventory Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Navigation"]
  node_login["Login<br/>[login.php]"]
  node_auth["Session and Roles<br/>[auth.php]"]
  node_sidebar["Role Navigation"]
  node_logout["Logout<br/>[logout.php]"]
end

subgraph group_stock["Inventory Operations"]
  node_home["Home Summary"]
  node_dashboard["Inventory Dashboard"]
  node_create_item["Create Item"]
  node_edit_item["Edit Item"]
  node_adjust_stock["Adjust Stock<br/>[adjust_stock.php]"]
  node_delete_item["Delete Item"]
  node_delete_confirm["Confirm Item Delete"]
end

subgraph group_oversight["Admin and Reporting"]
  node_account_register["Create Account<br/>[admin_register.php]"]
  node_accounts["Manage Accounts<br/>[admin_accounts.php]"]
  node_account_actions["Account Actions"]
  node_account_activity["Account Activity"]
  node_audit["Inventory Audit"]
  node_login_log["Login Log"]
end

subgraph group_persistence["Persistence"]
  node_database[("Ward Stock Database<br/>[database.sql]")]
  node_config["DB Connection and Thresholds<br/>[config.php]"]
end

node_user(("Admin or Staff"))

node_user -->|"submits credentials"| node_login
node_login -->|"connects to"| node_config
node_login -->|"checks accounts; logs login"| node_database
node_login -->|"redirects on success"| node_home
node_home -->|"checks role"| node_auth
node_dashboard -->|"checks role"| node_auth
node_create_item -->|"checks role"| node_auth
node_edit_item -->|"checks role"| node_auth
node_home -->|"loads connection and thresholds"| node_config
node_dashboard -->|"loads connection and thresholds"| node_config
node_create_item -->|"loads connection"| node_config
node_edit_item -->|"loads connection"| node_config
node_home -->|"reads inventory and activity"| node_database
node_dashboard -->|"reads inventory"| node_database
node_create_item -->|"writes item and audit record"| node_database
node_edit_item -->|"updates item and audit record"| node_database
node_account_register -->|"checks admin role"| node_auth
node_account_register -->|"writes account and activity"| node_database
node_accounts -->|"checks admin role"| node_auth
node_accounts -->|"reads accounts"| node_database
node_account_activity -->|"checks admin role"| node_auth
node_account_activity -->|"reads activity"| node_database
node_audit -->|"checks admin role"| node_auth
node_audit -->|"reads item actions"| node_database
node_login_log -->|"requires login"| node_auth
node_logout -->|"ends session"| node_auth
node_home -->|"includes navigation"| node_sidebar
node_dashboard -->|"includes navigation"| node_sidebar
node_user -->|"opens"| node_home
node_user -->|"opens"| node_dashboard
node_user -->|"requests logout"| node_logout

click node_login "https://github.com/dec-olgen/oop/blob/main/login.php"
click node_auth "https://github.com/dec-olgen/oop/blob/main/includes/auth.php"
click node_home "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_home.php"
click node_dashboard "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_dashboard.php"
click node_create_item "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_create.php"
click node_edit_item "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_edit.php"
click node_adjust_stock "https://github.com/dec-olgen/oop/blob/main/shared/adjust_stock.php"
click node_delete_item "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_delete.php"
click node_delete_confirm "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_delete_confirm.php"
click node_sidebar "https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_sidebar.php"
click node_account_register "https://github.com/dec-olgen/oop/blob/main/admin_only/admin_register.php"
click node_accounts "https://github.com/dec-olgen/oop/blob/main/admin_only/admin_accounts.php"
click node_account_actions "https://github.com/dec-olgen/oop/tree/main/admin_only"
click node_account_activity "https://github.com/dec-olgen/oop/blob/main/admin_only/admin_activity_log.php"
click node_audit "https://github.com/dec-olgen/oop/blob/main/admin_only/admin_audit_log.php"
click node_login_log "https://github.com/dec-olgen/oop/blob/main/admin_only/admin_login_log.php"
click node_database "https://github.com/dec-olgen/oop/blob/main/sql/database.sql"
click node_config "https://github.com/dec-olgen/oop/blob/main/includes/config.php"
click node_logout "https://github.com/dec-olgen/oop/blob/main/logout.php"

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_login,node_auth,node_sidebar,node_logout toneBlue
class node_home,node_dashboard,node_create_item,node_edit_item,node_adjust_stock,node_delete_item,node_delete_confirm toneAmber
class node_account_register,node_accounts,node_account_actions,node_account_activity,node_audit,node_login_log toneMint
class node_database,node_config toneRose
class node_user toneIndigo
```

## Components

### Access and Navigation

- [Login](https://github.com/dec-olgen/oop/blob/main/login.php): `login.php`
- [Session and Roles](https://github.com/dec-olgen/oop/blob/main/includes/auth.php): `includes/auth.php`
- [Role Navigation](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_sidebar.php): `shared/admin_and_staff_sidebar.php`
- [Logout](https://github.com/dec-olgen/oop/blob/main/logout.php): `logout.php`

### Inventory Operations

- [Home Summary](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_home.php): `shared/admin_and_staff_home.php`
- [Inventory Dashboard](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_dashboard.php): `shared/admin_and_staff_dashboard.php`
- [Create Item](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_create.php): `shared/admin_and_staff_create.php`
- [Edit Item](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_edit.php): `shared/admin_and_staff_edit.php`
- [Adjust Stock](https://github.com/dec-olgen/oop/blob/main/shared/adjust_stock.php): `shared/adjust_stock.php`
- [Delete Item](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_delete.php): `shared/admin_and_staff_delete.php`
- [Confirm Item Delete](https://github.com/dec-olgen/oop/blob/main/shared/admin_and_staff_delete_confirm.php): `shared/admin_and_staff_delete_confirm.php`

### Admin and Reporting

- [Create Account](https://github.com/dec-olgen/oop/blob/main/admin_only/admin_register.php): `admin_only/admin_register.php`
- [Manage Accounts](https://github.com/dec-olgen/oop/blob/main/admin_only/admin_accounts.php): `admin_only/admin_accounts.php`
- [Account Actions](https://github.com/dec-olgen/oop/tree/main/admin_only): `admin_only`
- [Account Activity](https://github.com/dec-olgen/oop/blob/main/admin_only/admin_activity_log.php): `admin_only/admin_activity_log.php`
- [Inventory Audit](https://github.com/dec-olgen/oop/blob/main/admin_only/admin_audit_log.php): `admin_only/admin_audit_log.php`
- [Login Log](https://github.com/dec-olgen/oop/blob/main/admin_only/admin_login_log.php): `admin_only/admin_login_log.php`

### Persistence

- [Ward Stock Database](https://github.com/dec-olgen/oop/blob/main/sql/database.sql): `sql/database.sql`
- [DB Connection and Thresholds](https://github.com/dec-olgen/oop/blob/main/includes/config.php): `includes/config.php`

### Other components

- **Admin or Staff**

## Connections

- Admin or Staff → Login: submits credentials
- Login → DB Connection and Thresholds: connects to
- Login → Ward Stock Database: checks accounts; logs login
- Login → Home Summary: redirects on success
- Home Summary → Session and Roles: checks role
- Inventory Dashboard → Session and Roles: checks role
- Create Item → Session and Roles: checks role
- Edit Item → Session and Roles: checks role
- Home Summary → DB Connection and Thresholds: loads connection and thresholds
- Inventory Dashboard → DB Connection and Thresholds: loads connection and thresholds
- Create Item → DB Connection and Thresholds: loads connection
- Edit Item → DB Connection and Thresholds: loads connection
- Home Summary → Ward Stock Database: reads inventory and activity
- Inventory Dashboard → Ward Stock Database: reads inventory
- Create Item → Ward Stock Database: writes item and audit record
- Edit Item → Ward Stock Database: updates item and audit record
- Create Account → Session and Roles: checks admin role
- Create Account → Ward Stock Database: writes account and activity
- Manage Accounts → Session and Roles: checks admin role
- Manage Accounts → Ward Stock Database: reads accounts
- Account Activity → Session and Roles: checks admin role
- Account Activity → Ward Stock Database: reads activity
- Inventory Audit → Session and Roles: checks admin role
- Inventory Audit → Ward Stock Database: reads item actions
- Login Log → Session and Roles: requires login
- Logout → Session and Roles: ends session
- Home Summary → Role Navigation: includes navigation
- Inventory Dashboard → Role Navigation: includes navigation
- Admin or Staff → Home Summary: opens
- Admin or Staff → Inventory Dashboard: opens
- Admin or Staff → Logout: requests logout
