{"id":34121363,"url":"https://github.com/amirzayi/clean_architect","last_synced_at":"2026-05-30T17:31:39.662Z","repository":{"id":220195520,"uuid":"750902259","full_name":"amirzayi/clean_architect","owner":"amirzayi","description":"my clean architecture go project template","archived":false,"fork":false,"pushed_at":"2026-05-17T20:06:17.000Z","size":279,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-17T22:29:56.711Z","etag":null,"topics":["clean-architecture","clean-code","cleanarchitecture","cleancode"],"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/amirzayi.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":"2024-01-31T14:52:14.000Z","updated_at":"2026-05-17T20:06:21.000Z","dependencies_parsed_at":"2024-02-12T21:30:28.428Z","dependency_job_id":"ad923e3a-c907-4943-9f25-8ae3f6e3d20e","html_url":"https://github.com/amirzayi/clean_architect","commit_stats":null,"previous_names":["amirmirzayi/clean_architecture","aamiruv/clean_architect","amirzayi/clean_architect"],"tags_count":6,"template":true,"template_full_name":null,"purl":"pkg:github/amirzayi/clean_architect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirzayi%2Fclean_architect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirzayi%2Fclean_architect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirzayi%2Fclean_architect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirzayi%2Fclean_architect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amirzayi","download_url":"https://codeload.github.com/amirzayi/clean_architect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirzayi%2Fclean_architect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33703065,"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-05-30T02:00:06.278Z","response_time":92,"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":["clean-architecture","clean-code","cleanarchitecture","cleancode"],"created_at":"2025-12-14T21:50:36.354Z","updated_at":"2026-05-30T17:31:39.657Z","avatar_url":"https://github.com/amirzayi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Clean Architecture Project\n\n## What is Clean Architecture?\n\nClean Architecture is a software design philosophy that emphasizes separation of concerns and independence of business logic from implementation details. It was popularized by Robert C. Martin (Uncle Bob) and organizes the system into concentric layers with the following key principles:\n\n1. **Independent of Frameworks**: The architecture doesn't depend on the existence of some library or framework\n2. **Testable**: Business rules can be tested without UI, database, web server, etc.\n3. **Independent of UI**: The UI can change easily without changing the rest of the system\n4. **Independent of Database**: You can swap out Oracle or SQL Server for MongoDB, etc.\n5. **Independent of any external agency**: Your business rules don't know anything about the outside world\n\n## Why Use Clean Architecture?\n\nClean Architecture provides several important benefits:\n\n- **High Cohesion**: Related functionality is kept close together in the same layer\n- **Low Coupling**: Layers communicate through well-defined interfaces, making components easily replaceable\n- **Maintainability**: Changes in one layer (like database) don't affect others\n- **Testability**: Business logic can be tested without infrastructure concerns\n- **Flexibility**: Easy to adapt to new requirements or technology changes\n\n## Project Structure\n\nThe project follows a typical Clean Architecture organization with these layers:\n\n```\nproject/\n├── api/\n│   ├── grpc/               # grpc service handlers\n│   ├── http/\n│   │   ├── handler/        # http handlers\n│   │   ├── middleware/     # http middlewares\n│   ├── proto/              # protobuf schema definition\n├── cmd/                    # Main application entry point and dependency injection\n│   ├── app/                # web application\n│   ├── cli/                # cli application\n├── internal/\n│   ├── delivery/           # Interface adapters (HTTP handlers, gRPC, etc.)\n│   ├── domain/             # Enterprise business rules\n│   ├── service/            # Application business rules\n│   ├── repository/         # Interface definitions for data access\n├── pkg/                    # Concrete implementation reusable libraries\n│   └── auth/               # identify user\n│   └── bus/                # message broker\n│   └── cache/              # cache\n│   └── config/             # app configuration\n│   └── errs/               # human readable internal error conversion\n│   └── hash/               # hashing password\n│   └── interceptor/        # grpc interceptors\n│   └── jsonutil/           # json utilities\n│   └── logger/             # log\n│   └── mongoutil/          # mongo utilities(paginate query builder,...)\n│   └── paginate/           # pagination, sorting, filter\n│   └── queue/              # queue\n│   └── scheduler/          # persistent task scheduler\n│   └── server/\n│   │   └── grpc/           # grpc server manager\n│   │   └── http/           # http server manager\n│   └── sqlutil/            # sql utilities(paginate query builder,...)\n│   └── synq/               # sync cache via crud operations\n\n```\n\n## Drivers and Plugins\n\nThis project supports multiple implementations (drivers) for various components:\n\n### Repository Drivers\n- **MongoDB**\n- **MySQL, Postgresql, Sqlite**\n- **In-memory**\n\n### Caching Drivers\n- **Redis**\n- **Memcached**\n- **In-Memory**\n\n### Message Broker Drivers\n- **RabbitMQ**\n- **Redis**\n- **In-Memory**\n- **Nats**\n\n### Task Scheduler\n- **Redis**\n- **MySQL, Postgresql, Sqlite**\n- **File**\n\n### Queue\n- **Redis**\n- **In-Memory**\n\n### Auth\n- **JWT**\n- **Paseto**\n\n### Logger\n- **File**\n- **External Web Service**\n\n### Pagination, Sorting, Filters\npaginate, sort, filter incoming list requests for sql and MongoDB\n\n### Error conversion\nconvert internal errors to human readable response\n\n## Getting Started\n\n### Prerequisites\n- Go 1.23+\n- Docker (for running some database/broker implementations)\n\n### Installation\n1. Clone the repository\n2. Install dependencies:\n   ```sh\n   go mod download\n   ```\n3. Copy the example config file and modify as needed:\n   ```sh\n   cp config.yaml.example config.yaml\n   ```\n\n## Run application\n### webserver\n```sh\ngo run ./cmd/app\n```\n### cli\n```sh\ngo run ./cmd/cli\n```\n\n## Configuration\n\nThe application is configured via `config.[yaml,json,toml]`. You can specify which drivers to use for each component:\n\n```yaml\ndb:\n  driver: \"mysql\" # or \"sqlite\", \"postgres\", \"mongodb\"\n  ip: 127.0.0.1\n  port: 3306\n  userName: amir\n  password: mirzaei\n  name: db\n\ncache:\n  driver: \"memcached\" # or \"redis\", \"inmemory\"\n  ip: 127.0.0.1\n  port: 11211\n  userName: amir\n  password: mirzaei\n  prefix: app\n\nevent:\n  driver: \"rabbitmq\" # or \"redis\", \"memory\", \"nats\"\n  ip: 127.0.0.1\n  port: 1567\n  userName: amir\n  password: mirzaei\n\nscheduler:\n  driver: redis # or \"sqlite\" or \"file\"\n  ip: 127.0.0.1\n  port: 6379\n  prefix: task_scheduler\n  userName: amir\n  password: mirzaei\n\nqueue:\n  driver: redis # or \"memory\"\n  ip: 127.0.0.1\n  port: 6379\n  prefix: task_scheduler\n  userName: amir\n  password: mirzaei\n\nlogger:\n  level: 0 # debug: -1, info: 0, warn: 1, error: 2\n  directory: log # store logs on specified directory\n  fileCreationMode: 1 # 0: won't store in files, 1: keep in single created file, 2: keep in seperated hourly created files, 3: keep in seperated daily created files\n  remoteURL: http://127.0.0.1:8080/ping # send logs to http address\n  console: true # print on stdout\n```\n\n## Testing\n\nTo run tests:\n```sh\ngo test ./...\n```\n\nThe architecture makes it easy to test components in isolation by using mock implementations of interfaces.\n\n## Dependency Injection\n\nThe application uses dependency injection to provide concrete implementations to the use cases. This is configured in `cmd/app/main.go` where you can switch between different drivers.\n\n## Contributing\n\nWhen adding new drivers or functionality:\n1. Define interfaces in the appropriate layer (repository, cache, etc.)\n2. Implement the interface in the driver package\n3. Register the new driver in the dependency injection setup\n\n## License\n\n[MIT License](LICENSE)\n### you need config.json file to run project. for example:\n```go run cmd/web/main.go -config=/path/to/config_file.json```\n\n### docker repository [url](https://hub.docker.com/r/92276992/clean_architect)\n\n#### you could run docker image easily via command for example:\n```sh\ndocker pull 92276992/clean_architect\ndocker run --rm -p 8070:8070 -p 8071:8071 -it --name my_container clean_architect:1.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirzayi%2Fclean_architect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirzayi%2Fclean_architect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirzayi%2Fclean_architect/lists"}