Fraser the Third

“Fraser the bot” (see https://fraserthebot.com/about) is up and running in its third incarnation. The first incarnation was a chat bot (see “Frogitecture”), connected to the APIs of a few different chat services including Telegram, Slack, and Facebook Messenger. The second was a mobile app on iOS and Android, built with Flutter. That incarnation used the two app stores subscription services as its mechanism for user account verification.

This third incarnation is a web application. A number of technologies have been added to the mix, and the core pieces of Fraser have had upgrades.

PostgreSQL
Fraser’s records have always been stored on PostgreSQL. This received an updated version as well as a few new tables to support the newly added user authentication, which I’ll describe in a section below.

Python and spaCy
The core of Fraser runs on Python, with Tornado to serve up its REST API. I updated all the python dependencies, including spaCy. I also changed from spaCy’s vector based language model to its transformer model for the up-front parsing of the documents. This resulted in an improvement to the named entity recognition. Although I’m using the transformer model when I build Fraser’s backing data, the vector model is still being used on the server for comparing phrase similarities.

Redis
Redis played a role in the second incarnation of Fraser, and in this third incarnation it has two minor jobs. I use it for the temporary storage of one-time-pass codes, and I use it for publish/subscribe of messages with any shared “observer” pages. (More on that below.)

DNS
The previous, static fraserthebot.com web pages were hosted on AWS with S3 and Route 53. DNS remains on Route 53, but the domain (and staging subdomain) are now pointing at my new server on Hetzner.

Hetzner
My family will be happy to know that I am recycling hardware. 🙂 I used Hetzner’s “Server Auction” to rent some second-hand hardware. It’s a Xeon machine with 64GB and a couple of SSDs configured in software RAID (Ubuntu). That hardware sits at their data center in Germany, and I’m also taking advantage of Hetzner’s storage service for backups.

HAProxy
On the new Ubuntu server, I’m using HAProxy for rate limiting, blue/green deployments, and SSL termination for the Let’s Encrypt certificate. And, of course, HAProxy will be the load balancer if scaling is required.

Next.js
This tech stack was new to me. I hadn’t done any real work with React prior to this. I used Material UI for basic components and layout. Other than the “/shared” pages (more on that below), all of the pages and UI for fraserthebot.com are served up from this service. This, and the other services, are managed using systemd.

NextAuth.js
I’m using this library to deal with authentication basics like the session JWT, but it didn’t provide what I wanted out of the box so I largely went my own way with the email based one-time-passcodes. I’m using AWS Simple Email Service for emailing the temporary passcodes from the web app.

Blazor ASP.NET
The web app has a feature for a player to share a view-only link to their session. I have a secondary service running, in Blazor, that receives any “/shared” page request. If that session is still active, then the shared (observer) page automatically updates itself when the player exchanges new messages with Fraser. I’m using SignalR to a minor extent for this, and the server-side Blazor pages take care of their automatic updates. This service receives messages from the Next.js service via Redis pub/sub.