{"id":50672043,"url":"https://github.com/pascalallen/go-clean-arch","last_synced_at":"2026-06-08T12:04:07.725Z","repository":{"id":359222921,"uuid":"1245085574","full_name":"pascalallen/go-clean-arch","owner":"pascalallen","description":"A reference implementation of Clean Architecture in Go. This repository is the companion project for the Medium article Structuring Go Projects With Clean Architecture which can be found at https://medium.com/@pascalallen/structuring-go-projects-with-clean-architecture-2c46d7e58ac3","archived":false,"fork":false,"pushed_at":"2026-05-20T22:43:48.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T04:44:23.139Z","etag":null,"topics":[],"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/pascalallen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-20T22:34:29.000Z","updated_at":"2026-05-20T22:43:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pascalallen/go-clean-arch","commit_stats":null,"previous_names":["pascalallen/go-clean-arch"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pascalallen/go-clean-arch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalallen%2Fgo-clean-arch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalallen%2Fgo-clean-arch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalallen%2Fgo-clean-arch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalallen%2Fgo-clean-arch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pascalallen","download_url":"https://codeload.github.com/pascalallen/go-clean-arch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalallen%2Fgo-clean-arch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34061125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-06-08T12:04:05.432Z","updated_at":"2026-06-08T12:04:07.716Z","avatar_url":"https://github.com/pascalallen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-clean-arch\n\nA reference implementation of Clean Architecture in Go. This repository is the companion project for the Medium article [*Structuring Go Projects With Clean Architecture*](https://medium.com/@pascalallen/structuring-go-projects-with-clean-architecture-2c46d7e58ac3).\n\n## Project Structure\n\n```\n├── bin/       # Helper scripts for common Docker commands\n├── cmd/       # Go main packages (entry points)\n├── docs/      # Documentation\n├── internal/  # All application code\n└── web/       # Frontend assets\n```\n\n## Architecture\n\nThe application code in `internal/` is organized around three layers:\n\n### Domain Layer\n\nContains the core business logic — entities, repository interfaces, and service interfaces. No framework dependencies.\n\n```\ninternal/app/domain/\n├── logger/\n├── pagination/\n├── password/\n├── permission/\n├── role/\n└── user/\n    ├── user.go        # User entity with behavior methods\n    └── repository.go  # Repository interface\n```\n\n### Application Layer\n\nOrchestrates the domain using CQRS and event-driven patterns.\n\n```\ninternal/app/application/\n├── command/           # Intent structs (RegisterUser, DeleteUser)\n├── command_handler/   # Command handlers\n├── event/             # Domain events (UserRegistered)\n├── listener/          # Event listeners\n├── query/             # Query structs (GetUserById, ListUsers)\n└── query_handler/     # Query handlers\n```\n\n### Infrastructure Layer\n\nConcrete implementations of domain interfaces.\n\n```\ninternal/app/infrastructure/\n├── container/    # Google Wire DI container\n├── database/     # Postgres session, migrations, seeders\n├── messaging/    # Command bus, event dispatcher, query bus\n├── repository/   # Postgres implementations\n├── routes/       # Gin HTTP router\n├── service/      # JWT token service\n└── websocket/    # WebSocket hub for real-time push updates\n```\n\n## Prerequisites\n\n- [Docker](https://www.docker.com/)\n- [Docker Compose](https://docs.docker.com/compose/)\n\n## Development Setup\n\n### Clone the repository\n\n```bash\ngit clone https://github.com/pascalallen/go-clean-arch.git \u0026\u0026 cd go-clean-arch\n```\n\n### Copy the environment file\n\n```bash\ncp .env.example .env\n```\n\n### Bring up the environment\n\n```bash\nbin/up\n```\n\nThe app will be running at [http://localhost:8080](http://localhost:8080).\n\n### Seed the database\n\n```bash\nbin/exec go run cmd/seed/seed.go\n```\n\n### Take down the environment\n\n```bash\nbin/down\n```\n\n## Testing\n\n```bash\ndocker compose exec go go test ./... -covermode=count -coverprofile=coverage.out\n```\n\n## API\n\n| Method | Endpoint                    | Description        |\n|--------|-----------------------------|--------------------|\n| POST   | `/api/v1/auth/register`    | Register a user    |\n| POST   | `/api/v1/auth/login`       | Log in             |\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascalallen%2Fgo-clean-arch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpascalallen%2Fgo-clean-arch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascalallen%2Fgo-clean-arch/lists"}