This boilerplate serves as a solid foundation for building robust, scalable, and maintainable monolithic applications using the Go programming language.
In the world of software architecture, a monolithic application refers to a single-layer software application in which various components are combined into a single program. While microservices are popular for their scalability and modularity, monoliths still have their place, especially in scenarios where simplicity and ease of deployment are crucial.
Warning
Pet and owner were shown in the project only as an example.
- Modularity: Although it is a monolithic boilerplate, it promotes modular design principles and allows you to organize your code base into logical components. This process is made easier using Uber FX for the dependency injection in the boilerplate.
- Scalability: While a monolithic application may not scale as easily as a microservice, this example provides best practices and patterns to help you scale your application efficiently as it grows.
- Ease of Deployment: Application deployment and management become easier with a single deployable unit compared to a distributed microservices architecture.
How to use are Swagger, Gorm and Gorm Gen mentioned in the boilerplate.
The app can convertible easily to microservice from monolithic thanks to modularity. All we have to do is creating main.go files separately on the under of the app's folders.
// ./app/pet/main.go
package main
import (
"github.com/balcieren/go-monolithic-boilerplate/pkg/infrastructure"
"go.uber.org/fx"
petApiV1 "github.com/balcieren/go-monolithic-boilerplate/app/pet/api/v1"
)
func main() {
fx.New(
infrastructure.CommonModule(),
infrastructure.HTTPModule("go-monolithic-boilerplate/pet-api"),
petApiV1.Module,
fx.Invoke(infrastructure.LaunchHTTPServer),
).Run()
}
graph TD;
App-->PetService
App-->OwnerService
PetService-->id1[(Database)];
OwnerService-->id1[(Database)];
Run the app as development mode
make dev
Run the app as production mode
make prod
Generate the swagger document
make swagger
Gorm Gen
make gorm