# Calendink Provider — Agent Context This is an **ESP32-S3 IoT device** firmware + web dashboard project. It uses **ESP-IDF** (native, not Arduino) and serves a **Svelte 5 web UI** from flash. --- ## Project Summary Calendink Provider is a connected desk device that serves a local web dashboard over Ethernet/WiFi. The firmware manages network connections, serves a Svelte SPA from LittleFS flash partitions, and exposes a REST API for system control (reboot, OTA, tasks, users). ### Key Paths | Path | Purpose | |---|---| | `main/` | C++ firmware (Unity Build) | | `main/api/` | REST API handlers, one file per endpoint | | `main/http_server.cpp` | HTTP server setup, static file serving | | `main/connect.cpp` | Ethernet + WiFi connection management | | `frontend/src/` | Svelte 5 frontend source | | `frontend/src/lib/api.js` | All API calls (always use `trackedFetch`) | | `frontend/src/app.css` | TailwindCSS v4 design tokens (`@theme`) | | `tdd/` | Technical Design Documents (read before major changes) | | `.agents/rules/` | Coding guidelines (always follow) | --- ## Architecture ### Backend - **Unity Build**: `main.cpp` `#include`s all `.cpp` files. Do NOT add files to CMakeLists.txt. Everything is one translation unit. - **API handlers**: Each endpoint is its own `.cpp` file in `main/api//`. A `unity.cpp` aggregates them. - **HTTP server**: `esp_http_server` + `cJSON`. CORS is always on (`*`). - **Data storage**: Users and tasks are in static BSS arrays (`g_Users[8]`, `g_Tasks[32]`). In-RAM only, intentionally — persistence is a future feature. - **OTA**: A/B partition scheme — `www_0` / `www_1` for frontend, `ota_0` / `ota_1` for firmware. NVS tracks which slot is active. - **Connections**: Ethernet first, WiFi fallback. Connection state managed with FreeRTOS semaphores. ### Frontend - **Svelte 5** with runes (`$state`, `$derived`, `$effect`, `$props`). No legacy Svelte 4 APIs. - **TailwindCSS v4** (utility classes only — no `