Skip to main content

Architecture

architecture

In order to understand the entire architecture, it is necessary to begin by comprehending the smaller components.


Minimal Service Module

minimal

Api: Protobuf definition for public/internal service and models. Extra: define permissions in ACL

Event: Protobuf definition for distributed event bus

Biz: Domain layer, definition for all entities and repository interface

Service: Business logic, depends on biz repository interface

Data: Data access layer, implement biz repository interface, init databases( mysql ,redis), init event bus (kafka ), expose migration function

Conf: Protobuf configuration definition

Server: Set up http and grpc server. register all services, set up middlewares. set up distributed event and job handler, seeding behavior

Host: Process entry point, read configuration, set up tracing, logging. Usually the cmd folder

You may also see some other folders that not being listed:

I18n: Define localization resources

Menu: Define menu resources for Admin-UI

tip

You may find some concepts to be different from Kratos when using go-saas-kit; consider this as the reference.

Now that you have understood the layered composition, you can begin designing the division of business domains into different modules.

How to divide different domain modules is a challenging question, and the answer often relies on experience, much like when to split microservices. Each choice has its pros and cons. After division, you may not be able to use the same database transaction, and you may need to use RPC calls instead of local functions (although go-saas-kit has tools to abstract some of these differences). However, when involving different development teams, dividing domain modules can make it more convenient for each team to iterate agilely.

Monolithic

minimal

You can combine different private modules hosted in the same process by using dependency injection.

Microservice

minimal

You can containerize different processes and communicate through distributed messaging or Remote Procedure Call(RPC).