<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bastien R.</title>
    <description>The latest articles on Forem by Bastien R. (@teyz).</description>
    <link>https://forem.com/teyz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1826987%2F3eb7997c-6c8d-4d5c-bc87-025c6ec16eaf.jpeg</url>
      <title>Forem: Bastien R.</title>
      <link>https://forem.com/teyz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/teyz"/>
    <language>en</language>
    <item>
      <title>🚀 Kickstart Your Microservices Development with Go! 🚀</title>
      <dc:creator>Bastien R.</dc:creator>
      <pubDate>Tue, 13 Aug 2024 15:14:16 +0000</pubDate>
      <link>https://forem.com/teyz/kickstart-your-microservices-development-with-go-d86</link>
      <guid>https://forem.com/teyz/kickstart-your-microservices-development-with-go-d86</guid>
      <description>&lt;p&gt;Are you looking to build robust, scalable microservices using hashtag#Golang? Look no further! I've come across this amazing template that provides a solid foundation for creating microservices in hashtag#Go: &lt;a href="https://github.com/Teyz/go-svc-template" rel="noopener noreferrer"&gt;Github repository here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This template comes with:&lt;br&gt;
🛠️ Ready-to-use project structure&lt;br&gt;
🧩 Built-in support for dependency injection&lt;br&gt;
📈 Integrated metrics and logging&lt;br&gt;
✅ Complete hashtag#testing framework&lt;/p&gt;

&lt;p&gt;Whether you're new to Go or an experienced developer, this template will save you time and help you focus on what matters—writing business logic!&lt;br&gt;
Check it out and start building your next hashtag#microservice with ease! 🌟&lt;/p&gt;

&lt;p&gt;Feel free to modify it as you see fit!&lt;/p&gt;

</description>
      <category>go</category>
      <category>microservices</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Livestream platform backend — Detailed architecture</title>
      <dc:creator>Bastien R.</dc:creator>
      <pubDate>Tue, 23 Jul 2024 16:29:53 +0000</pubDate>
      <link>https://forem.com/teyz/livestream-platform-backend-detailed-architecture-1f62</link>
      <guid>https://forem.com/teyz/livestream-platform-backend-detailed-architecture-1f62</guid>
      <description>&lt;h2&gt;
  
  
  Previously
&lt;/h2&gt;

&lt;p&gt;In the previous article, dflmnq presents a backend architecture for a streaming platform use case.&lt;/p&gt;

&lt;p&gt;This article follows this one: &lt;a href="https://medium.com/@dflmnq/backend-architecture-use-case-live-stream-platform-6030a524085d" rel="noopener noreferrer"&gt;Backend Architecture — Use Case: Live stream Platform.&lt;/a&gt;&lt;br&gt;
I invite you to read it if you haven’t already.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who am I?
&lt;/h3&gt;

&lt;p&gt;I’m Bastien, a 26yo backend developer (at the time of writing this article).&lt;/p&gt;

&lt;p&gt;I’m passionate about streaming and video games. I was delighted when I had an opportunity to join Kick. I learned a lot about architecture / good practices, etc. It’s my experience at Kick that prompted me to write this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s go into more details
&lt;/h2&gt;

&lt;p&gt;We finish the previous article with the description of the global architecture of the backend as you can see below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16sibrbwtaf43s997sq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16sibrbwtaf43s997sq0.png" alt="Global backend architecture" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I added the &lt;strong&gt;contract&lt;/strong&gt; component(purple one).&lt;/p&gt;

&lt;p&gt;Any communication happening between services, synchronous or not, involving a gateway or not, should be defined in this contracts repository which is the only source of truth.&lt;br&gt;
Respecting this rule ensures that payloads stay consistent, versioning is way easier and we do not miss nor hide any information.&lt;/p&gt;

&lt;h3&gt;
  
  
  How contracts is organized?
&lt;/h3&gt;

&lt;p&gt;In short, it’s the glue between gateways and services. Without it, our services won’t be able to communicate with each other, and that’s a real shame 😅.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ijtp3eldbtzdwvj292q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ijtp3eldbtzdwvj292q.png" alt="Architecture of contracts" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As stated above, there are two types of contracts :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The internal ones, between our services.&lt;/li&gt;
&lt;li&gt;The external ones, between the gateways and the internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The internal ones live inside services, generated, and clients folders while the external ones live inside models and docs. How does it work?&lt;/p&gt;

