# htl-tv Full-screen TV display for [maakleerplek](https://maakleerplek.be/) — a public makerspace in Leuven. Shows the current time, weather, upcoming events, news, a drinks/materials inventory, and machine usage rates on a 4K TV. ![Screenshot of the TV display](Public/image.png) ## Features ### Machine prices The "Machine usage" strip reads its prices from InvenTree. Each machine is a virtual part in the category `INVENTREE_MACHINE_CATEGORY` (default `Machinegebruik`). The sale price break is the price per unit (the part's units, e.g. `min` or `g`), and the parameter `Minimum` is the least a job costs. `data-fetcher/scripts/seed-machine-pricing.js` creates the category and the parts. ### InvenTree Integration Pulls live stock levels and prices for drinks, snacks, and consumable materials directly from an InvenTree instance. ### Calendar & News Scrapes the main maakleerplek.be website for the latest news and upcoming events, automatically prioritizing "high-profile" events like OpenLabs or Repair Cafés. ### Changelog API External projects can report stock actions that are then shown as a live "Recent activity" feed in the inventory panel. **Endpoint:** `POST /api/changelog` **Body:** ```json { "action": "checkout", "source": "my-project", "item_name": "Club Mate", "quantity": 2 } ``` | Field | Type | Values | |---|---|---| | `action` | string | `checkout` (sold), `add` (restocked), `remove`, `set` | | `source` | string | Free-form identifier of the sending project | | `item_name` | string | Human-readable name of the item | | `quantity` | number | Positive integer | The endpoint is available at the TV presentation URL (default port 8083). Failures are silently ignored so they never block the calling workflow. **Integrations already included:** - [htl-stock](https://github.com/maakleerplek/htl-stock): set `VITE_TV_PRESENTATION_URL` in `.env` - [htl-kiosk](https://github.com/maakleerplek/htl-kiosk): set `TV_PRESENTATION_URL` in `.env` ## Quick Start ```bash # 1. Copy config cp .env.example .env # 2. Build and run docker compose up -d --build ``` - Frontend: `http://localhost:8083` - Data-fetcher API: `http://localhost:8085` ## Configuration | Variable | Description | |---|---| | `MAAKLEERPLEK_URL` | Base URL of the website; also used for the "Bezoek" QR code | | `STOCK_QR_URL` | URL encoded into the "HTL stock" QR code in the footer | | `INVENTREE_URL` | URL of your InvenTree instance | | `INVENTREE_TOKEN` | InvenTree API token | | `INVENTREE_MACHINE_CATEGORY` | InvenTree category with the machine usage prices (default `Machinegebruik`) | | `INVENTREE_DRINKS_LOCATIONS` | Comma-separated location names to show in the inventory panel | | `PAYMENT_QR_URL` | URL for the payment QR code shown in the inventory section | | `CAROUSEL_TRANSITION_TIME` | Seconds per carousel slide (default `15`) | | `EVENT_PRIORITY` | Comma-separated keywords; earlier = higher priority in the status panel | | `WEATHER_LAT` / `WEATHER_LON` | Coordinates for Open-Meteo weather | | `CACHE_DURATION_MINUTES` | How long scraped data is cached (default `15`) | ## Development ```bash # Full stack docker compose up --build # Frontend only cd "Reworked website" bun install bun run dev # Data-fetcher only cd data-fetcher node --no-warnings --watch server.js ``` ### Auto-deploy (htl-server) `master` is production. Every 5 minutes cron runs `scripts/autodeploy.sh`: once CI on a new master commit is green it pulls and runs `docker compose up -d --build`, and rolls back to the previous commit if a container does not come up healthy. Log: `.git/autodeploy.log`. Install once: `(crontab -l; echo "*/5 * * * * $PWD/scripts/autodeploy.sh") | crontab -` ## Tests ```bash # Frontend cd "Reworked website" bun test # Data-fetcher cd data-fetcher bun test ``` ## Tech Stack - **Next.js 15** (App Router, TypeScript, Tailwind CSS v4, Bun runtime) - **Node.js + Express + Cheerio** — Modular data-fetcher service - **SQLite** (`bun:sqlite`) — Stores custom news items and admin credentials - **InvenTree** — Source for the drinks/materials inventory - **Docker Compose** — Orchestrates frontend, data-fetcher, and nginx reverse proxy ## CI / CD A GitHub Actions workflow automatically creates a **Prerelease** on every push to `master` or a PR targeting it, tagged as `master-` or `pr--`. Tests run as part of the workflow.