MCPcopy Index your code
hub / github.com/MarioCarrion/todo-api-microservice-example

github.com/MarioCarrion/todo-api-microservice-example @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,751 symbols 8,402 edges 71 files 230 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

  • [X] dockerfiles/: defines all the Dockerfiles used by the different applications used in the project.
  • [ ] cmd/
  • [ ] <primary-server>/: uses primary database.
  • [ ] <replica-server>/: uses readonly databases.
  • [ ] <binaryN>/
  • [X] db/
  • [X] migrations/: contains database migrations.
  • [ ] seeds/: contains file meant to populate basic database values.
  • [X] internal/: defines the core domain.
  • [X] <datastoreN>/: a concrete repository used by the domain, for example postgresql
  • [X] rest/: defines HTTP Handlers.
  • [X] service/: orchestrates use cases and manages transactions.

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

Running project locally using Docker Compose

Originally added

Extension points exported contracts — how you extend this code

TaskRepository (Interface)
go:generate counterfeiter -generate counterfeiter:generate -o servicetesting/task_repository.gen.go . TaskRepository Tas [5 …
internal/service/task.go
SearchableTaskStore (Interface)
counterfeiter:generate -o memcachedtesting/searchable_task_store.gen.go . SearchableTaskStore [3 implementers]
internal/memcached/searchable_task.go
Provider (Interface)
go:generate counterfeiter -generate counterfeiter:generate -o envvartesting/provider.gen.go . Provider Provider ... [3 …
internal/envvar/envvar.go
MessageBrokerPublisher (Interface)
MessageBrokerPublisher represents the type that indicates the different Message Brokers supported. [3 implementers]
cmd/rest-server/main.go
TaskService (Interface)
go:generate counterfeiter -generate counterfeiter:generate -o resttesting/task_service.gen.go . TaskService TaskService [2 …
internal/rest/task_handler.go
DBTX (Interface)
(no doc)
internal/postgresql/db/db.go
TaskSearchRepository (Interface)
counterfeiter:generate -o servicetesting/task_search_repository.gen.go . TaskSearchRepository TaskSearchRepository defin [5 …
internal/service/task.go
TaskStore (Interface)
(no doc) [5 implementers]
internal/memcached/task.go

Core symbols most depended-on inside this repo

n
called by 2982
cmd/rest-server/static/swagger-ui/swagger-ui-bundle.js
n
called by 2982
cmd/rest-server/static/swagger-ui/swagger-ui-es-bundle.js
n
called by 2055
cmd/rest-server/static/swagger-ui/swagger-ui.js
n
called by 2055
cmd/rest-server/static/swagger-ui/swagger-ui-es-bundle-core.js
n
called by 1331
cmd/rest-server/static/swagger-ui/swagger-ui-standalone-preset.js
r
called by 689
cmd/rest-server/static/swagger-ui/swagger-ui-bundle.js
r
called by 689
cmd/rest-server/static/swagger-ui/swagger-ui-es-bundle.js
o
called by 477
cmd/rest-server/static/swagger-ui/swagger-ui-bundle.js

Shape

Function 1,153
Method 418
Struct 121
Class 24
Interface 20
TypeAlias 12
FuncType 3

Languages

TypeScript64%
Go36%

Modules by API surface

cmd/rest-server/static/swagger-ui/swagger-ui-es-bundle.js293 symbols
cmd/rest-server/static/swagger-ui/swagger-ui-bundle.js293 symbols
cmd/rest-server/static/swagger-ui/swagger-ui-standalone-preset.js187 symbols
cmd/rest-server/static/swagger-ui/swagger-ui.js176 symbols
cmd/rest-server/static/swagger-ui/swagger-ui-es-bundle-core.js176 symbols
internal/rest/server.gen.go119 symbols
client.gen.go90 symbols
internal/rest/resttesting/task_service.gen.go33 symbols
internal/service/servicetesting/task_repository.gen.go27 symbols
internal/memcached/memcachedtesting/task_store.gen.go27 symbols
internal/service/servicetesting/task_message_broker_publisher.gen.go21 symbols
internal/memcached/memcachedtesting/searchable_task_store.gen.go21 symbols

Datastores touched

dbnameDatabase · 1 repos

For agents

$ claude mcp add todo-api-microservice-example \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact