{"id":13806885,"url":"https://github.com/sebajax/go-vertical-slice-architecture","last_synced_at":"2026-03-10T09:39:57.148Z","repository":{"id":219971114,"uuid":"748845582","full_name":"sebajax/go-vertical-slice-architecture","owner":"sebajax","description":"go-vertical-slice-architecture","archived":false,"fork":false,"pushed_at":"2024-02-25T02:43:19.000Z","size":621,"stargazers_count":45,"open_issues_count":8,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-18T11:33:54.160Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebajax.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}},"created_at":"2024-01-26T21:34:30.000Z","updated_at":"2025-12-14T17:43:11.000Z","dependencies_parsed_at":"2024-02-25T03:38:34.780Z","dependency_job_id":null,"html_url":"https://github.com/sebajax/go-vertical-slice-architecture","commit_stats":null,"previous_names":["sebajax/go-architecture-angrycoders","sebajax/go-vertical-slice-architecture"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sebajax/go-vertical-slice-architecture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebajax%2Fgo-vertical-slice-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebajax%2Fgo-vertical-slice-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebajax%2Fgo-vertical-slice-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebajax%2Fgo-vertical-slice-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebajax","download_url":"https://codeload.github.com/sebajax/go-vertical-slice-architecture/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebajax%2Fgo-vertical-slice-architecture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30328891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"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":[],"created_at":"2024-08-04T01:01:17.515Z","updated_at":"2026-03-10T09:39:57.118Z","avatar_url":"https://github.com/sebajax.png","language":"Go","funding_links":[],"categories":["🚧 Boilerplates"],"sub_categories":["🌱 Third Party"],"readme":"\u003cimg src=\"https://img.shields.io/badge/Go-00ADD8?style=for-the-badge\u0026logo=go\u0026logoColor=white\" /\u003e\n\n\u003ch1 align='center'\u003e\n    ⚡ go-vertical-slice-architecture\n\u003c/h1\u003e\n\nThis structure, created following the development guide's for vertical slice architecture, will help to isolate the dependencies, make development easier and have a cleaner and testable code in every package.\n\n## 👩‍💻 Authors\n\n#### Sebastián Ituarte\n\n- [@sebajax](https://www.github.com/sebajax)\n\n#### Luis Fernando Miranda\n\n- [@Abraxas-365](https://www.github.com/Abraxas-365)\n\n## 🖍 Vertical slice architecture\n\nVertical slice architecture is an approach to software development where code and functionality are organized around individual features or user stories, encompassing all layers of the application from user interface to data access, promoting autonomy, reduced dependencies, and iterative development.\n\n![alt text](./image/vertical-slice-architecture.png)\n\n## 📚 Code Structure\n\n![alt text](./image/go-vertical-slice-architecture.png)\n\nA brief description of the layout:\n\n- `.github` has two template files for creating PR and issue. Please see the files for more details.\n- `.gitignore` varies per project, but all projects need to ignore `bin` directory.\n- `.golangci.yml` is the golangci-lint config file.\n- `Makefile` is used to build the project. **You need to tweak the variables based on your project**.\n- `CHANGELOG.md` contains auto-generated changelog information.\n- `OWNERS` contains owners of the project.\n- `README.md` is a detailed description of the project.\n- `cmd` contains the main.go file that is our starting point to execute\n- `pkg` places most of project business logic.\n- `migrations` contains all vendored code.\n- `internal` contains all the api logic.\n\n## 🚀 Stack\n\n#### Programming language [Go](https://go.dev/)\n\n#### Framework [Fiber](https://docs.gofiber.io/)\n\n#### Dependency injection [Uber dig](https://github.com/uber-go/dig)\n\n#### Database [Postgre SQL](https://www.postgresql.org/)\n\n#### Container [Docker](https://www.docker.com/)\n\n#### Live reload [Air](https://github.com/cosmtrek/air)\n\n## 🧐 This app uses conventional commits\n\n[Conventional commits url](https://www.conventionalcommits.org/en/v1.0.0/)\n\n## 🤜 How to create a new use case (Example)\n\n```http\n  POST /api/product\n```\n\n| Parameter  | Type     | Description                              |\n| :--------- | :------- | :--------------------------------------- |\n| `name`     | `string` | **Required**. Product Name               |\n| `sku`      | `string` | **Required**. Product Sku must be Unique |\n| `category` | `string` | **Required**. Product Category           |\n| `price`    | `float`  | **Required**. Product Price              |\n\n### Internal folder structure for a new domain all folders and files go in internal/product/\n\n```tree\n├───internal\n│   ├───product\n│   │   │   port.go\n│   │   │   product.go\n│   │   │\n│   │   ├───handler\n│   │   │       createProduct.go\n│   │   │       handler.go\n│   │   │\n│   │   ├───infrastructure\n│   │   │       productRepository.go\n│   │   │\n│   │   ├───mock\n│   │   │       mockProductRepository.go\n│   │   │\n│   │   └───service\n│   │           createProduct.go\n│   │           service.go\n```\n\n#### 1 - Create product.go (domain)\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/d4501917930ef2263551bee3ee529de49b6d6fc5/internal/product/product.go#L1-L58\n\n#### 2 - Create infrastructure/productRepository.go (DB query)\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/infrastructure/productRepository.go#L1-L61\n\n```tree\n├───internal\n│   ├───product\n│   │   ├───infrastructure\n│   │   │       productRepository.go\n```\n\n#### 3 - Create port.go (dp injection for the service)\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/port.go#L1-L7\n\n#### 4 - Create service/createProduct.go (create a new product use case implementation)\n\n```tree\n├───internal\n│   ├───product\n│   │   └───service\n│   │           createProduct.go\n│   │           service.go\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/service/createProduct.go#L1-L51\n\n#### 5 - Create service/service.go (dependency injection service using uber dig)\n\n```tree\n├───internal\n│   ├───product\n│   │   └───service\n│   │           createProduct.go\n│   │           service.go\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/service/service.go#L1-L42\n\n#### 6 - Create handler/createProduct.go (create a new hanlder presenter to call the use case)\n\n```tree\n├───internal\n│   ├───product\n│   │   ├───handler\n│   │   │       createProduct.go\n│   │   │       handler.go\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/handler/createProduct.go#L1-L60\n\n#### 7 - Create handler/handler.go (handles all the routes for all the presenters)\n\n```tree\n├───internal\n│   ├───product\n│   │   ├───handler\n│   │   │       createProduct.go\n│   │   │       handler.go\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/872df7def565c7e0a95216b0b93d8166c3912ef5/internal/product/handler/handler.go#L1-L11\n\n#### 8 - Create mock/ProductRepository.go (mocks the user repository implementation for unit testing)\n\n```tree\n├───internal\n│   ├───product\n│   │   ├───mock\n│   │   │       mockProductRepository.go\n```\n\n```bash\n    # It uses mockery Run\n        mockery\n```\n\n#### 9 - Create service/createProduct_test.go (create a unit test for the service)\n\n```tree\n├───internal\n│   ├───product\n│   │   └───service\n│   │           createProduct.go\n│   │           service.go\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/9ff7ae658ee5bada18b88ec4a03994a105ccbe02/internal/product/service/createProduct_test.go#L1-L97\n\n#### 10 - Add dependency injection service using uber dig\n\n```tree\n├───pkg\n│   ├───injection\n```\n\nhttps://github.com/sebajax/go-vertical-slice-architecture/blob/eb79ccae805d23b6f77385a5f7ebfc81bb6174e0/pkg/injection/injection.go#L1-L73\n\n## ⚙️ Usage without Make\n\n### Docker usage\n\n```bash\n    # Build server\n        docker-compose -p go-vertical-slice-architecture build\n\n    # Start server\n        docker-compose up -d\n\n    # Stop server\n        docker-compose down\n```\n\n### Standalone usage\n\n```bash\n    # Live reload\n        air\n```\n\n### Testing\n\n```bash\n    # To run unit testing\n        go test ./...\n\n    # To run unit testing coverage\n        go test -cover ./...\n```\n\n### Formatting, Linting and Vetting\n\n```bash\n    # Clean dependencies\n        go mod tidy\n\n    # Run formating\n        go fmt ./...\n\n    # Remove unused imports\n        goimports -l -w .\n\n    # Run linting\n        golangci-lint run ./...\n\n    # Run vetting\n        go vet ./...\n\n    # Run shadow to check shadowed variables\n        # Install shadow\n        go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest\n        # Run shadow\n        shadow ./...\n```\n\n### Database migration script\n\n```bash\n    # Create the script\n        migrate create -ext sql -dir /migrations -seq [script_name]\n    # Run the script\n        migrate -database ${POSTGRESQL_URL} -path /migrations up\n\n    # It will run automatically when the database initializes\n```\n\n## ⚙️ Usage with Make\n\n### Docker usage\n\n```bash\n    # Build server\n        make build-server\n\n    # Start server\n        make start-server\n\n    # Stop server\n        make stop-server\n```\n\n### Standalone usage\n\n```bash\n    # Live reload\n        make live-reload\n```\n\n### Testing\n\n```bash\n    # To run unit testing\n        make test\n\n    # To run unit testing coverage\n        make test-coverage\n```\n\n### Formatting, Linting and Vetting\n\n```bash\n    # Clean dependencies\n        make clean-deps\n\n    # Run formating\n        make format\n\n    # Remove unused imports\n        make clean-imports\n\n    # Run linting\n        make lint\n\n    # Run vetting\n        make vet\n\n    # Run shadow to check shadowed variables\n        # Install shadow\n        go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest\n        # Run shadow\n        make check-shadow\n\n    # Run vetting to lint, format and vet your once\n        make lint-format\n```\n\n### Database migration script\n\n```bash\n    # Create the script (replace your_script_name with the actual name)\n        make migrate-create name=your_script_name\n    # Run the script\n        make migrate-up\n\n    # It will run automatically when the database initializes\n```\n\n## 💻 Environment variables\n\nTo modify/add configuration via environment variables, use the `.env` file, which contains basic app configuration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebajax%2Fgo-vertical-slice-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebajax%2Fgo-vertical-slice-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebajax%2Fgo-vertical-slice-architecture/lists"}