• This repository has been archived on 13/Oct/2021
  • Stars
    star
    2,370
  • Rank 18,675 (Top 0.4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Exploring DDD in Go

GoDDD

Build Status GoDoc Go Report Card License MIT stability-unstable

This is an attempt to port the DDD Sample App to idiomatic Go. This project aims to:

  • Demonstrate how the tactical design patterns from Domain Driven Design may be implemented in Go.
  • Serve as an example of a modern production-ready enterprise application.

Important note

This project is intended for inspirational purposes and should not be considered a tutorial, guide or best-practice neither how to implement Domain Driven Design nor enterprise applications in Go. Make sure you adapt the code and ideas to the requirements of your own application.

Porting from Java

The original application is written in Java and much thought has been given to the domain model, code organization and is intended to be an example of what you might find in an enterprise system.

I started out by first rewriting the original application, as is, in Go. The result was hardly idiomatic Go and I have since tried to refactor towards something that is true to the Go way. This means that you will still find oddities due to the application's Java heritage. If you do, please let me know so that we can weed out the remaining Java.

Running the application

Start the application on port 8080 (or whatever the PORT variable is set to).

go run main.go -inmem

If you only want to try it out, this is enough. If you are looking for full functionality, you will need to have a routing service running and start the application with ROUTINGSERVICE_URL (default: http://localhost:7878).

Docker

You can also run the application using Docker.

# Start routing service
docker run --name some-pathfinder marcusolsson/pathfinder

# Start application
docker run --name some-goddd \
  --link some-pathfinder:pathfinder \
  -p 8080:8080 \
  -e ROUTINGSERVICE_URL=http://pathfinder:8080 \
  marcusolsson/goddd -inmem

... or if you're using Docker Compose:

docker-compose up

Try it!

# Check out the sample cargos
curl localhost:8080/booking/v1/cargos

# Book new cargo
curl localhost:8080/booking/v1/cargos -d '{"origin": "SESTO", "destination": "FIHEL", "arrival_deadline": "2016-03-21T19:50:24Z"}'

# Request possible routes for sample cargo ABC123
curl localhost:8080/booking/v1/cargos/ABC123/request_routes

Contributing

If you want to fork the repository, follow these step to avoid having to rewrite the import paths.

go get github.com/marcusolsson/goddd
cd $GOPATH/src/github.com/marcusolsson/goddd
git remote add fork git://github.com:<yourname>/goddd.git

# commit your changes

git push fork

For more information, read this.

Additional resources

For watching

For reading

Related projects

The original application uses a external routing service to demonstrate the use of bounded contexts. For those who are interested, I have ported this service as well:

pathfinder

To accompany this application, there is also an AngularJS-application to demonstrate the intended use-cases.

dddelivery-angularjs

Also, if you want to learn more about Domain Driven Design, I encourage you to take a look at the Domain Driven Design book by Eric Evans.

More Repositories

1

tui-go

A UI library for terminal applications.
Go
2,086
star
2

obsidian-projects

Plain text project planning in Obsidian
Svelte
1,205
star
3

gophers

Go Artwork
186
star
4

obsidian-plugin-docs

Unofficial documentation for Obsidian plugin development.
JavaScript
181
star
5

obsidian-vale

A Vale client for Obsidian.
TypeScript
85
star
6

pathfinder

Routing context for DDD Sample App, in Go.
HTML
57
star
7

dddelivery-angularjs

An AngularJS application for the DDD Sample App.
HTML
38
star
8

grafana-hourly-heatmap-panel

A panel plugin for Grafana to visualize hourly heatmaps.
TypeScript
35
star
9

edith

An open learning platform based on Gatsby
JavaScript
27
star
10

grafana-dynamictext-panel

A panel plugin for Grafana for dynamic, data-driven text.
TypeScript
27
star
11

grafana-gantt-panel

A panel plugin for Grafana to visualize Gantt charts.
TypeScript
26
star
12

obsidian-pipe-tricks

Adds support for Wikilink pipe tricks in Obsidian.
TypeScript
21
star
13

grafana-calendar-panel

A Calendar panel plugin for Grafana
TypeScript
19
star
14

grafana-hexmap-panel

A Grafana panel plugin for hexagonal tiling of data.
TypeScript
18
star
15

grafana-ynab-datasource

Go
16
star
16

gouk16-slides

The slides from my presentation at GolangUK 2016
14
star
17

json-schema-docs

A simple JSON Schema to Markdown generator.
Go
14
star
18

obsidian-svelte

A Svelte component library for Obsidian. Experimental.
Svelte
13
star
19

dts-docs

A command-line tool for generating Markdown documentation from .d.ts.
TypeScript
12
star
20

grafana-static-datasource

A data source plugin for Grafana for static data.
TypeScript
10
star
21

obsidian-creature-theme

A dark, minimal Obsidian theme for night dwellers.
9
star
22

vscode-theme-enough

A minimal theme for Visual Studio Code.
Jsonnet
8
star
23

go-workshop

Go
7
star
24

serialized-go

Go client for the Serialized.io REST API
Go
4
star
25

freq

Display frequency distributions from the command-line.
Go
4
star
26

marcusolsson

3
star
27

terraform-provider-serialized

Terraform Provider for Serialized.IO
Go
3
star
28

dotfiles

My config files
Vim Script
3
star
29

go-workshop-exercises

Exercises for go-workshop
Go
3
star
30

grafana-plugin-support

Helpers for Grafana plugin development
TypeScript
3
star
31

focus

Subscribe to window focus events.
Go
2
star
32

obsidian-instant-coffee

TypeScript
1
star
33

passtray

systray for the UNIX password manager
Go
1
star
34

obsidian-projects-sample-view

TypeScript
1
star
35

marcusolsson.github.io

HTML
1
star
36

gointro

Parse datsets from the DAT-o-MATIC.
Go
1
star