An AJAX forum with Kirby as the backend?

So, when I started paying attention to web development one of the “dream goals” I had in mind was to one day reproduce the interface and feel of Durarara!!'s “Dollars” chatroom (which has been done here, for instance).

The features I’d be looking to reproduce / craft:

  • It’s a chatroom. Users may have an avatar with basic identification features or post as anonyms; messages have an author (may be blank), a date and a content.
  • It needs to refresh at least once every minute (that is, to check whether there are new messages in the chatroom).
  • Probably, it’d have some DOM cleanup agent to make sure the page doesn’t get too heavy for active users (and a corresponding archive feature to read older posts).

I recently started digging around AJAX (and I’m getting reasonably good with Kirby itself), and now I’m thinking tackling the challenge may be feasible with Kirby as a backend framework and jQuery as the chatroom “engine” (using jQuery’s AJAX functionalities to refresh, post, etc.). It’s probably not ideal, but still something for which I’d like to evaluate the feasability.

Hence, a few questions.

  • Let’s first approach the issue from a flat-database perspective. The “thread” would likely be a single .txt file (let’s call it Thread.txt), which would be updated every time a new post is made by a user. Is there a way to store an array-like list in a .txt, in such a way that Kirby can easily retrieve individual posts from that array-in-a-single-file? (I assume this would require parsing?)
  • Still flat-database, but with more files (probably simpler to code but slower?), a given thread could be a folder containing .txt files for each post (each file would be titled with its post date, for instance). Then it’s trivial to retrieve the 50 youngest messages for instance. How much slower would it be, though?
  • I haven’t really worked with a database before. Assuming I end up picking this option (probably for performance issues), what would be the simplest approach to database handling? (Which database-type, specifically?)

Thanks for reading, and cheers!