Skip to content
All articles

Software Architecture

A static blog on shared hosting: Next.js, a PHP API and GitHub Actions

I wanted my writing to belong to my own garden, not to a platform's algorithm. Here's the architecture of Mavi Bahçem, my personal blog that combines the speed of a static site with the low cost of shared hosting.

Fahrettin Baştürk5 min read

I love writing. I collect my essays on anime, manga, books, Studio Ghibli and engineering at Mavi Bahçem ("my blue garden", in Turkish). In one of those essays I wrote that writing is like debugging your thinking; building the technical side of the blog felt exactly the same.

I set myself one condition from the start: my writing should belong to my own garden, not to a platform's algorithm. But off-the-shelf CMSs brought unnecessary runtime weight, and headless CMS services brought a monthly bill. For a personal blog, both were too much.

Solving speed and cost together

The balance I found: the front end readers see is completely static, and only the parts that need interaction go to a small API.

  • Front end: Next.js 16 App Router with output: 'export', fully static HTML. No Node process running on a server.
  • Back end: framework-free PHP with PDO and MySQL. It runs on shared hosting at no extra cost.
  • In between: reader cards, comments, the Garden Board, a guestbook, a newsletter and the admin panel, all via the API.

If the build can't reach the API, it must stop

On a static site, posts are fetched from the API at build time. In the first version I noticed a risk: if the API was briefly unreachable, the build could receive an empty list and publish an empty site. So the build fails and stops when it can't reach the API. An old but full site in production is always better than a new but empty one.

const res = await fetch(`${API}/posts`, { cache: 'no-store' });
if (!res.ok) throw new Error(`Could not reach the API (${res.status}); publishing stopped.`);
const posts: Post[] = await res.json();
if (posts.length === 0) throw new Error('The post list came back empty; publishing stopped.');

What happens when I press "Publish"?

My favorite part of this project is the publishing loop. When a post is added or updated in the panel:

  1. The API triggers GitHub Actions with repository_dispatch.
  2. The workflow builds the static site and uploads it to the host with rsync.
  3. Posts that haven't been announced yet are sent once to a Discord webhook and to newsletter subscribers.
  4. New URLs are submitted to search engines with IndexNow.

The "once" part matters. Announcing the same post twice leaves readers with a bad feeling. Announcement state is stored in the database; even if the workflow runs again, it never resends a post that has already been announced.

Keeping a small API safe

Not using a framework meant thinking about security myself. The admin panel and reader cards are protected by two separate JWT types signed with different secrets, so a reader's token is useless in the panel under any circumstance. Public endpoints have rate limiting and honeypot fields. Endpoints are thin; business logic lives in per-domain modules like posts, comments, readers, board, subscribers and deploy.

Details that make reading easier

As much as I love the technical side, a blog's real job is to be read. I spent time on a sticky sidebar, reading progress, a table of contents and stars that twinkle only in dark mode. The design matches the name: a night sky, clouds and a little paper plane. It's inspired by The Wind Rises, just like this site.

Who is this setup for?

This architecture fits sites whose content changes often but not intensely: personal blogs, small magazines, company news pages. There's no need to generate a page for every reader; generating it once per publish is enough. In return you get a fast, cheap site that needs almost no maintenance.

For me, Mavi Bahçem is both an engineering experiment and a personal space. Saving a post in the panel and seeing it live as a static page a few minutes later still gives me a small joy. Maybe that's the taste of building something with your own hands.

Fahrettin Baştürk

Software Engineer & Consultant

Share
  • Next.js
  • PHP
  • GitHub Actions
  • SEO

Working on a similar system or problem?Tell me about your project