diff --git a/README.md b/README.md index 406480e..5aa1418 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,10 @@ Go Climb follows the group-by-layer structure: │   │   ├── crag.go │   │   ├── mock_repository.go │   │   └── repository.go -│   ├── inputports +│   ├── infra │   │   ├── http │   │   │   ├── crag │   │   │   └── server.go -│   │   └── sevices.go -│   ├── outputadapters │   │   ├── notification │   │   │   └── console │   │   ├── services.go @@ -72,8 +70,6 @@ Go Climb follows the group-by-layer structure: - `docs` contains documentation about the application - `internal` contains the main implementation of our application. It consists of the three layers of clean architecture + shared utility code under `pkg/` - infra - - outputadapters - - inputports - app - domain - pkg diff --git a/cmd/main.go b/cmd/main.go index 065737f..9e28cd5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,17 +3,16 @@ package main import ( "github.com/pkritiotis/go-climb-clean-architecture-example/internal/app" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/inputports" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters" + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra" "github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/time" "github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid" ) func main() { - interfaceAdapterServices := interfaceadapters.NewServices() + infraProviders := infra.NewInfraProviders() tp := time.NewTimeProvider() up := uuid.NewUUIDProvider() - appServices := app.NewServices(interfaceAdapterServices.CragRepository, interfaceAdapterServices.NotificationService, up, tp) - inputPortsServices := inputports.NewServices(appServices) - inputPortsServices.Server.ListenAndServe(":8080") + appServices := app.NewServices(infraProviders.CragRepository, infraProviders.NotificationService, up, tp) + infraHTTPServer := infra.NewHTTPServer(appServices) + infraHTTPServer.ListenAndServe(":8080") } diff --git a/docs/CleanArchitecture.drawio b/docs/CleanArchitecture.drawio deleted file mode 100644 index 5c82cbf..0000000 --- a/docs/CleanArchitecture.drawio +++ /dev/null @@ -1 +0,0 @@ -7Vtre5o8GP41fqwXBMLho/XQubbb3vXa1W5fdkWJyoaE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m7KxqMuKOCKCG/Cxj2qqHLXohphQG8N+0YH1XrjOF01p4Uyvy8uMmsI16AvbNAcsYhsELsUnnp4/8HYvUhhdwB3VGG5/4IpViin2oPMH10MWU9pLNFtxaXt9tfjCq+ERG1xIH13XCSI21dEaBkxouXhjt8fKPLB2i5xFJPXGRc++VQwboSBPPgcvZLpD3KW8eNbtREXc3J1Ru2X9Fii8dyhSVXhTUD0URfHh1SKELQjjDXEdn0KUHpaVTgD7oeAKNLmIvz3CXj1xmfGggLte46/V3mAX095Pu8VfH/eCbe0objYKQTvGywTOj8tMAK27VQzyVQJ/inSCIRgaiqypQFdUWZclU/9feAKgGRVnL49EUqjGsO6U3yl4cfXu/ZvZZXQ5nis3XxffZj/fL7ya89Q+Js5tvOyjuLLVmo+2g2c7qVR/8KB5cd/frmnLrmhb1b1p1/Rw6h2za1rLga6ldU7kN9IQmDrv9MTDVJpRNQpVy07ttR2n6ukAX9McFezkM7OTbDGzN3i+ktqBXq37d16CnCKT+RJNwocPk91s/N3f4kdreT+9zMzgaHdUmu0zVvxduETuOIuRxeAUf7rEvLwWWhfzxCqpuAnQ4ejm8f6oFjBJ9EeNKer59/pqH1sRTP90lfS+KNhWVu+Nglm1/EAK9k+1J4W+nk/hSZVVYvn8T6s+UJv19Ur9qKL/5EJ7EwQ168wkcr7eM0VK5R8RQE2ef6IqO23m/8+ZIJf/VyyY/Qc= \ No newline at end of file diff --git a/internal/inputports/http/crag/handler.go b/internal/infra/http/crag/handler.go similarity index 100% rename from internal/inputports/http/crag/handler.go rename to internal/infra/http/crag/handler.go diff --git a/internal/inputports/http/crag/handler_test.go b/internal/infra/http/crag/handler_test.go similarity index 100% rename from internal/inputports/http/crag/handler_test.go rename to internal/infra/http/crag/handler_test.go diff --git a/internal/inputports/http/server.go b/internal/infra/http/server.go similarity index 98% rename from internal/inputports/http/server.go rename to internal/infra/http/server.go index 7891b27..055733d 100644 --- a/internal/inputports/http/server.go +++ b/internal/infra/http/server.go @@ -8,7 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/pkritiotis/go-climb-clean-architecture-example/internal/app" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/inputports/http/crag" + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/http/crag" ) // Server Represents the http server running for this service diff --git a/internal/interfaceadapters/notification/console/notificationservice.go b/internal/infra/notification/console/notificationservice.go similarity index 100% rename from internal/interfaceadapters/notification/console/notificationservice.go rename to internal/infra/notification/console/notificationservice.go diff --git a/internal/interfaceadapters/notification/console/notificationservice_test.go b/internal/infra/notification/console/notificationservice_test.go similarity index 100% rename from internal/interfaceadapters/notification/console/notificationservice_test.go rename to internal/infra/notification/console/notificationservice_test.go diff --git a/internal/interfaceadapters/services.go b/internal/infra/services.go similarity index 51% rename from internal/interfaceadapters/services.go rename to internal/infra/services.go index 304ecb6..20bfc93 100644 --- a/internal/interfaceadapters/services.go +++ b/internal/infra/services.go @@ -1,23 +1,31 @@ -// Package interfaceadapters contains the services of the interface adapters -package interfaceadapters +// Package infra contains the services of the interface adapters +package infra import ( + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/app" "github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/notification" "github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters/notification/console" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters/storage/memory" + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/http" + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/notification/console" + "github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/storage/memory" ) // Services contains the exposed services of interface adapters type Services struct { NotificationService notification.Service CragRepository crag.Repository + Server *http.Server } -// NewServices Instantiates the interface adapter services -func NewServices() Services { +// NewInfraProviders Instantiates the infra services +func NewInfraProviders() Services { return Services{ NotificationService: console.NewNotificationService(), CragRepository: memory.NewRepo(), } } + +// NewHTTPServer creates a new server +func NewHTTPServer(appServices app.Services) *http.Server { + return http.NewServer(appServices) +} diff --git a/internal/interfaceadapters/storage/memory/repo.go b/internal/infra/storage/memory/repo.go similarity index 100% rename from internal/interfaceadapters/storage/memory/repo.go rename to internal/infra/storage/memory/repo.go diff --git a/internal/interfaceadapters/storage/memory/repo_test.go b/internal/infra/storage/memory/repo_test.go similarity index 100% rename from internal/interfaceadapters/storage/memory/repo_test.go rename to internal/infra/storage/memory/repo_test.go diff --git a/internal/interfaceadapters/storage/mysql/repo.go b/internal/infra/storage/mysql/repo.go similarity index 100% rename from internal/interfaceadapters/storage/mysql/repo.go rename to internal/infra/storage/mysql/repo.go diff --git a/internal/inputports/sevices.go b/internal/inputports/sevices.go deleted file mode 100644 index d868425..0000000 --- a/internal/inputports/sevices.go +++ /dev/null @@ -1,17 +0,0 @@ -// Package inputports contains the services of the input ports -package inputports - -import ( - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/app" - "github.com/pkritiotis/go-climb-clean-architecture-example/internal/inputports/http" -) - -// Services contains the ports services -type Services struct { - Server *http.Server -} - -// NewServices instantiates the services of input ports -func NewServices(appServices app.Services) Services { - return Services{Server: http.NewServer(appServices)} -}