How I and my agents got myself live on a static site today without the usual backend (Category Architecture)
This week I have four conversations with experts live: two have already passed, two are yet to come. The format of real-time communication ceased to be a one-off experiment for me, and at some point it became strange that my website was a real-time experience. polomodov.tech He doesn't know anything about it. I wanted a simple behavior: if the next seven days are scheduled to air, the site itself shows the announcement. When the broadcast begins, the block switches to state. live. If there is no ether, you do not need to rule your hands, reassemble or lay out specifically for one plaque.
There was an interesting limitation. The site is static, assembled on GitHub Pages and runs on its own domain. He does not have a regular backend, and I did not want to start a separate service with a server and a database for the sake of broadcast status. But you can not do without the server part: YouTube API requires OAuth, which means that somewhere you must live safely. client secret and refresh token.
So I ended up talking to Codex this morning, and we designed this.
Added not a full backend, and one narrow dynamic layer – Cloudflare Worker.
Every two minutes, OAuth requests lists from YouTube. active and upcoming broadcasts;
Discards non-public broadcasts and broadcasts of another channel, then selects the current or nearest planned one;
- Stores a normalized picture of three states in Workers KV -
offline,upcoming,live- and cache separately.access token; - Outside only gives public read-only endpoint
/statuswithout OAuth data and unnecessary details of the YouTube API; The browser polls this endpoint once a minute, but only as long as the tab is visible.
Separately provided not only how to show the air, but also how to safely stop showing it. The client checks the schema version and all response fields. If the image is older than ten minutes, it is considered outdated and the interface returns to the user interface. offline. An announcement is also hidden if the broadcast is scheduled for more than seven days. A YouTube or Worker error doesn't turn into an eternal plaque of "we're on the air."
The player itself does not load in advance. For live streaming, iframe only appears after a click. If I fall into insanity and forbid embedding a Youtube frame, the site will show a preview and a link to the YouTube page. In navigation, the indicator appears only in the state live. I didn’t leave the operating part for later either: Worker changes are laid out in a separate GitHub Actions script, and another script checks the scheme once an hour. /status and freshness of data. At the same time, visits to the site do not increase the number of requests to YouTube - only Worker addresses the API on a schedule.
It took less than a day from start to release: This morning, the agent and I agreed on architecture.
- Principal PR opened in 12:46
- In 15:48 branch synchronized with
main(I roared and accepted the change.) Next, I configured all tokens and accesses according to the instructions of the agent between Google Cloud Console, Cloudflare, Github - And in 17:09 The changes were stirred and further rolled out. K 18:00 The site has already displayed tomorrow's stream with Zhenya Sergeev about whitepaper Anthropic
In general, now developing your pet projects is a pure fan, especially if you understand engineering and have set up a bunch of deterministic checks that allow the agent to safely achieve their goals:)
#Architecture #Engineering #Web #Cloudflare #DevOps #YouTube