More than a year ago I started working on a side project born out of the furstration I had with buffer, ifttt and zapier. The use case was pretty simple: I just wanted to share an article and some comments about it on multiple social media platforms from a single location.
All sharing services had great functionalities (e.g. automated workflows) Initially I played with RSS and hugo for publishing content via a RSS feed which will then trigger posts on Twitter, LinkedIn & co. but you’re always limited in the number of shares you can distribute withing a time frame without paying for premium. At the same time they all lacked support for LinkedIn which then sparked the idea for gocial. After having a look at the LinkedIn Post API Which apparently now it’s legacy and got replaced by the posts API. I decided I’ll implement my own service in Golang and learn more about OAuth and JWT tokens.
For the overall system design I use a serverless environment to run my Golang binary. Currently I use netlify.com to host my Lambda function which serves all the functionalities via HTTP and some REST API.
As for the software architecture I’ve used hexagonal architecture to have more or less strict boundaries between the domains and enable lose coupling.
As always I’ve started with a rough idea how the code structure should like. Initially I wrote down some ideas on my whiteboard And yeah, coding and drawing with kids is possible! 😊 and codified these later on.
I know the picture below doesn’t look like an hexagonal structure but it should at least emphasize what the core domain is about.
I’ve recently release an online presentation on this topic. Checkout Hexagonal Architecture (Basic Introduction using Python).
For the project structure/layout I’ve decided to go with this structure:
This is where the gocial specific domain code goes to. This includes entities, different services and the authentication part.
This folder contains HTTP server specific functionalities:
- here I put all the HTML templates and components (partials)
- I use tailwindCSS so there is a little bit of
- responsible for launching the HTTP server and setting up API routes
- renders HTML templates
- handles different API routes (e.g. sharing articles/comments)
- defines API endpoints for doing OAuth