{"id":21553519,"url":"https://github.com/dinstone/doha-go","last_synced_at":"2026-01-27T13:02:23.474Z","repository":{"id":264323460,"uuid":"892918356","full_name":"dinstone/doha-go","owner":"dinstone","description":"DOHA is the abbreviation for \"Domain Oriented Hexagonal Architecture\", aimed at standardizing the code layering of microservices.","archived":false,"fork":false,"pushed_at":"2024-11-26T03:17:38.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-29T17:40:53.799Z","etag":null,"topics":["ddd","hexagonal-architecture"],"latest_commit_sha":null,"homepage":"","language":"Smarty","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinstone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-23T03:42:35.000Z","updated_at":"2024-11-26T03:17:41.000Z","dependencies_parsed_at":"2025-03-18T23:15:45.688Z","dependency_job_id":null,"html_url":"https://github.com/dinstone/doha-go","commit_stats":null,"previous_names":["dinstone/doha-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dinstone/doha-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fdoha-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fdoha-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fdoha-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fdoha-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinstone","download_url":"https://codeload.github.com/dinstone/doha-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fdoha-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd","hexagonal-architecture"],"created_at":"2024-11-24T07:11:04.850Z","updated_at":"2026-01-27T13:02:23.460Z","avatar_url":"https://github.com/dinstone.png","language":"Smarty","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DOHA (Domain-Oriented Hexagonal Architecture)\n\nDOHA (面向领域的六边形架构)的核心在于使用领域驱动设计（DDD）的思想来设计和组织业务逻辑，并结合六边形架构的端口适配器模式来实现业务逻辑与外部接口的分离，为构建健壮、可维护、可扩展的复杂应用系统提供了有力的支持。\n\n![六边形架构](https://static001.geekbang.org/infoq/2e/2e3e0acccfa5e96d9bef8e0a7090660d.png)\n\n2005 年，Alistair Cockburn 提出的六边形架构，将应用程序巧妙地划分为内部的业务逻辑层和外部的适配器层。内部聚焦于业务逻辑，而外部具有一个或多个入站适配器（而不是表示层），通过调用业务逻辑来处理来自外部的请求。同样，外部具有一个或多个出站适配器（而不是数据持久层），业务逻辑调用这些出站适配器来访问外部应用程序。\n\n为了解耦内部和外部之间的依赖，业务逻辑层抽象出端口来应对业务逻辑与外部的交互，这些端口实质上代表了一种协议，通常以接口 API 的形式呈现。\n\n六边形架构的一个重要好处是业务逻辑不依赖于表示层逻辑或数据访问层逻辑。它将业务逻辑与适配器中包含的表示层和数据访问层的逻辑分离开来。由于这种分离，单独测试业务逻辑就容易得多了。\n\n六边形架构的另一个好处是它是描述微服务架构中每个服务的架构的好方法。可以通过多个适配器调用业务逻辑，每个适配器实现特定的 API 或用户界面。业务逻辑还可以通过端口调用多个适配器，每个适配器调用不同的外部系统。\n\n六边形架构以业务为核心，解耦外部依赖，分离了业务复杂度和技术复杂度等。然而，六边形架构本身并不涉及内部业务逻辑的设计模式，因此在落地过程中，需要我们自己选择业务逻辑的设计模式。通常，对于简单应用可以选择面向事务脚本模式来组织业务逻辑，而对于复杂应用来说，面向领域建模模式是首选。\n\n## 逻辑架构\n\n![逻辑架构](https://static001.geekbang.org/infoq/b7/b73caea583c17dda18d1ac852da4926b.jpeg)\n\nDOHA 架构将应用细化为五个分层： Inbound Adapter 层、Inbound Port 层、Domain 层、Outbound Port 层、Outbound Adapter层。\n\n Inbound Adapter层和 Outbound Adapter层作为适配器层，依赖业务层（Inbound Port 层，Outbound Port 层和 Domain 层）。\n\n## 实现架构\n\n![实现架构](https://static001.geekbang.org/infoq/48/48c5573f89bb10f3fa2abe0db427d593.jpeg)\n\nDOHA 将工程分为：\n\n- doha-handler：应用程序入口，入站适配器实现都在这里，负责处理外部请求，依赖其它工程。\n\n- doha-interface：提供给第三方应用依赖的编程接口，如 RPC、Event、MQ 等，不依赖其它工程。\n\n- doha-invoker：出站适配器实现都在这里，负责调用外部系统，依赖 doha-business 工程。\n\n- doha-business：业务逻辑实现的地方，包括入站端口服务、领域模型、出站端口接口，不依赖其它工程。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinstone%2Fdoha-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinstone%2Fdoha-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinstone%2Fdoha-go/lists"}