{"id":13416733,"url":"https://github.com/bxcodec/go-clean-arch","last_synced_at":"2025-04-28T15:40:53.815Z","repository":{"id":37773845,"uuid":"93808874","full_name":"bxcodec/go-clean-arch","owner":"bxcodec","description":"Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture","archived":false,"fork":false,"pushed_at":"2024-04-24T04:15:38.000Z","size":381,"stargazers_count":9484,"open_issues_count":34,"forks_count":1260,"subscribers_count":140,"default_branch":"master","last_synced_at":"2025-04-09T19:15:09.700Z","etag":null,"topics":["architecture","article","clean-architecture","database","go","golang","mysql","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bxcodec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["bxcodec"]}},"created_at":"2017-06-09T02:04:22.000Z","updated_at":"2025-04-09T14:40:37.000Z","dependencies_parsed_at":"2022-07-09T19:00:51.302Z","dependency_job_id":"bb605bac-84ec-482e-a46c-32a86f228d33","html_url":"https://github.com/bxcodec/go-clean-arch","commit_stats":{"total_commits":65,"total_committers":10,"mean_commits":6.5,"dds":0.6461538461538461,"last_synced_commit":"d5d2bac0a4405ae2b651def6642c138794a6d42a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxcodec%2Fgo-clean-arch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxcodec%2Fgo-clean-arch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxcodec%2Fgo-clean-arch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxcodec%2Fgo-clean-arch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bxcodec","download_url":"https://codeload.github.com/bxcodec/go-clean-arch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251340485,"owners_count":21573913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["architecture","article","clean-architecture","database","go","golang","mysql","sql"],"created_at":"2024-07-30T22:00:21.015Z","updated_at":"2025-04-28T15:40:53.777Z","avatar_url":"https://github.com/bxcodec.png","language":"Go","readme":"# go-clean-arch\n\n## Changelog\n\n- **v1**: checkout to the [v1 branch](https://github.com/bxcodec/go-clean-arch/tree/v1) \u003cbr\u003e\n  Proposed on 2017, archived to v1 branch on 2018 \u003cbr\u003e\n  Desc: Initial proposal by me. The story can be read here: https://medium.com/@imantumorang/golang-clean-archithecture-efd6d7c43047\n\n- **v2**: checkout to the [v2 branch](https://github.com/bxcodec/go-clean-arch/tree/v2) \u003cbr\u003e\n  Proposed on 2018, archived to v2 branch on 2020 \u003cbr\u003e\n  Desc: Improvement from v1. The story can be read here: https://medium.com/@imantumorang/trying-clean-architecture-on-golang-2-44d615bf8fdf\n\n- **v3**: checkout to the [v3 branch](https://github.com/bxcodec/go-clean-arch/tree/v3) \u003cbr\u003e\n  Proposed on 2019, merged to master on 2020. \u003cbr\u003e\n  Desc: Introducing Domain package, the details can be seen on this PR [#21](https://github.com/bxcodec/go-clean-arch/pull/21)\n\n- **v4**: master branch\n  Proposed on 2024, merged to master on 2024. \u003cbr\u003e\n  Desc:\n\n  - Declare Interfaces to the consuming side,\n  - Introduce `internal` package\n  - Introduce `Service-focused` package.\n\n  Details can be seen in this PR [#88](https://github.com/bxcodec/go-clean-arch/pull/88).\u003cbr\u003e\n\n\u003e ### Author's Note\n\u003e\n\u003e You may notice it diverges from the structures seen in previous versions. I encourage you to explore the branches for each version to select the structure that appeals to you the most. In my recent projects, the code structure has progressed to version 4. However, I do not strictly advocate for one version over another. You may encounter alternative examples on the internet that align more closely with your preferences. Rest assured, the foundational concept will remain consistent or at least bear resemblance. The differences are primarily in the arrangement of directories or the integration of advanced tools directly into the setup.\n\n## Description\n\nThis is an example of implementation of Clean Architecture in Go (Golang) projects.\n\nRule of Clean Architecture by Uncle Bob\n\n- Independent of Frameworks. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.\n- Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element.\n- Independent of UI. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.\n- Independent of Database. You can swap out Oracle or SQL Server, for Mongo, BigTable, CouchDB, or something else. Your business rules are not bound to the database.\n- Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.\n\nMore at https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html\n\nThis project has 4 Domain layer :\n\n- Models Layer\n- Repository Layer\n- Usecase Layer\n- Delivery Layer\n\n#### The diagram:\n\n![golang clean architecture](https://github.com/bxcodec/go-clean-arch/raw/master/clean-arch.png)\n\nThe original explanation about this project's structure can read from this medium's post : https://medium.com/@imantumorang/golang-clean-archithecture-efd6d7c43047.\nIt may be different already, but the concept still the same in application level, also you can see the change log from v1 to current version in Master.\n\n### How To Run This Project\n\n\u003e Make Sure you have run the article.sql in your mysql\n\nSince the project is already use Go Module, I recommend to put the source code in any folder but GOPATH.\n\n#### Run the Testing\n\n```bash\n$ make tests\n```\n\n#### Run the Applications\n\nHere is the steps to run it with `docker-compose`\n\n```bash\n#move to directory\n$ cd workspace\n\n# Clone into your workspace\n$ git clone https://github.com/bxcodec/go-clean-arch.git\n\n#move to project\n$ cd go-clean-arch\n\n# copy the example.env to .env\n$ cp example.env .env\n\n# Run the application\n$ make up\n\n# The hot reload will running\n\n# Execute the call in another terminal\n$ curl localhost:9090/articles\n```\n\n### Tools Used:\n\nIn this project, I use some tools listed below. But you can use any similar library that have the same purposes. But, well, different library will have different implementation type. Just be creative and use anything that you really need.\n\n- All libraries listed in [`go.mod`](https://github.com/bxcodec/go-clean-arch/blob/master/go.mod)\n- [\"github.com/vektra/mockery\".](https://github.com/vektra/mockery) To Generate Mocks for testing needs.\n","funding_links":["https://github.com/sponsors/bxcodec"],"categories":["Popular","开源类库","Go","Repositories","Open source library","后端开发框架及项目","💻 项目实战"],"sub_categories":["项目骨架","Project Skeleton","管理面板","💾 Redis"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbxcodec%2Fgo-clean-arch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbxcodec%2Fgo-clean-arch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbxcodec%2Fgo-clean-arch/lists"}