zevolution / golang-netflix-hexagonal-arch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FlixHexaArch-Logo

Golang Netflix Hexagonal Arch

Table of contents

About the project

This project was created as a simple example to show how we can create a golang application. This project use Hexagonal Architecture as described in zevolution/netflix-hexagonal-architecture and the same business rule applied in zevolution/quarkus-job-java17-hexagonal-arch

Description

This project has as a business rule to get all software from one author in the main cloud DVCS such as Github, Gitlab, Bitbucket and persist this softwares in a mongodb grouped by author

Describe folder structure

πŸ“¦ app-folder
┣ πŸ“‚ adapters: Adapters responsible for driving or being driven from external events or business-logic
┃ ┣ πŸ“‚ datasources: Also know as driven adapter, secondary adapter or outbound adapter. Responsible for dealing with our application's data sources such as databases, message brokers(producers), cache, http providers and etc. Normally driven by business-rule
┃ ┃ ┣ πŸ“‚ services: Services used by datasource
┃ ┃ ┃ ┣ πŸ“‚ data: DTO's used for any data source other than a database, such as http apis
┃ ┃ ┃ ┃ ┣ πŸ“‚ request:
┃ ┃ ┃ ┃ ┣ πŸ“‚ response:
┃ ┃ ┃ ┣ πŸ“‚ mappers: Responsible for mapping the DTO's, to business-logic(internal) entities
┃ ┃ ┃ ┣ πŸ“‚ models: Responsible for mapping entities that deal directly with any database
┃ ┣ πŸ“‚ transportlayers: Also known as a driving adapter, primary adapter or input adapter. Responsible for being the gateway to the external world of our application, whether via rest, graphql, message-broker(consumers), socket and application events as startup. Normally driving one or more business rule
┃ ┃ ┣ πŸ“‚ mappers: Responsible for mapping the DTO's, to business-logic(internal) entities
┃ ┃ ┣ πŸ“‚ http(example): Example of where we can add our http controllers/handlers such as REST and GraphQL
┃ ┃ ┣ πŸ“‚ consumers(example): Example of where we can add our Listener and Consumers from message brokes such as RabbitMQ, Kafka, SQS, Redis and etc
┃ ┃ ┣ πŸ“‚ cli(example): Example where we can have our entry point for CLI
┣ πŸ“‚ bootstrap: Application startup/configuration classes
┃ ┣ πŸ“‚ config: Application config such as database, migration, env variables
┃ ┣ πŸ“œ entry.go: Main file for application startup
┣ πŸ“‚ internal: Contains everything related to Application Business-Logic
┃ ┣ πŸ“‚ entities: Contains entities that are normally used to represent our business domains/model
┃ ┣ πŸ“‚ interactors: Contains UseCases(or services) which is a list of actions/events that typically define the interactions required for the system to achieve a goal. Normally triggered by a driving adapter such as rest/graphql, and responsible for trigger a driven adapter, such as database or message-broker(as producer)
┃ ┣ πŸ“‚ repositories: Also know as Ports from Ports&Adapters is interfaces responsible for specifying the behavior of a datasource(driven/secondary/outbound adapter), such as which input and return parameters must follow. "How" datasource will do this, it is own responsibility, since it converts the result in the imposed specification
┣ πŸ“œ .gitignore
┣ πŸ“œ Dockerfile
┣ πŸ“œ docker-compose.yml
┣ πŸ“œ go.mod
┣ πŸ“œ go.sum
β”— πŸ“œ README.MD

Built with

Installation

To clone and run this application, you'll need Git installed on your computer(or no, if you want to download .zip). From your command line:

# Git CLI
git clone https://github.com/zevolution/golang-netflix-hexagonal-arch.git

# Github CLI
gh repo clone zevolution/golang-netflix-hexagonal-arch

Requirements to run

Run

  1. Just open the application folder in a terminal and run docker-compose up

License

MIT