# How We Implemented Domain-Driven Development in Golang

[Grab](https://yomu.fyi/company/grab) · Kapil Chaurasia · Nov 21, 2019

**Type:** Problem & solution

## Summary

Building GrabPlatform's partner integration self-service portal initially resulted in an unstructured codebase where individual files exceeded 500 lines and lacked proper segregation. Modifying existing functions carried high risks of breaking functionality across imported source collections. To resolve this, the team restructured the Go application using Domain-Driven Design principles in coordination with product domain experts. They mapped business rules into bounded contexts, identified entities and aggregate roots, introduced repository interfaces, and utilized domain events for cross-context communication. The refactoring distributed core functionality evenly, simplified onboarding, and aligned technical terminology with business concepts.

## Context

Building a self-service partner integration portal led to an unstructured Go codebase with 500+ line files and poor responsibility segregation, making changes risky.

## Approach / What changed

Applied Domain-Driven Design and idiomatic Go by gathering business knowledge from domain experts, breaking requirements into bounded contexts, defining entities and aggregate roots, wrapping storage logic in repository interfaces, and using domain events for cross-context data propagation.

## Takeaways

- Project serves as an aggregate root because dependent mapping entities like DeveloperProjectDAO and ProductProjectDAO cannot exist without it.
- Domain events allow bounded contexts to propagate updates and fetch full domain attributes without creating direct entity dependencies.
- Starting with database schemas rather than domain expert collaboration risks producing an anemic domain model based on relational data rather than business functionality.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Go](https://yomu.fyi/topic/go), [Refactoring](https://yomu.fyi/topic/refactoring)

[Read original post](https://engineering.grab.com/domain-driven-development-in-golang)
