Releasing Gocial
Tags: go, serverless, tailwindcss, netlify
Published: 2022-12-21 11:19:15

---
title: Releasing Gocial
published: true
date: 2022-12-15 20:40:00 UTC
tags: go, serverless, tailwindcss, netlify
canonical_url: https://blog.dornea.nu/2022/12/15/releasing-gocial/
---

More than a year ago I started working on a [side project](https://brainfck.org/t/deliberate-practice) born out of the furstration I had with [buffer](https://buffer.com/), [ifttt](https://ifttt.com/) and [zapier](https://zapier.com/). 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) 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](https://gocial.netlify.app/). After having a look at the [LinkedIn Post API](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api?view=li-lms-unversioned&tabs=http) I decided I’ll implement my own service in [Golang](/tags/golang) and learn more about [OAuth](https://brainfck.org/t/OAuth) and [JWT](https://brainfck.org/t/JWT) tokens.

[![](https://blog.dornea.nu/posts/img/2022/gocial/2022-12-screenshot.png)](https://gocial.netlify.app)
_gocial main page_

## Design

For the overall _system design_ I use a [serverless](https://brainfck.org/t/serverless) environment to run my Golang binary. Currently I use [netlify.com](https://www.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](https://brainfck.org/t/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 codified these later on.

[![image](https://blog.dornea.nu/posts/img/2022/gocial/architecture-sketches.jpg)
Early ideas
](/posts/img/2022/gocial/architecture-sketches.jpg)

### 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)](https://slides.dornea.nu/2022/hexagonal-architecture/).

[![image](https://blog.dornea.nu/posts/img/2022/gocial/architecture.png)
Hexagonal Architecture
](/posts/img/2022/gocial/architecture.png)

## Project layout

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

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

```
  ./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`

```
  ./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:

- `/html`
  - here I put all the HTML templates and components (partials)
  - I use [tailwindCSS](https://tailwindcss.com/) so there is a little bit of `npm` foo
- `http.go`
  - responsible for launching the HTTP server and setting up API routes
  - renders HTML templates
- `api.go`
  - handles different API routes (e.g. sharing articles/comments)
- `oauth.go`
  - defines API endpoints for doing OAuth

## Project repository

[![](https://socialify.git.ci/dorneanu/gocial/image?description=1&descriptionEditable=gocial%20-%20social%20media%20interactions&font=Source%20Code%20Pro&forks=1&language=1&name=1&owner=1&pattern=Solid&stargazers=1&theme=Light)](https://github.com/dorneanu/gocial)
_Check out the github repository_