&lt;h4&gt;
  
  
  Internal contracts
&lt;/h4&gt;

&lt;p&gt;The first folder is services.&lt;/p&gt;

&lt;p&gt;This one contains the protobuf definition for each of our services.&lt;br&gt;
It is versioned and each service is independent here. Any time we modify services, we can use &lt;code&gt;buf generate&lt;/code&gt; to update the go interfaces matching the protobuf definitions.&lt;br&gt;
This generated code is pushed into the &lt;code&gt;generated&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;Then, the final part is the &lt;code&gt;clients&lt;/code&gt; one.&lt;br&gt;
We use clients to write wrappers around the generated code, adding to it unified monitoring, errors handling, payloads translating...&lt;br&gt;
In the end, the only thing used out of contracts is the code from clients.&lt;/p&gt;

&lt;h4&gt;
  
  
  External contracts
&lt;/h4&gt;

&lt;p&gt;Whenever a gateway needs to build a response for an endpoint, entities should be used from the ones available in the &lt;code&gt;models&lt;/code&gt; folder.&lt;br&gt;
It contains each entities, versioned.&lt;/p&gt;

&lt;p&gt;The second folder, &lt;code&gt;docs&lt;/code&gt; contains all the OpenAPI documents for both the Public, Private, and Admin API. It has to always be in sync with the models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now, let’s dive deep into clients
&lt;/h3&gt;

&lt;p&gt;clients is the most important folder on this repository, as I said before, we will find everything we need to create our gRPC wrappers.&lt;/p&gt;

&lt;p&gt;Here is an example of the integration of user-store-svc in contracts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdie20yh8arlvj4r37i18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdie20yh8arlvj4r37i18.png" alt="Architecture of clients" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;entities&lt;/strong&gt; is the folder where we can retrieve all the definitions of our entities for user-store-svc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;grpc&lt;/strong&gt;, in this folder, we will find the gRPC logic of our service. All methods need to be defined in interface.go.&lt;/p&gt;

&lt;p&gt;mocks is auto-generated with interface.go.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about Models ?
&lt;/h3&gt;

&lt;p&gt;Models is composed by 4 folders, here the architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcwelixjleoxowqjn2vw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcwelixjleoxowqjn2vw2.png" alt="Architecture of models" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;entities&lt;/strong&gt; must list all the entities in our various gateways/services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;kafka&lt;/strong&gt; must list all our events/constants.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;public&lt;/strong&gt; must list all our entities and stuff related to our public API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ws&lt;/strong&gt; must list all our models/entities for our websockets events.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best for last: Services
&lt;/h3&gt;

&lt;p&gt;In this last folder, we will retrieve all the definitions of our protobuf services.&lt;br&gt;
Those protobuf will define the contracts between our gateway and the service.&lt;/p&gt;

