Skip to content

About

Go-based gRPC microservices backend demonstrating Protocol Buffers, service-to-service communication, PostgreSQL persistence, API Gateway, authentication, fault handling, observability, testing, and Dockerized deployment. Built to explore practical distributed-systems and backend engineering patterns.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

gRPC Microservices

A backend-focused microservices project built with Go and gRPC. The system demonstrates how independent services communicate through strongly typed Protocol Buffers contracts while handling persistence, authentication, failures, and service reliability.

Architecture

                    Client
                      |
                      v
                API Gateway
                   :8080
                      |
                     gRPC
                      |
                +-----v-----+
                |   Order   |
                |  Service  |
                +--+-----+--+
                   |     |
                 gRPC   gRPC
                   |     |
             +-----v-+ +-v-------+
             |Inventory| |Payment |
             | Service | |Service |
             +----+----+ +---+----+
                  |          |
              PostgreSQL  PostgreSQL

Services

API Gateway

  • Exposes the external HTTP API.
  • Converts HTTP requests to gRPC calls.
  • Handles request validation and authentication.
  • Maps gRPC responses and errors to HTTP responses.

Order Service

  • Creates and retrieves orders.
  • Coordinates Inventory and Payment services.
  • Manages the order lifecycle.
  • Handles failures between dependent services.

Inventory Service

  • Manages product stock.
  • Checks availability.
  • Reserves inventory.
  • Releases reserved inventory.

Payment Service

  • Processes payments.
  • Tracks payment status.
  • Handles successful and failed transactions.

Tech Stack

  • Go
  • gRPC
  • Protocol Buffers
  • PostgreSQL
  • Docker
  • JWT
  • Prometheus

Communication

Services communicate internally using gRPC.

Gateway → Order Service
Order → Inventory Service
Order → Payment Service

Protocol Buffers define the contracts between services. Generated Go code is used for the gRPC clients and servers.

Main Order Flow

Create Order
     |
     v
Check Inventory
     |
     v
Reserve Stock
     |
     v
Process Payment
     |
     +---- Payment Failed ----> Release Stock
     |
     v
Create Order

Key Backend Concepts

This project focuses on:

  • gRPC service communication
  • Protocol Buffers
  • Microservice boundaries
  • Database-per-service ownership
  • Deadlines and timeouts
  • Retry handling
  • Idempotency
  • Authentication
  • gRPC interceptors
  • Graceful shutdown
  • Health checks
  • Structured logging
  • Metrics
  • Failure handling
  • Concurrent request handling

Project Structure

grpc-microservices/
├── proto/
│   ├── order.proto
│   ├── inventory.proto
│   └── payment.proto
│
├── services/
│   ├── order/
│   ├── inventory/
│   └── payment/
│
├── gateway/
├── migrations/
├── docker-compose.yml
├── Makefile
├── go.mod
├── go.sum
└── README.md

Development Phases

  • Project foundation
  • Protobuf contracts
  • Inventory gRPC service
  • Payment gRPC service
  • Order gRPC service
  • Inter-service reliability
  • PostgreSQL persistence
  • HTTP API Gateway
  • Authentication
  • gRPC interceptors
  • Docker setup
  • Testing
  • Observability
  • Security hardening
  • End-to-end validation
  • Deployment

Goal

The goal is to build a practical Go microservices system that demonstrates real backend engineering concepts rather than simply creating multiple independent APIs.

The project will progressively introduce distributed communication, persistence, failure handling, security, testing, and observability.

About

Go-based gRPC microservices backend demonstrating Protocol Buffers, service-to-service communication, PostgreSQL persistence, API Gateway, authentication, fault handling, observability, testing, and Dockerized deployment. Built to explore practical distributed-systems and backend engineering patterns.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages