# ivanparada/product-registration-system architecture

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

- Interactive diagram: https://gitdiagram.com/ivanparada/product-registration-system
- Repository: https://github.com/ivanparada/product-registration-system

## Overview

This is a PHP/PostgreSQL product-registration application. A user fills a product form; browser-side validation gates submission, while lookup requests populate warehouse, branch, currency, and material choices. The save endpoint validates the submitted product, checks branch and code constraints, and transactionally stores the product and material links. The graph includes the form-rendering components and lookup capabilities; several lookup endpoint implementations are not excerpted, so their database connections are supported only by the SOURCE INDEX references.

Main entry points: [`php/config/database.php`](https://github.com/ivanparada/product-registration-system/blob/main/php/config/database.php) (PDO connection), [`js/api.js`](https://github.com/ivanparada/product-registration-system/blob/main/js/api.js) (HTTP API client), [`js/app.js`](https://github.com/ivanparada/product-registration-system/blob/main/js/app.js) (Form orchestration), [`index.php`](https://github.com/ivanparada/product-registration-system/blob/main/index.php) (Registration form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Product form"]
  node_form["Registration form<br/>[index.php]"]
  node_form_controls["Form controls"]
end

subgraph group_browser["Browser workflow"]
  node_app["Form orchestration<br/>[app.js]"]
  node_validation["Field validation<br/>[validation.js]"]
  node_api["HTTP API client<br/>[api.js]"]
end

subgraph group_backend["PHP services"]
  node_warehouse_lookup["Warehouse lookup<br/>[get_warehouses.php]"]
  node_branch_lookup["Branch lookup<br/>[get_branches.php]"]
  node_currency_lookup["Currency lookup<br/>[get_currencies.php]"]
  node_material_lookup["Material lookup<br/>[get_materials.php]"]
  node_code_check["Product code check"]
  node_save_product["Product persistence<br/>[save_product.php]"]
end

subgraph group_storage["Persistence"]
  node_db_config["PDO connection<br/>[database.php]"]
  node_schema["Database schema<br/>[database.sql]"]
end

node_user(("Product user"))
node_postgres[("PostgreSQL")]

node_user -->|"enters product"| node_form
node_form -->|"renders controls"| node_form_controls
node_form -->|"loads script"| node_app
node_form_controls -->|"provides form fields"| node_app
node_app -->|"validates fields"| node_validation
node_app -->|"requests data and saves"| node_api
node_api -->|"fetches"| node_warehouse_lookup
node_api -->|"fetches"| node_branch_lookup
node_api -->|"fetches"| node_currency_lookup
node_api -->|"fetches"| node_material_lookup
node_api -->|"posts product"| node_save_product
node_warehouse_lookup -.->|"uses connection"| node_db_config
node_branch_lookup -->|"queries branches"| node_db_config
node_currency_lookup -.->|"uses connection"| node_db_config
node_material_lookup -.->|"uses connection"| node_db_config
node_code_check -->|"uses connection"| node_db_config
node_save_product -->|"uses connection"| node_db_config
node_db_config -->|"connects"| node_postgres
node_save_product -->|"writes product and materials"| node_postgres
node_schema -->|"initializes schema"| node_postgres

click node_form "https://github.com/ivanparada/product-registration-system/blob/main/index.php"
click node_form_controls "https://github.com/ivanparada/product-registration-system/tree/main/components"
click node_app "https://github.com/ivanparada/product-registration-system/blob/main/js/app.js"
click node_validation "https://github.com/ivanparada/product-registration-system/blob/main/js/validation.js"
click node_api "https://github.com/ivanparada/product-registration-system/blob/main/js/api.js"
click node_warehouse_lookup "https://github.com/ivanparada/product-registration-system/blob/main/php/get_warehouses.php"
click node_branch_lookup "https://github.com/ivanparada/product-registration-system/blob/main/php/get_branches.php"
click node_currency_lookup "https://github.com/ivanparada/product-registration-system/blob/main/php/get_currencies.php"
click node_material_lookup "https://github.com/ivanparada/product-registration-system/blob/main/php/get_materials.php"
click node_code_check "https://github.com/ivanparada/product-registration-system/blob/main/php/check_product_code.php"
click node_save_product "https://github.com/ivanparada/product-registration-system/blob/main/php/save_product.php"
click node_db_config "https://github.com/ivanparada/product-registration-system/blob/main/php/config/database.php"
click node_schema "https://github.com/ivanparada/product-registration-system/blob/main/SQL/database.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_form,node_form_controls,node_user toneBlue
class node_app,node_validation,node_api,node_postgres toneAmber
class node_warehouse_lookup,node_branch_lookup,node_currency_lookup,node_material_lookup,node_code_check,node_save_product toneMint
class node_db_config,node_schema toneRose
```

## Components

### Product form

- [Registration form](https://github.com/ivanparada/product-registration-system/blob/main/index.php): `index.php`
- [Form controls](https://github.com/ivanparada/product-registration-system/tree/main/components): `components`

### Browser workflow

- [Form orchestration](https://github.com/ivanparada/product-registration-system/blob/main/js/app.js): `js/app.js`
- [Field validation](https://github.com/ivanparada/product-registration-system/blob/main/js/validation.js): `js/validation.js`
- [HTTP API client](https://github.com/ivanparada/product-registration-system/blob/main/js/api.js): `js/api.js`

### PHP services

- [Warehouse lookup](https://github.com/ivanparada/product-registration-system/blob/main/php/get_warehouses.php): `php/get_warehouses.php`
- [Branch lookup](https://github.com/ivanparada/product-registration-system/blob/main/php/get_branches.php): `php/get_branches.php`
- [Currency lookup](https://github.com/ivanparada/product-registration-system/blob/main/php/get_currencies.php): `php/get_currencies.php`
- [Material lookup](https://github.com/ivanparada/product-registration-system/blob/main/php/get_materials.php): `php/get_materials.php`
- [Product code check](https://github.com/ivanparada/product-registration-system/blob/main/php/check_product_code.php): `php/check_product_code.php`
- [Product persistence](https://github.com/ivanparada/product-registration-system/blob/main/php/save_product.php): `php/save_product.php`

### Persistence

- [PDO connection](https://github.com/ivanparada/product-registration-system/blob/main/php/config/database.php): `php/config/database.php`
- [Database schema](https://github.com/ivanparada/product-registration-system/blob/main/SQL/database.sql): `SQL/database.sql`

### Other components

- **Product user**
- **PostgreSQL**

## Connections

- Product user → Registration form: enters product (evidence: `README.md`)
- Registration form → Form controls: renders controls (evidence: `index.php`)
- Registration form → Form orchestration: loads script (evidence: `index.php`)
- Form controls → Form orchestration: provides form fields (evidence: `js/app.js`)
- Form orchestration → Field validation: validates fields (evidence: `js/app.js`)
- Form orchestration → HTTP API client: requests data and saves (evidence: `js/app.js`)
- HTTP API client → Warehouse lookup: fetches (evidence: `js/api.js`)
- HTTP API client → Branch lookup: fetches (evidence: `js/api.js`)
- HTTP API client → Currency lookup: fetches (evidence: `js/api.js`)
- HTTP API client → Material lookup: fetches (evidence: `js/api.js`)
- HTTP API client → Product persistence: posts product (evidence: `js/api.js`)
- Warehouse lookup → PDO connection: uses connection (evidence: `php/get_warehouses.php`)
- Branch lookup → PDO connection: queries branches (evidence: `php/get_branches.php`)
- Currency lookup → PDO connection: uses connection (evidence: `php/get_currencies.php`)
- Material lookup → PDO connection: uses connection (evidence: `php/get_materials.php`)
- Product code check → PDO connection: uses connection (evidence: `php/check_product_code.php`)
- Product persistence → PDO connection: uses connection (evidence: `php/save_product.php`)
- PDO connection → PostgreSQL: connects (evidence: `php/config/database.php`)
- Product persistence → PostgreSQL: writes product and materials (evidence: `php/save_product.php`)
- Database schema → PostgreSQL: initializes schema (evidence: `README.md`)
