A Peek Under The Hood

By Serdar Yegulalp on 2021-03-28 21:00:00 No comments


I've received a couple of notes from people who're curious about how this blog is built. It's all custom software, which I will in time release as open source once it's not quite so awful to behold. But here's the basics.

  • The whole system is written in Python 3.8+. It's more than fast enough for what I'm doing, since the vast majority of the bottlenecks involve streaming data from the database or waiting for network or disk I/O to complete.
  • The app uses a SQLite 3 database to store posts. I opted for this over MySQL since it makes it easier to manage and transport the data, and SQLite runs wicked fast.
  • Posts are rendered to static HTML and served by my host's web server. The app itself does not serve anything to the end user. Any changes made to pages are rebuilt in such a way that only the changes need rebuilding.
  • I use the Bottle framework for the client UI, Bottle's built-in rendering engine for the templating system used by blogs, the Peewee ORM for database access, and a few other third-party bits.
  • All posts are created and edited in the browser using a WordPress-like interface, built with Bootstrap and the Tiny editor. I'm planning to make it possible to also write posts in Markdown, and want to have an in-browser MD editor to support that.
  • Whenever changes are made, they're pushed into a queue. Every ten minutes a cron job polls the queue for waiting jobs. I can also run the queue manually, in the browser. If I publish a post to go live at a certain time, it's not pushed into the queue pre-emptively, though; the cron job checks for scheduled posts that are at or past their publication date and then queues them if they exist.

Among the features I built into the system:

  • The ability to create a preview of a post and share it before it goes live. With my previous system, I found myself in too many positions where I wanted to share a draft of something with people ahead of time, so I built that into my current system from the git-go. When a post goes live, it automatically erases any previews.
  • Edit locking, so that multiple users cannot mistakenly edit the same post. (Not too useful for me yet as I'm the only one here, but it reminds me of when I have a post already open somewhere.)
  • Categories, tagging, media uploads, and the ability to attach metadata to every object in the system. This last makes it possible to extend things elegantly -- e.g., to attach Amazon.com product links to a post, or insert other metadata that can be used by a template to change rendering or take selective action.

So far, the whole thing has served me very well indeed. Long may it wave.


Tags: Bootstrap Python SQLite blogging programming software