Skip to content

Delgerskhn/gosetup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Architecture

Clean Architecture is a software design pattern that separates the concerns of an application into different layers, each with a specific responsibility. It is based on the SOLID principles and helps to create maintainable, testable, and scalable software.

The following is an example of how to implement the Clean Architecture pattern in a Go web application.

config package

This package contains the application's configuration.

  • init.go: This file contains the code to read the configuration from a file or environment variables and make it available to the rest of the application.

pkg package

This package contains the different layers of the application.

presentation package

This package contains the components that handle the presentation logic of the application.

  • routes package: This package contains the routing logic for the application.
    • books.go: This file defines the routes for the books endpoints.
    • index.go: This file defines the routes for the index endpoint.
  • middlewares package: This package contains the middleware logic for the application.
    • validation.go: This file contains the validation middleware that is used to validate the requests.

domain package

This package contains the components that handle the domain logic of the application.

  • entities package: This package contains the structs that represent the entities in the domain.
    • book.go: This file defines the Book struct.
  • gorm package: This package contains the gorm models that map the domain entities to the database.
    • book.go: This file defines the Book gorm model.

application package

This package contains the components that handle the application logic of the application.

  • book package: This package contains the components related to the book feature.
    • inputs.go: This file defines the inputs to the book feature.
    • service.go: This file defines the services of the book feature.
    • controller.go: This file defines the controller of the book feature.

infrastructure package

This package contains the components that handle the infrastructure logic of the application.

  • persistence package: This package contains the components that handle the persistence logic of the application.
    • repository package: This package contains the interfaces and implementations of the repositories.
      • repository.go: This file defines the interface for the repositories.
    • specification package: This package contains the interfaces and implementations of the specifications.
      • specification.go: This file defines the interface for the specifications.
    • db.go: This file contains the code to initialize the database connection.
  • middlewares package: This package contains the middleware logic for the application.
    • auth.go: This file contains the implementation of the authentication middleware.

main.go

This file contains the entry point of the application, where the server is started and the routes are registered.

This is just an example of a possible folder structure for a web application using Clean Architecture. You can adjust it according to your needs, but it's important to keep the separation of concerns and follow the SOLID principles.

About

Go, fiber, gorm boilerplate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages