All Projects → MarioCarrion → todo-api-microservice-example

MarioCarrion / todo-api-microservice-example

Licence: MIT license
Go microservice tutorial project using Domain Driven Design and Onion Architecture!

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to todo-api-microservice-example

DDD
Domain-Driven Design example
Stars: ✭ 116 (-75.78%)
Mutual labels:  domain-driven-design, onion-architecture
Domain Driven Hexagon
Guide on Domain-Driven Design, software architecture, design patterns, best practices etc.
Stars: ✭ 4,417 (+822.13%)
Mutual labels:  domain-driven-design, onion-architecture
Clean Architecture Manga
🌀 Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
Stars: ✭ 3,104 (+548.02%)
Mutual labels:  domain-driven-design, onion-architecture
hask
Haskell domain modeling playground
Stars: ✭ 29 (-93.95%)
Mutual labels:  domain-driven-design
microservice-template
📖 Nest.js based microservice repository template
Stars: ✭ 131 (-72.65%)
Mutual labels:  domain-driven-design
sls-node-ts
Serverless Node TypeScript is a starter kit to write serverless applications by using the Serverless Framework in Node.js and TypeScript. An Apollo GraphQL server and a REST endpoint come configured out of the box
Stars: ✭ 38 (-92.07%)
Mutual labels:  domain-driven-design
typescript-ddd-example
🔷🎯 TypeScript DDD Example: Complete project applying Hexagonal Architecture and Domain-Driven Design patterns
Stars: ✭ 607 (+26.72%)
Mutual labels:  domain-driven-design
EcommerceDDD
Experimental full-stack application using Domain-Driven Design, CQRS, and Event Sourcing.
Stars: ✭ 178 (-62.84%)
Mutual labels:  domain-driven-design
eventuous
Minimalistic Event Sourcing library for .NET
Stars: ✭ 236 (-50.73%)
Mutual labels:  domain-driven-design
tg
Trident Genesis
Stars: ✭ 14 (-97.08%)
Mutual labels:  domain-driven-design
financial
POC de uma aplicação de domínio financeiro.
Stars: ✭ 62 (-87.06%)
Mutual labels:  domain-driven-design
onion-architecture
My Java implementation example of onion architecture
Stars: ✭ 52 (-89.14%)
Mutual labels:  onion-architecture
node-cqrs-saga
Node-cqrs-saga is a node.js module that helps to implement the sagas in cqrs. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
Stars: ✭ 59 (-87.68%)
Mutual labels:  domain-driven-design
OnionArchitecture
The onion architecture, introduced by Jeffrey Palermo, overcomes the issues of the layered architecture with great ease. With Onion Architecture, the game-changer is that the Domain Layer (Entities and Validation Rules that are common to the business case ) is at the Core of the Entire Application. This means higher flexibility and lesser coupli…
Stars: ✭ 314 (-34.45%)
Mutual labels:  onion-architecture
MonolithicArchitecture
This repository presents an approach on how to build an application using Monolithic architecture, ASP.NET Core, EntityFrameworkCore, Identity Server, CQRS, DDD
Stars: ✭ 18 (-96.24%)
Mutual labels:  domain-driven-design
ddd-house
🏠 Building a house with DDD
Stars: ✭ 38 (-92.07%)
Mutual labels:  domain-driven-design
nodebr-meetup-ddd-demo
This is a code sample presented in NodeBR meetup at 2017-07-13
Stars: ✭ 15 (-96.87%)
Mutual labels:  domain-driven-design
domain
A dependency-free package to help building a business domain layer
Stars: ✭ 33 (-93.11%)
Mutual labels:  domain-driven-design
go-ddd-microservice
Domain driven design demonstration with idiomatic golang
Stars: ✭ 23 (-95.2%)
Mutual labels:  domain-driven-design
e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (-89.98%)
Mutual labels:  domain-driven-design

"ToDo API" Microservice Example

codecov

Introduction

Welcome! 👋

This is an educational repository that includes a microservice written in Go. It is used as the principal example of my video series: Building Microservices in Go.

