Previously used for hosting university and side projects, sonurai.com is now hosting Bing wallpapers which are updated daily and the code is fully open source.

The legacy version was all hosted on a single $5 per month VPS box running Centos. This contained Nginx, MySQL, PHP and it was built using the Symfony framework. Images were hosted in the local filesystem. Updates had to be manually installed, firewall rules and CRON too.

Now it is fully hosted in the cloud and uses "serverless" for bits. It costs around $4 per month depending on usage, but requires zero management. This price is attained by using Google Cloud Platform's (GCP) free tier, free hosting from Vercel and probably some aspect of Cloudflare's CDN.

Frontend

The frontend is built using Next.js and hosted on Vercel. It has a simple design created using the Bootstrap CSS framework.

Image optimisation happens automatically. This means web browsers get images optimised for their screen size and they only load images when in or near view. Resulting in faster loading of images and a quicker first contentful paint.

Backend

The backend is fully hosted on GCP in the same US region to save costs. The majority of the traffic comes from the US so it is hosted there to reduce latency.

Cloud Firest0re is the NoSQL database which encompasses the wallpaper entries.

The API is written in GoLang and gets deployed as a container automatically on Cloud Run with a push to the main branch.

A GoLang function which updates the Bing wallpapers is hosted on Cloud Functions (GCP's serverless product). It listens to a Cloud Pub/Sub topic which receives a message daily from Cloud Scheduler (CRON service). HTTP caching headers are set according to this time, so clients receive the latest wallpapers.

Images are stored in a muti-region Google Cloud Storage bucket with a subdomain set. An index.html file redirects to the top-level domain.