This project demonstrates a microservices architecture using gRPC for inter-service communication and GraphQL as the API gateway. It includes services for account management, product catalog, and order processing.
The project consists of the following main components:
- Account Service
- Catalog Service
- Order Service
- GraphQL API Gateway
Each service has its own database:
- Account and Order services use PostgreSQL
- Catalog service uses Elasticsearch
-
Clone the repository:
git clone <https://github.com/bianavic/go-microservice.git> cd <go-microservice> -
Start the services using Docker Compose:
docker-compose up -d --build -
Access the GraphQL playground at
http://localhost:8000/playground
mutation {
createAccount(account: {name: "New Account 1"}) {
id
name
}
}Response
{
"data": {
"createAccount": {
"id": "351EYSISpLmj80FtdVBxK3xGFy7",
"name": "New Account 1"
}
}
}
query {
accounts {
id
name
}
}Response
{
"data": {
"accounts": [
{
"id": "351jWooTazORjuLqlN5QCSoBiSO",
"name": "New Account 2"
},
{
"id": "351jHF16EuftmBnEoHHDRLzYt3K",
"name": "New Account 1"
}
]
}
}
mutation {
createProduct(product: {name: "New Product 1", description: "A new product 1", price: 19.99}) {
id
name
price
}
}Response
{
"data": {
"createProduct": {
"id": "351fvBgwUN46Dzh2kej9MPOR9HM",
"name": "New Product 1",
"price": 19.99
}
}
}
query {
products {
id
name
price
}
}Response
{
"data": {
"products": [
{
"id": "351fvBgwUN46Dzh2kej9MPOR9HM",
"name": "New Product 1",
"price": 19.99
},
{
"id": "351jHVm8nTUU0zLvK3JR4Mxl6am",
"name": "New Product 1",
"price": 19.99
}
]
}
}
mutation {
createOrder(order: {
accountId: "351jHF16EuftmBnEoHHDRLzYt3K",
products: [{id: "351fvBgwUN46Dzh2kej9MPOR9HM", quantity: 2}]}) {
id
totalPrice
products {
name
quantity
}
}
}Response
{
"data": {
"createOrder": {
"id": "351jbVAyl9fUskE9dYYgk43xa5t",
"totalPrice": 39.98,
"products": []
}
}
}
query {
accounts(id: "351jHF16EuftmBnEoHHDRLzYt3K") {
name
orders {
id
createdAt
totalPrice
products {
name
quantity
price
}
}
}
}Response
{
"data": {
"accounts": [
{
"name": "New Account 1",
"orders": [
{
"id": "351jbVAyl9fUskE9dYYgk43xa5t",
"createdAt": "2025-11-04T20:07:40.499766593Z",
"totalPrice": 39.98,
"products": [
{
"name": "New Product 1",
"quantity": 2,
"price": 19.99
}
]
}
]
}
]
}
}
query {
products(pagination: {skip: 0, take: 5}, query: "New") {
id
name
description
price
}
}Response
{
"data": {
"products": [
{
"id": "351fvBgwUN46Dzh2kej9MPOR9HM",
"name": "New Product 1",
"description": "A new product 1",
"price": 19.99
},
{
"id": "351jHVm8nTUU0zLvK3JR4Mxl6am",
"name": "New Product 1",
"description": "A new product 1",
"price": 19.99
}
]
}
}
query {
accounts(id: "351jHF16EuftmBnEoHHDRLzYt3K") {
name
orders {
totalPrice
}
}
}Response
{
"data": {
"accounts": [
{
"name": "New Account 1",
"orders": [
{
"totalPrice": 39.98
}
]
}
]
}
}

