# hidingdust/pulse-design architecture

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

- Interactive diagram: https://gitdiagram.com/hidingdust/pulse-design
- Repository: https://github.com/hidingdust/pulse-design

## Overview

PULSE is a server-backed digital-life experience: a PHP worker samples host and visitor signals, updates persistent state, and the browser renders the resulting lifeform and history while visitors interact with it. The main request path runs from the browser API client through the PHP entry point and controller into domain services and repositories. The README also documents a production static-front-end/Edge Function deployment and demo scenarios. Source excerpts establish the main calls; some infrastructure and frontend-to-API links are documented rather than shown in excerpts.

Main entry points: [`pulse/src/Service/PulseService.php`](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/PulseService.php) (Pulse operations), [`pulse/frontend/src/main.js`](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/main.js) (Application entry), [`pulse/src/Service/MetricService.php`](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/MetricService.php) (Metric collection), [`pulse/src/Support/Database.php`](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Support/Database.php) (MySQL access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Browser experience"]
  node_frontend["Application entry<br/>[main.js]"]
  node_api_client["API client<br/>[api.js]"]
  node_scene["3D lifeform<br/>[PulseScene.js]"]
  node_hud["Status HUD<br/>[Hud.js]"]
  node_timeline["Timeline view<br/>[Timeline.js]"]
  node_report["Report drawer<br/>[ReportDrawer.js]"]
  node_demo_panel["Demo controls<br/>[DemoPanel.js]"]
  node_edge_proxy["Edge API proxy<br/>[&#91;&#91;default&#93;&#93;.js]"]
end

subgraph group_api["API and domain"]
  node_api_entry["PHP API entry<br/>[index.php]"]
  node_controller["Route controller<br/>[ApiController.php]"]
  node_pulse_service["Pulse operations<br/>[PulseService.php]"]
  node_rules["Pulse rules<br/>[PulseRules.php]"]
  node_demo_service["Demo scenarios<br/>[DemoService.php]"]
end

subgraph group_collection["Metrics and heartbeat"]
  node_worker["Heartbeat worker<br/>[pulse-worker.php]"]
  node_metric_service["Metric collection<br/>[MetricService.php]"]
end

subgraph group_persistence["Persistence"]
  node_pulse_repo["Pulse repository"]
  node_metric_repo["Metric repository"]
  node_visitor_repo["Visitor repository"]
  node_event_repo["Event repository"]
  node_database["MySQL access<br/>[Database.php]"]
end

node_visitor(("Visitor"))
node_php_origin["PHP API origin"]
node_mysql[("MySQL database")]

node_visitor -->|"uses"| node_frontend
node_frontend -->|"calls"| node_api_client
node_frontend -->|"updates"| node_scene
node_frontend -->|"updates"| node_hud
node_frontend -->|"renders"| node_report
node_frontend -->|"registers"| node_demo_panel
node_hud -->|"renders"| node_timeline
node_api_client -.->|"routes via"| node_edge_proxy
node_edge_proxy -->|"forwards API"| node_php_origin
node_api_client -->|"requests API"| node_api_entry
node_api_entry -->|"dispatches"| node_controller
node_controller -->|"routes operations"| node_pulse_service
node_controller -->|"checks demo config"| node_demo_service
node_pulse_service -->|"applies rules"| node_rules
node_pulse_service -->|"reads and updates"| node_pulse_repo
node_pulse_service -->|"reads metrics"| node_metric_repo
node_pulse_service -->|"records visits"| node_visitor_repo
node_pulse_service -->|"records events"| node_event_repo
node_pulse_service -->|"manages scenarios"| node_demo_service
node_worker -->|"collects metrics"| node_metric_service
node_worker -->|"computes state"| node_rules
node_worker -->|"updates heartbeat"| node_pulse_repo
node_worker -->|"logs changes"| node_event_repo
node_metric_service -->|"persists samples"| node_metric_repo
node_metric_service -->|"reads visitors"| node_visitor_repo
node_metric_service -->|"reads pulse state"| node_pulse_repo
node_metric_service -->|"applies overrides"| node_demo_service
node_pulse_repo -->|"uses connection"| node_database
node_metric_repo -->|"uses connection"| node_database
node_visitor_repo -->|"uses connection"| node_database
node_event_repo -->|"uses connection"| node_database
node_database -->|"connects to"| node_mysql

click node_frontend "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/main.js"
click node_api_client "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/api.js"
click node_scene "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/three/PulseScene.js"
click node_hud "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/Hud.js"
click node_timeline "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/Timeline.js"
click node_report "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/ReportDrawer.js"
click node_demo_panel "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/DemoPanel.js"
click node_edge_proxy "https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/edge-functions/api/%5B%5Bdefault%5D%5D.js"
click node_api_entry "https://github.com/hidingdust/pulse-design/blob/master/pulse/public/index.php"
click node_controller "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Controller/ApiController.php"
click node_pulse_service "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/PulseService.php"
click node_rules "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Domain/PulseRules.php"
click node_demo_service "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/DemoService.php"
click node_worker "https://github.com/hidingdust/pulse-design/blob/master/pulse/worker/pulse-worker.php"
click node_metric_service "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/MetricService.php"
click node_pulse_repo "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/PulseRepository.php"
click node_metric_repo "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/MetricRepository.php"
click node_visitor_repo "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/VisitorRepository.php"
click node_event_repo "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/EventRepository.php"
click node_database "https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Support/Database.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_frontend,node_api_client,node_scene,node_hud,node_timeline,node_report,node_demo_panel,node_edge_proxy toneBlue
class node_api_entry,node_controller,node_pulse_service,node_rules,node_demo_service,node_mysql toneAmber
class node_worker,node_metric_service,node_php_origin toneMint
class node_pulse_repo,node_metric_repo,node_visitor_repo,node_event_repo,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Browser experience

- [Application entry](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/main.js): `pulse/frontend/src/main.js`
- [API client](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/api.js): `pulse/frontend/src/api.js`
- [3D lifeform](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/three/PulseScene.js): `pulse/frontend/src/three/PulseScene.js`
- [Status HUD](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/Hud.js): `pulse/frontend/src/components/Hud.js`
- [Timeline view](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/Timeline.js): `pulse/frontend/src/components/Timeline.js`
- [Report drawer](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/ReportDrawer.js): `pulse/frontend/src/components/ReportDrawer.js`
- [Demo controls](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/src/components/DemoPanel.js): `pulse/frontend/src/components/DemoPanel.js`
- [Edge API proxy](https://github.com/hidingdust/pulse-design/blob/master/pulse/frontend/edge-functions/api/%5B%5Bdefault%5D%5D.js): `pulse/frontend/edge-functions/api/[[default]].js`

### API and domain

- [PHP API entry](https://github.com/hidingdust/pulse-design/blob/master/pulse/public/index.php): `pulse/public/index.php`
- [Route controller](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Controller/ApiController.php): `pulse/src/Controller/ApiController.php`
- [Pulse operations](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/PulseService.php): `pulse/src/Service/PulseService.php`
- [Pulse rules](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Domain/PulseRules.php): `pulse/src/Domain/PulseRules.php`
- [Demo scenarios](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/DemoService.php): `pulse/src/Service/DemoService.php`

### Metrics and heartbeat

- [Heartbeat worker](https://github.com/hidingdust/pulse-design/blob/master/pulse/worker/pulse-worker.php): `pulse/worker/pulse-worker.php`
- [Metric collection](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Service/MetricService.php): `pulse/src/Service/MetricService.php`

### Persistence

- [Pulse repository](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/PulseRepository.php): `pulse/src/Repository/PulseRepository.php`
- [Metric repository](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/MetricRepository.php): `pulse/src/Repository/MetricRepository.php`
- [Visitor repository](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/VisitorRepository.php): `pulse/src/Repository/VisitorRepository.php`
- [Event repository](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Repository/EventRepository.php): `pulse/src/Repository/EventRepository.php`
- [MySQL access](https://github.com/hidingdust/pulse-design/blob/master/pulse/src/Support/Database.php): `pulse/src/Support/Database.php`

### Other components

- **Visitor**
- **PHP API origin**
- **MySQL database**

## Connections

- Visitor → Application entry: uses (evidence: `README.md`)
- Application entry → API client: calls (evidence: `pulse/frontend/src/main.js`)
- Application entry → 3D lifeform: updates (evidence: `pulse/frontend/src/main.js`)
- Application entry → Status HUD: updates (evidence: `pulse/frontend/src/main.js`)
- Application entry → Report drawer: renders (evidence: `pulse/frontend/src/main.js`)
- Application entry → Demo controls: registers (evidence: `pulse/frontend/src/main.js`)
- Status HUD → Timeline view: renders (evidence: `pulse/frontend/src/components/Hud.js`)
- API client → Edge API proxy: routes via
- Edge API proxy → PHP API origin: forwards API (evidence: `README.md`)
- API client → PHP API entry: requests API (evidence: `README.md`)
- PHP API entry → Route controller: dispatches (evidence: `pulse/public/index.php`)
- Route controller → Pulse operations: routes operations (evidence: `pulse/src/Controller/ApiController.php`)
- Route controller → Demo scenarios: checks demo config (evidence: `pulse/src/Controller/ApiController.php`)
- Pulse operations → Pulse rules: applies rules (evidence: `pulse/src/Service/PulseService.php`)
- Pulse operations → Pulse repository: reads and updates (evidence: `pulse/src/Service/PulseService.php`)
- Pulse operations → Metric repository: reads metrics (evidence: `pulse/src/Service/PulseService.php`)
- Pulse operations → Visitor repository: records visits (evidence: `pulse/src/Service/PulseService.php`)
- Pulse operations → Event repository: records events (evidence: `pulse/src/Service/PulseService.php`)
- Pulse operations → Demo scenarios: manages scenarios (evidence: `pulse/src/Service/PulseService.php`)
- Heartbeat worker → Metric collection: collects metrics (evidence: `pulse/worker/pulse-worker.php`)
- Heartbeat worker → Pulse rules: computes state (evidence: `pulse/worker/pulse-worker.php`)
- Heartbeat worker → Pulse repository: updates heartbeat (evidence: `pulse/worker/pulse-worker.php`)
- Heartbeat worker → Event repository: logs changes (evidence: `pulse/worker/pulse-worker.php`)
- Metric collection → Metric repository: persists samples (evidence: `pulse/src/Service/MetricService.php`)
- Metric collection → Visitor repository: reads visitors (evidence: `pulse/src/Service/MetricService.php`)
- Metric collection → Pulse repository: reads pulse state (evidence: `pulse/src/Service/MetricService.php`)
- Metric collection → Demo scenarios: applies overrides (evidence: `pulse/src/Service/MetricService.php`)
- Pulse repository → MySQL access: uses connection (evidence: `pulse/src/Repository/PulseRepository.php`)
- Metric repository → MySQL access: uses connection (evidence: `pulse/src/Repository/MetricRepository.php`)
- Visitor repository → MySQL access: uses connection (evidence: `pulse/src/Repository/VisitorRepository.php`)
- Event repository → MySQL access: uses connection (evidence: `pulse/src/Repository/EventRepository.php`)
- MySQL access → MySQL database: connects to (evidence: `pulse/src/Support/Database.php`)
