# allenmoronivillegas-glitch/ebhealth architecture

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

- Interactive diagram: https://gitdiagram.com/allenmoronivillegas-glitch/ebhealth
- Repository: https://github.com/allenmoronivillegas-glitch/ebhealth

## Overview

eBHealth is a browser-based barangay health-center records and medicine-inventory system. Staff use its web interface to sign in, manage patient and clinical records, track medicine stock, and review or export activity summaries; PHP API actions enforce session and role checks and access shared Supabase PostgreSQL storage. The API is a large monolith, so domain nodes share its implementation path rather than implying separate services. The JavaScript is linked by the page, but its API calls were not excerpted; that connection is shown as unverified.

Main entry points: [`api/index.php`](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php) (API actions), [`config/database.php`](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/config/database.php) (PDO connection), [`eBHealth.php`](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/eBHealth.php) (Staff workspace), [`assets/app.js`](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/assets/app.js) (Interactive client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webui["Staff workspace<br/>[eBHealth.php]"]
  node_browserlogic["Interactive client<br/>[app.js]"]
end

subgraph group_api["Application API"]
  node_api_entry["API actions<br/>[index.php]"]
  node_identity["Sign-in and staff<br/>[index.php]"]
  node_patients["Patient records<br/>[index.php]"]
  node_consults["Consultations<br/>[index.php]"]
  node_healthrecords["Health records<br/>[index.php]"]
  node_inventory["Medicine inventory<br/>[index.php]"]
  node_reporting["Reports and exports<br/>[index.php]"]
  node_staffadmin["Staff administration<br/>[index.php]"]
end

subgraph group_data["Persistence"]
  node_dbconfig["PDO connection<br/>[database.php]"]
  node_schema["Relational schema<br/>[schema.sql]"]
  node_securitysql["Database security"]
  node_postgres[("Supabase PostgreSQL")]
end

subgraph group_ops["Health and audit"]
  node_audit["Audit events<br/>[index.php]"]
  node_healthcheck["Connection check<br/>[health.php]"]
end

node_staff(("Health staff"))

node_staff -->|"uses"| node_webui
node_webui -->|"loads"| node_browserlogic
node_browserlogic -.->|"requests"| node_api_entry
node_api_entry -->|"dispatches"| node_identity
node_api_entry -->|"dispatches"| node_patients
node_api_entry -->|"dispatches"| node_consults
node_api_entry -->|"dispatches"| node_healthrecords
node_api_entry -->|"dispatches"| node_inventory
node_api_entry -->|"dispatches"| node_reporting
node_api_entry -->|"dispatches"| node_staffadmin
node_api_entry -->|"records"| node_audit
node_api_entry -->|"connects via"| node_dbconfig
node_healthcheck -->|"connects via"| node_dbconfig
node_dbconfig -->|"opens PDO"| node_postgres
node_schema -.->|"defines tables"| node_postgres
node_securitysql -.->|"documents policies"| node_postgres

click node_webui "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/eBHealth.php"
click node_browserlogic "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/assets/app.js"
click node_api_entry "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_identity "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_patients "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_consults "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_healthrecords "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_inventory "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_reporting "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_staffadmin "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_audit "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php"
click node_dbconfig "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/config/database.php"
click node_schema "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/database/schema.sql"
click node_securitysql "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/database/application_security.sql"
click node_healthcheck "https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/health.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_webui,node_browserlogic toneBlue
class node_api_entry,node_identity,node_patients,node_consults,node_healthrecords,node_inventory,node_reporting,node_staffadmin toneAmber
class node_dbconfig,node_schema,node_securitysql,node_postgres toneMint
class node_audit,node_healthcheck toneRose
class node_staff toneIndigo
```

## Components

### Web interface

- [Staff workspace](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/eBHealth.php): `eBHealth.php`
- [Interactive client](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/assets/app.js): `assets/app.js`

### Application API

- [API actions](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Sign-in and staff](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Patient records](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Consultations](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Health records](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Medicine inventory](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Reports and exports](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Staff administration](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`

### Persistence

- [PDO connection](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/config/database.php): `config/database.php`
- [Relational schema](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/database/schema.sql): `database/schema.sql`
- [Database security](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/database/application_security.sql): `database/application_security.sql`
- **Supabase PostgreSQL**

### Health and audit

- [Audit events](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/index.php): `api/index.php`
- [Connection check](https://github.com/allenmoronivillegas-glitch/ebhealth/blob/main/api/health.php): `api/health.php`

### Other components

- **Health staff**

## Connections

- Health staff → Staff workspace: uses (evidence: `README.md`)
- Staff workspace → Interactive client: loads (evidence: `eBHealth.php`)
- Interactive client → API actions: requests
- API actions → Sign-in and staff: dispatches (evidence: `api/index.php`)
- API actions → Patient records: dispatches (evidence: `api/index.php`)
- API actions → Consultations: dispatches (evidence: `api/index.php`)
- API actions → Health records: dispatches (evidence: `api/index.php`)
- API actions → Medicine inventory: dispatches (evidence: `api/index.php`)
- API actions → Reports and exports: dispatches (evidence: `api/index.php`)
- API actions → Staff administration: dispatches (evidence: `api/index.php`)
- API actions → Audit events: records (evidence: `api/index.php`)
- API actions → PDO connection: connects via (evidence: `api/index.php`)
- Connection check → PDO connection: connects via (evidence: `api/health.php`)
- PDO connection → Supabase PostgreSQL: opens PDO (evidence: `config/database.php`)
- Relational schema → Supabase PostgreSQL: defines tables
- Database security → Supabase PostgreSQL: documents policies
