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.

gocial main page

Design

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.

Sketching ideas

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.

Hexagonal Architecture

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).

Project layout

For the project structure/layout I’ve decided to go with this structure:

1
2
3
4
5
6
7
gocial:

├── cli
├── docs
├── internal
├── lambda
└── server
Code Snippet 1: Overall project structure

/internal

This is where the gocial specific domain code goes to. This includes entities, different services and the authentication part.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  ./internal
  ├── config
  │   └── config.go
  ├── entity
  │   ├── identity.go
  │   ├── providers.go
  │   └── share.go
  ├── identity
  │   ├── cookie_repository.go
  │   ├── file_repository.go
  │   └── repository.go
  ├── jwt
  │   └── token.go
  ├── oauth
  │   ├── goth_repository.go
  │   ├── repository.go
  │   └── service.go
  └── share
      ├── linkedin_repository.go
      ├── repository.go
      ├── service.go
      └── twitter_repository.go

/server

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  ./server
  ├── api.go
  ├── html
  │   ├── html.go
  │   ├── package.json
  │   ├── package-lock.json
  │   ├── postcss.config.js
  │   ├── static
  │   │   └── main.css
  │   ├── tailwind.config.js
  │   ├── tailwind.css
  │   ├── tailwind.js
  │   └── templates
  │       ├── about.html
  │       ├── auth
  │       ├── base.html
  │       ├── index.html
  │       ├── partials
  │       └── share
  ├── http.go
  ├── oauth.go
  └── share.go

This folder contains HTTP server specific functionalities:

Project repository

Check out the github repository