Mike's Program

A place for notes

Micheal Earl

I’ve now written a few web apps in Go. My latest creation features Go on the backend using Gin as a lightweight web framework and gorm as my ORM. Gorm really surprised me with how easy it is to use. I still have a lot to learn about how it works, but it appears to manage migrations in a really intuitive way.

My database is PostgreSQL and it has been pretty easy to use. I just spin up a docker container with Postgres installed and connect to it with gorm.

On my front end is a Preact server that gets data from my back end through a REST api. I looked into GraphQL and it was pretty interesting, but has a decent learning curve and was not nearly as simple to implement.

For now, I’m working on authentication and exploring the ecosystem in Go. I would likely never roll my own auth in a production app, but going through the process of designing auth from scratch really helps me understand what all those third party libraries are doing anyway.

Sessions have been on the top of my list. My current goal is to make a Reddit style social media app that can scale to many users.

Architecture

This is my tentative plan for now. As long as I design my front end and back end to be stateless, they should hopefully be able to handle arbitrary requests without knowledge of the previous ones. A caveat is session storage, but I can store session data in redis.

I may have to scale up the database layer too with multiple read only databases and a few write only databases, but I’m not 100% sure how to go about that yet. I’m not particularly experienced at scaling web applications to crazy amounts of users, but even this basic plan should ensure that I can use something like kubernetes and docker to scale the number of servers.