# LASUCA Shared Endpoint This micro-endpoint exposes the historian snapshot consumed by both the desktop dashboard and the factory display clients. It returns a normalised JSON payload so updates happen in one place. ## Project layout ``` shared-endpoint/ ├── config.php # Connection + cache settings (override with env vars in production) ├── public/ │ └── index.php # JSON endpoint (`/shared-endpoint/public/index.php`) └── src/ └── Database.php # `fetchLatestItems()` helper wrapping the `items` table ``` ## Running locally 1. Set the required environment variables (optional if you reuse the on-prem credentials): - `LASUCA_DB_HOST` - `LASUCA_DB_USER` - `LASUCA_DB_PASSWORD` - `LASUCA_DB_NAME` - `LASUCA_CACHE_TTL` (seconds, defaults to 1) 2. Serve the project (from one level above `shared-endpoint`): ```powershell php -S localhost:8081 shared-endpoint/public/index.php ``` The endpoint will respond with: ```json { "status": "ok", "metadata": { "generatedAt": "2025-10-16T14:22:00+00:00", "count": 321 }, "items": [ { "tagId": 1, "name": "RUNHRSTODAY", "value": 12, "rounded1": 12.0, "rounded2": 12.00, "timestamp": "2025-10-16 09:20:31" } ] } ``` ## Integrating with the dashboards 1. Move this folder so it sits alongside `overviews/` (both projects can then include `../shared-endpoint/public/index.php`). 2. Update the existing UI code to call `fetchLatestItems()` through the endpoint instead of including `includes/items.php` directly: - Server-side PHP can `file_get_contents('http://localhost:8081')` and `json_decode` the result. - Front-end polling can swap `data/main.php` for the JSON feed if you add a thin adapter. 3. When you edit tag metadata, change it once in the database—every consumer will see it on the next poll. > **Tip:** keep the endpoint repo in its own workspace or git submodule so both the control room and display teams can update it without stepping on each other.