{"id":51840296,"url":"https://github.com/youknow2509/temp-go-ddd","last_synced_at":"2026-07-23T04:01:13.723Z","repository":{"id":367369522,"uuid":"1171854492","full_name":"Youknow2509/temp-go-ddd","owner":"Youknow2509","description":"Go template project built with DDD architecture.  The project is structured into Domain, Application, Infrastructure, and Presentation layers to ensure clear separation of concerns, scalability, and maintainability.  Designed for Go applications with complex business logic and long-term development needs.","archived":false,"fork":false,"pushed_at":"2026-06-25T16:59:40.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-25T18:24:15.414Z","etag":null,"topics":["ddd","ddd-architecture","ddd-example","go","golang","golang-examples","project"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Youknow2509.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-03-03T17:21:36.000Z","updated_at":"2026-06-25T16:59:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Youknow2509/temp-go-ddd","commit_stats":null,"previous_names":["youknow2509/temp-go-ddd"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Youknow2509/temp-go-ddd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youknow2509%2Ftemp-go-ddd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youknow2509%2Ftemp-go-ddd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youknow2509%2Ftemp-go-ddd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youknow2509%2Ftemp-go-ddd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Youknow2509","download_url":"https://codeload.github.com/Youknow2509/temp-go-ddd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youknow2509%2Ftemp-go-ddd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35787351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-23T02:00:06.683Z","response_time":57,"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":["ddd","ddd-architecture","ddd-example","go","golang","golang-examples","project"],"created_at":"2026-07-23T04:01:12.617Z","updated_at":"2026-07-23T04:01:13.708Z","avatar_url":"https://github.com/Youknow2509.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# temp-go-ddd\n\nEnglish | [Tiếng Việt](README.vi.md)\n\n## Contact\n\n- **Mail**: *lytranvinh.work@gmail.com*\n- **Github**: *https://github.com/Youknow2509*\n\n## Overview\n\nThis repository is a Go Domain-Driven Design (DDD) template. It is not a complete product, but a practical starter structure that you can extend for your own service.\n\n## About this template\n\nThis template focuses on a clean DDD skeleton for Go backends: clear layer boundaries, centralized bootstrap, and extension points for business code.\n\n### 1) Current project structure\n\n```text\n.\n├── .github/\n│   └── workflows/\n│       └── ci.yml\n├── cmd/\n│   └── server/\n│       └── main.go\n├── .dockerignore\n├── Dockerfile\n├── config/\n│   ├── config_default.yaml\n│   └── config.yaml\n├── docs/\n├── environment/\n│   ├── .env.dev\n│   ├── docker-compose-dev.yml\n│   └── docker-compose.yml\n├── internal/\n│   ├── application/\n│   ├── constant/\n│   │   ├── config.go\n│   │   ├── logger.go\n│   │   └── system.go\n│   ├── domain/\n│   │   ├── cache/\n│   │   │   └── cache_domain.go\n│   │   ├── config/\n│   │   │   └── config_domain.go\n│   │   ├── logger/\n│   │   │   └── logger_domain.go\n│   │   ├── model/\n│   │   │   ├── config_model.go\n│   │   │   └── logger_model.go\n│   │   └── repository/\n│   ├── global/\n│   │   └── global.go\n│   ├── infrastructure/\n│   ├── initialize/\n│   │   ├── initialize.go\n│   │   ├── initialize_config.go\n│   │   └── initialize_logger.go\n│   ├── interface/\n│   └── shared/\n├── pkg/\n│   ├── config/\n│   │   └── viper.go\n│   └── logger/\n│       └── zap.go\n├── proto/\n├── tests/\n├── Makefile\n└── go.mod\n```\n\n### 2) Folder responsibilities\n\n- `cmd/`: service entrypoint. `cmd/server/main.go` handles bootstrap and runtime lifecycle.\n- `internal/domain/`: domain contracts and models shared across the system.\n    - `domain/config`, `domain/logger`, `domain/cache`: port interfaces.\n    - `domain/model`: domain-level data structures such as `SystemConfig`, `LoggerSetting`.\n- `pkg/`: adapter implementations for domain ports.\n    - `pkg/config/viper.go`: YAML config loading and merging.\n    - `pkg/logger/zap.go`: logger implementation using Zap + lumberjack.\n- `internal/initialize/`: system bootstrap wiring (config, logger, and future dependencies).\n- `internal/global/`: shared runtime singletons/state (logger, config, waitgroup).\n- `internal/application/`: application use cases/services (currently a scaffold).\n- `internal/infrastructure/`: infrastructure adapters for DB/message broker/external cache (scaffold).\n- `internal/interface/`: transport layer (HTTP/gRPC handlers, routing, DTO mapping) (scaffold).\n- `internal/shared/`: internal shared utilities.\n- `config/`: default and override configuration files.\n- `environment/`: compose files and sample env for local/dev.\n- `tests/`: unit and integration tests.\n\n### 3) Container and CI files\n\n- `Dockerfile`: multi-stage Docker build with a minimal `scratch` runtime image.\n- `.dockerignore`: excludes unnecessary files from Docker build context.\n- `.github/workflows/ci.yml`: basic CI pipeline for Go build and Docker build checks.\n\n## How to use this template\n\n1. Clone the repository.\n\n```bash\ngit clone https://github.com/Youknow2509/temp-go-ddd.git\n```\n\n2. Update system name in `Makefile`.\n\n```makefile\nSYSTEM_NAME = ABCD\n```\n\n3. Prepare config and environment variables.\n\n- Create `config/config.yaml` to override values from `config/config_default.yaml`.\n- Create `.env` from `environment/.env.dev` and adjust values.\n\n4. View available Make targets.\n\n```bash\nmake help\n```\n\n5. Start implementing your business code.\n\n## Build and Docker\n\n### Local build\n\n```bash\nmake build\n```\n\n### Docker build (Buildx)\n\n```bash\nmake docker_build\n```\n\nNotes:\n\n- Docker image build uses `docker buildx build` with `--load` for local usage.\n- The runtime image is `scratch` (no OS packages) for minimal size.\n- TLS CA certificates are copied into runtime image so HTTPS/TLS calls still work.\n\n## CI/CD (basic)\n\nGitHub Actions workflow at `.github/workflows/ci.yml` runs on push and pull request:\n\n1. `go build ./...` (compile check)\n2. Docker image build check using Buildx\n\nThis is a basic quality gate to ensure the project can be built successfully.\n\n## DDD - Domain-Driven Design\n\nThis template follows a layered DDD style with ports/adapters.\n\n### 1) Layers in this template\n\n- **Domain layer (`internal/domain`)**\n    - Contains pure business contracts and models.\n    - Does not depend on framework-specific code.\n    - Example interfaces: `IConfig`, `ILogger`, `IDistributedCache`, `ILocalCache`.\n\n- **Application layer (`internal/application`)**\n    - Orchestrates use cases and business workflows.\n    - Depends on domain interfaces, not concrete implementations.\n    - Currently scaffolded for your project-specific logic.\n\n- **Infrastructure layer (`internal/infrastructure`, `pkg`)**\n    - Implements domain ports.\n    - Existing examples: `ViperConfig` (config adapter), `ZapLogger` (logger adapter).\n\n- **Interface layer (`internal/interface`)**\n    - Exposes system entry points (HTTP, gRPC, event consumers).\n    - Maps transport data to application commands/queries.\n\n### 2) Current startup flow\n\n1. `cmd/server/main.go` initializes global `WaitGroup`.\n2. Calls `initialize.Initialize()`.\n3. `initializeConfig()`:\n    - Creates config adapter via `pkg/config.NewViperConfig()`.\n    - Loads `config/config_default.yaml`.\n    - Loads and deep-merges `config/config.yaml` when present.\n    - Stores result in `global.SystemConfig`.\n4. `initializeLogger()`:\n    - Builds `LoggerConfigPkg` from `global.SystemConfig`.\n    - Creates logger with `pkg/logger.NewZapLogger(...)`.\n    - Stores logger in `global.Logger`.\n5. `main` blocks on `global.WaitGroup.Wait()`.\n\n### 3) Dependency direction\n\n- `interface` -\u003e `application` -\u003e `domain`\n- `infrastructure/pkg` implement domain interfaces\n- `domain` does not import `application/interface/infrastructure`\n\nThis keeps business rules stable and allows replacing adapters (logger/config/cache/DB) with minimal impact on core logic.\n\n### 4) How to extend\n\n- Add bounded contexts under `internal/domain` and matching use cases in `internal/application`.\n- Define repository ports in `internal/domain/repository`.\n- Implement repositories/adapters in `internal/infrastructure`.\n- Expose use cases via `internal/interface`.\n- Wire dependencies in `internal/initialize`.\n\nThe main goal is a clean domain with technical details (framework, I/O, infra) isolated outside business core.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouknow2509%2Ftemp-go-ddd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyouknow2509%2Ftemp-go-ddd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouknow2509%2Ftemp-go-ddd/lists"}