TeddyCloud is a local server that replaces the official Toniebox cloud service, enabling full local control and customization of Toniebox audio content. It handles HTTP/HTTPS requests from Toniebox devices, serving audio content, firmware updates, and handling freshness checks. It also provides a web management interface, MQTT integration for Home Assistant, and audio encoding/decoding. The server emulates the Toniebox cloud API, allowing devices to operate without internet access to the official cloud. The architecture is a monolithic C server using the CycloneTCP library for networking, TLS, HTTP, and MQTT. It uses a custom OS abstraction layer for portability across Linux and Windows. The server has multiple handlers for cloud API emulation, reverse proxying, Server-Sent Events (SSE), and security mitigation. It includes a full TLS certificate generation system and ESP32 firmware patching capabilities. Audio content is encoded/decoded using the Opus codec and stored in the Tonie Audio File (TAF) format. Key entry points include main.c for initialization, server.c for request dispatching, and handler_cloud.c for Toniebox API emulation. Data flows involve the server receiving requests from Tonieboxes, checking local cache, and either serving cached content or proxying to the real cloud. MQTT is used for Home Assistant discovery and control, and SSE provides real-time device events. The server also supports custom tonies JSON databases and audio playlist management. External dependencies include CycloneTCP/CycloneSSL/CycloneCRYPTO for networking and cryptography, FatFs for FAT filesystem operations, Opus for audio codec, cJSON for JSON parsing, protobuf-c for protocol buffers, and ffmpeg for audio conversion. The web frontend is a separate submodule (teddycloud_web) that provides the management UI.