Skip to content

Folder Structure of the project

Tree of folder structure

bash
.
├── README.md
├── bootstrap
│   ├── app.go
│   └── module.go
├── console
│   ├── commands
│   │   ├── migration.go
│   │   ├── random.go
│   │   ├── seed.go
│   │   └── serve.go
│   └── console.go
├── docker
│   ├── custom.cnf
│   ├── db.Dockerfile
│   ├── run.sh
│   └── web.Dockerfile
├── docker-compose.yml
├── domain
│   ├── dtos
│   │   └── hello.dto.go
│   ├── hello
│   │   ├── hello.controller.go
│   │   ├── hello.module.go
│   │   ├── hello.repository.go
│   │   ├── hello.route.go
│   │   └── hello.service.go
│   ├── middlewares
│   │   └── module.go
│   ├── models
│   │   └── hello.model.go
│   └── module.go
├── go.mod
├── go.sum
├── main.go
├── migrations
│   ├── hello.go
│   ├── migrator.go
│   └── module.go
├── pkg
│   ├── framework
│   │   ├── command.go
│   │   ├── constants.go
│   │   ├── env.go
│   │   ├── logger.go
│   │   ├── migration.go
│   │   ├── module.go
│   │   └── seed.go
│   ├── infrastructure
│   │   ├── module.go
│   │   └── router.go
│   ├── middlewares
│   │   ├── command.go
│   │   ├── module.go
│   │   └── rate_limitter.go
│   ├── module.go
│   ├── responses
│   │   └── response.go
│   ├── services
│   │   └── module.go
│   └── utils
│       ├── aws_error.go
│       └── functional_programming.go
└── seeds
    ├── hello.go
    ├── module.go
    └── seeder.go

19 directories, 48 files

Folder Structure 📁

Folder PathDescription
/bootstrapcontains modules required to start the application
/consoleserver commands, run go run main.go -help for all the available server commands
/dockerdocker files required for docker compose
/domaincontains dtos, models, constants and folder for each domain with controller, repository, routes and services
/domain/constantsglobal application constants
/domain/modelsORM models
/domain/<name>controller, repository, routes and service for a domain. In this template user is a domain
/pkgcontains setup for api_errors, infrastructure, middlewares, external services, utils
/pkg/api-errorsserver error handlers
/pkg/frameworkcontains env parser, logger...
/pkg/infrastructurethird-party services connections like gmail, firebase, s3-bucket, ...
/pkg/middlewaresall middlewares used in the app
/pkg/responsesdifferent types of http responses are defined here
/pkg/servicesservice layers, contains the functionality that compounds the core of the application
/pkg/typesdata types used throught the application
/pkg/utilsglobal utility/helper functions
/seedsseeds for already migrated tables
/testsincludes application tests
.env.examplesample environment variables
dbconfig.ymldatabase configuration file for sql-migrate command
docker-compose.ymldocker compose file for service application via Docker
main.goentry-point of the server
Makefilestores frequently used commands; can be invoked using make command