&lt;p&gt;contracts/&lt;br&gt;
├─ services/&lt;br&gt;
│ ├─ user/&lt;br&gt;
│ │ ├─ store/&lt;br&gt;
│ │ │ ├─ svc/&lt;br&gt;
│ │ │ │ ├─ v1/&lt;br&gt;
│ │ │ │ │ ├─ user.proto&lt;br&gt;
│ │ │ │ │ ├─ service.proto&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;service.proto&lt;/strong&gt; is like an interface in go but for protobuf.&lt;br&gt;
It should be like this (for our example).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;service UserStoreSvc {&lt;br&gt;
    rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;user.go&lt;/strong&gt; must define the contract for every methods in our &lt;strong&gt;user-store-svc&lt;/strong&gt;. It should be like this (for our example).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;message User {&lt;br&gt;
    google.protobuf.StringValue id = 1;&lt;br&gt;
    google.protobuf.StringValue username = 2;&lt;br&gt;
    google.protobuf.StringValue email = 3;&lt;br&gt;
    google.protobuf.Timestamp created_at = 4;&lt;br&gt;
    google.protobuf.Timestamp updated_at = 5;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;message CreateUserRequest {&lt;br&gt;
    google.protobuf.StringValue username = 1;&lt;br&gt;
    google.protobuf.StringValue email = 2;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;message CreateUserResponse {&lt;br&gt;
    User user = 1;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can find the GitHub repository here: &lt;a href="https://github.com/Golerplate/contracts" rel="noopener noreferrer"&gt;https://github.com/Golerplate/contracts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: It is very important to version all our files in contracts.&lt;/p&gt;

&lt;p&gt;That’s globally all for the contracts. And this is a very good transition to continue with the code organization of a service. We will see that contracts will be very useful 😀.&lt;/p&gt;

&lt;h2&gt;
  
  
  What will a service look like in terms of code organization
&lt;/h2&gt;

&lt;p&gt;Our services are built the way we might play with Legos. Let me explain what this means.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33fegomkdrv1t4u6cpv7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33fegomkdrv1t4u6cpv7.png" alt="Architecture of the microservice" width="800" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first folder &lt;strong&gt;cmd&lt;/strong&gt; contains the file &lt;strong&gt;main.go&lt;/strong&gt;, we will define how the server/database/redis runs and start the gRPC and HTTP server if we need it.&lt;/p&gt;

&lt;p&gt;The second folder &lt;strong&gt;internal&lt;/strong&gt; is where the fun begins, we will find 5 main folders.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;config&lt;/strong&gt;: At the beginning, config was always redefined in each service and he was looking like this:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;type Config struct {&lt;br&gt;
 HTTPServerConfig&lt;br&gt;
 GRPCServerConfig&lt;br&gt;
 PlanetScaleConfig&lt;br&gt;
 CacheConfig&lt;br&gt;
 GeneralConfig&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type GeneralConfig struct {&lt;br&gt;
 Environment string&lt;/code&gt;env:"ENVIRONMENT"&lt;code&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type CacheConfig struct {&lt;br&gt;
 Host     string&lt;/code&gt;env:"CACHE_HOST"&lt;code&gt;&lt;br&gt;
 Port     uint16&lt;/code&gt;env:"CACHE_PORT"&lt;code&gt;&lt;br&gt;
 Password string&lt;/code&gt;env:"CACHE_PASSWORD"&lt;code&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type PlanetScaleConfig struct {&lt;br&gt;
 WriterHost string&lt;/code&gt;env:"DB_HOST_WRITER"&lt;code&gt;&lt;br&gt;
 ReaderHost string&lt;/code&gt;env:"DB_HOST_READER"&lt;code&gt;&lt;br&gt;
 Username   string&lt;/code&gt;env:"DB_USER"&lt;code&gt;&lt;br&gt;
 Password   string&lt;/code&gt;env:"DB_PASSWORD"&lt;code&gt;&lt;br&gt;
 DBName     string&lt;/code&gt;env:"DB_NAME"&lt;code&gt;&lt;br&gt;
 Port       uint16&lt;/code&gt;env:"DB_PORT"&lt;code&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type HTTPServerConfig struct {&lt;br&gt;
 Port uint16&lt;/code&gt;env:"HTTP_SERVER_PORT"&lt;code&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type GRPCServerConfig struct {&lt;br&gt;
 Port uint16&lt;/code&gt;env:"GRPC_SERVER_PORT"&lt;code&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It was painful and we had a lot of duplicate code so we decided to move this logic into &lt;strong&gt;pkg&lt;/strong&gt; (I’ll come back to it later in this article.)&lt;/p&gt;

&lt;p&gt;So now, config looks like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type Config struct {&lt;br&gt;
 ServiceConfig       config.Config&lt;br&gt;
 GRPCServerConfig    grpc.GRPCServerConfig&lt;br&gt;
 PostgresConfig      database_postgres.Config&lt;br&gt;
 RedisConfig         redis.Config&lt;br&gt;
 KafkaProducerConfig pkg_kafka_producer.Config&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We’ve taken our inspiration from the Lego system, so we can build our service and configuration as we wish using the libraries in pkg.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;database&lt;/strong&gt;: The database folder is a little bit more complex than the config one. There is more logic in there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First of all, the migrations folder will list all our migrations files for our database, it’s very important to maintain consistency between our prod and our local environments.&lt;/p&gt;

&lt;p&gt;Then, we have &lt;strong&gt;interface.go&lt;/strong&gt; where we have to define all our methods.&lt;/p&gt;

&lt;p&gt;Finally, we have the &lt;strong&gt;postgres&lt;/strong&gt; folder (we chose postgres for the name as we are using postgres for our database, but we are free to change it).&lt;br&gt;
Inside this folder, we have all the files related to the methods we describe later in &lt;strong&gt;interface.go.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;entities&lt;/strong&gt;: Do we need to describe this one? Joke aside, we’ll need to describe the entities we’ll be using in the service, paying particular attention to versioning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;handlers&lt;/strong&gt;:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fet2pn6m480beyb4ibhwl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fet2pn6m480beyb4ibhwl.png" alt="Architecture of handlers" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handlers&lt;/strong&gt; is composed by 2 main elements, the first one is interface.go which describes the methods to launch our server.&lt;/p&gt;

&lt;p&gt;Into &lt;strong&gt;grpc&lt;/strong&gt; folder, we have &lt;strong&gt;server.go&lt;/strong&gt;, we will find a bench of functions to setup / start and stop our gRPC server.&lt;/p&gt;

&lt;p&gt;When we zoom into &lt;strong&gt;user/v1/&lt;/strong&gt; we will find &lt;strong&gt;init.go&lt;/strong&gt;, this file describes the struct and the function to create a &lt;strong&gt;NewUserStoreServiceHandler&lt;/strong&gt; (he will be used into &lt;strong&gt;main.go&lt;/strong&gt; in cmd).&lt;br&gt;
As we can imagine, &lt;strong&gt;user.go&lt;/strong&gt; contains all the gRPC methods related to User.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;services&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp62kjvv78dilnulzx650.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp62kjvv78dilnulzx650.png" alt="architecture of service/v1" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Init.go&lt;/strong&gt; has the same role as init.go in handlers and if we have added cache in our services, it is in this file that we will defines our cacheDuration and CacheKey&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const (&lt;br&gt;
 userCacheDuration = time.Hour * 24&lt;br&gt;
)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;func generateUserCacheKeyWithEmail(email string) string {&lt;br&gt;
 return fmt.Sprintf("user-store-svc:user:email:%v", email)&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interface.go&lt;/strong&gt;, We’re getting the hang of it, it’s where we define our interface for the methods of the service.&lt;/p&gt;

&lt;p&gt;The last one, &lt;strong&gt;user.go&lt;/strong&gt; is the main file where we wrote all the methods for the service, this layer is a middleman between the gRPC layer and the database layer. It takes parameters from the gRPC, calls the database service, and formats the data retrieved by the database layer to pass it to the gRPC layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where will be the shared code? (pkg)
&lt;/h2&gt;

&lt;p&gt;The pkg repository contains all the libraries that we use in the different micro-services. These libraries are non-product ones. It can be anything from a client connecting to our database to a utility function improving the way we handle the errors.&lt;/p&gt;

&lt;p&gt;For our streaming platform, we need several libraries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;config&lt;/strong&gt;: We will define our global config for all services. For example ServiceName and Environment (dev, prod, etc).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cache&lt;/strong&gt;: As we are processing a lot of requests per second (dozens of thousands of requests per second), we need to add some caching to relieve our Database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;constants&lt;/strong&gt;: All our common constants. For example, our id prefixes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;database&lt;/strong&gt;: We will define what type of database we use and the config and the connection methods.&lt;br&gt;
errors: Here we have defined custom database errors for our services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;grpc&lt;/strong&gt;: Here we have the gRPC config (Port) and the custom errors for our gRPC methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;http&lt;/strong&gt;: Same as gRPC but for the HTTP layer (errors, response, and config).&lt;br&gt;
You can find the GitHub repository here:&lt;br&gt;
&lt;a href="https://github.com/Golerplate/pkg" rel="noopener noreferrer"&gt;https://github.com/Golerplate/pkg&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>architecture</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
