Code for my youtube video - Microservices Project - Uses Golang, gRPC, GraphQL, Postgres, Elasticsearch, Docker Compose
- star 数
- 124
- watcher 数
- 1
- fork 数
- 26
- issue 数
- 1
- 最終更新
- 2024/10/07
Code for my youtube video - Microservices Project - Uses Golang, gRPC, GraphQL, Postgres, Elasticsearch, Docker Compose
Follow along with my youtube video - https://www.youtube.com/watch?v=5UIh1dV7aZ8&t=1346s
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.
Note from akhil - I built this project with the latest GO version and packages, but in this particular code - I have reverted to an older version of GO - why? Across all my production apps, I'm using old versions of GO - simply for more stability and also because I can easy fix if a new issue shows up - many issues prop up in projects with multiple moving parts (and this project has many of them - grpc, graphql, postgres, docker compose, elastisearch and GO) because each of the moving parts keep updating. If you're a one man team - keep your software manageable with this technique - use versions of software you've previously built with.
The project consists of the following main components:
Each service has its own database:
Clone the repository:
git clone <repository-url>
cd <project-directory>
Start the services using Docker Compose:
docker-compose up -d --build
Access the GraphQL playground at http://localhost:8000/playground
Steps for grpc file generation -
The GraphQL API provides a unified interface to interact with all the microservices.
query { accounts { id name } }
mutation { createAccount(account: {name: "New Account"}) { id name } }
query { products { id name price } }
mutation { createProduct(product: {name: "New Product", description: "A new product", price: 19.99}) { id name price } }
mutation { createOrder(order: {accountId: "account_id", products: [{id: "product_id", quantity: 2}]}) { id totalPrice products { name quantity } } }
query { accounts(id: "account_id") { name orders { id createdAt totalPrice products { name quantity price } } } }
query { products(pagination: {skip: 0, take: 5}, query: "search_term") { id name description price } }
query { accounts(id: "account_id") { name orders { totalPrice } } }