This repository is not a template nor a framework, it's a collection of patterns and guidelines I've successfully used to deliver enterprise microservices when using Go, and just like with everything in Software Development some trade-offs were made.

My end goal with this project is to help you learn another way to structure your Go project with 3 final goals:

  1. It is enterprise, meant to last for years,
  2. It allows a team to collaborate efficiently with little friction, and
  3. It is as idiomatic as possible.

Join the fun at https://youtube.com/MarioCarrion.

Domain Driven Design

This project uses a lot of the ideas introduced by Eric Evans in his book Domain Driven Design, I do encourage reading that book but before I think reading Domain-Driven Design Distilled makes more sense, also there's a free to download DDD Reference available as well.

On YouTube I created a playlist that includes some of my favorite talks and webinars, feel free to explore that as well.

Project Structure

Talking specifically about microservices only, the structure I like to recommend is the following, everything using < and > depends on the domain being implemented and the bounded context being defined.

  • build/: defines the code used for creating infrastructure as well as docker containers.
    • <cloud-providers>/: define concrete cloud provider.
    • <executableN>/: contains a Dockerfile used for building the binary.
  • cmd/
    • <primary-server>/: uses primary database.
    • <replica-server>/: uses readonly databases.
    • <binaryN>/
  • db/
    • migrations/: contains database migrations.
    • seeds/: contains file meant to populate basic database values.
  • internal/: defines the core domain.
    • <datastoreN>/: a concrete repository used by the domain, for example postgresql
    • http/: defines HTTP Handlers.
    • service/: orchestrates use cases and manages transactions.
  • pkg/ public API meant to be imported by other Go package.

There are cases where requiring a new bounded context is needed, in those cases the recommendation would be to define a package like internal/<bounded-context> that then should follow the same structure, for example:

  • internal/<bounded-context>/
    • internal/<bounded-context>/<datastoreN>
    • internal/<bounded-context>/http
    • internal/<bounded-context>/service

Tools

Please refer to the documentation in internal/tools/.

Features

Icons meaning:

  • YouTube video means a link to Youtube video.
  • Blog post means a link to Blog post.

In no particular order:

More ideas

Docker Containers

Please notice in order to run this project locally you need to run a few programs in advance, if you use Docker please refer to the concrete instructions in docs/ for more details.

There's also a docker-compose.yml, covered in Building Microservices In Go: Containerization with Docker, however like I mentioned in the video you have to execute docker-compose in multiple steps.

Notice that because of the way RabbitMQ and Kafka are being used they are sort of competing with each other, so at the moment we either have to enable Kafka and disable RabbitMQ or the other way around in both the code and the docker-compose.yml file, in either case there are Dockerfiles and services defined that cover building and running them.

  • Run docker-compose up, here both rest-server and elasticsearch-indexer services will fail because the postgres, rabbitmq, elasticsearch and kafka services take too long to start.
    • If you're planning to use RabbitMQ, run docker-compose up rest-server elasticsearch-indexer-rabbitmq.
    • If you're planning to use Kafka, run docker-compose up rest-server elasticsearch-indexer-kafka.
    • If you're planning to use Redis, run docker-compose up rest-server elasticsearch-indexer-redis.
  • For building the service images you can use:
    • rest-server image: docker-compose build rest-server.
    • elasticsearch-indexer-rabbitmq image: docker-compose build elasticsearch-indexer-rabbitmq.
    • elasticsearch-indexer-kafka image: docker-compose build elasticsearch-indexer-kafka.
    • elasticsearch-indexer-redis image: docker-compose build elasticsearch-indexer-redis.
  • Run docker-compose run rest-server migrate -path /api/migrations/ -database postgres://user:password@postgres:5432/dbname?sslmode=disable up to finally have everything working correctly.

Diagrams

To start a local HTTP server that serves a graphical editor:

mdl serve github.com/MarioCarrion/todo-api/internal/doc -dir docs/diagrams/

To generate JSON artifact for uploading to structurizr:

stz gen github.com/MarioCarrion/todo-api/internal/doc
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].