A modern microservices architecture built with Go, gRPC, and GraphQL, featuring multiple services for account management, catalog, and order processing. This project demonstrates a complete e-commerce system with separate microservices for user accounts, product catalog, and order management, all unified through a GraphQL API gateway.
-
Microservices Architecture
- Account Service (User Management)
- Catalog Service (Product Management)
- Order Service (Order Processing)
- GraphQL Gateway (Unified API)
-
Technology Stack
- Backend: Go
- Communication: gRPC
- API Gateway: GraphQL (gqlgen)
- Databases:
- PostgreSQL (Account & Order services)
- Elasticsearch 6.2.4 (Catalog service)
- Containerization: Docker & Docker Compose
- Go 1.24 or later
- Docker and Docker Compose
- Protocol Buffers compiler (protoc)
- Make (optional, for using Makefile commands)
-
Clone the repository
git clone https://github.com/deepam02/go-grpc-graphql-micro.git cd go-grpc-graphql-micro
-
Start the services
docker-compose up --build
-
Access the GraphQL Playground
http://localhost:8000/playground
- Port: 8080 (internal)
- Database: PostgreSQL
- Features:
- Account creation
- Account retrieval
- Account listing with pagination
- Port: 8080 (internal)
- Database: Elasticsearch 6.2.4
- Features:
- Product creation
- Product search
- Product listing with pagination
- Port: 8080 (internal)
- Database: PostgreSQL
- Features:
- Order creation
- Order retrieval
- Integration with Account and Catalog services
- Port: 8000 (external)
- Features:
- Unified GraphQL API
- GraphQL Playground
- Health check endpoint
-
Create Account
mutation { createAccount(account: { name: "John Doe" }) { id name } }
-
Create Product
mutation { createProduct(product: { name: "Product Name" description: "Product Description" price: 99.99 }) { id name price } }
-
Create Order
mutation { createOrder(order: { accountId: "account-id" products: [ { id: "product-id", quantity: 2 } ] }) { id totalPrice } }
-
Get Accounts
query { accounts(pagination: { skip: 0, take: 10 }) { id name orders { id totalPrice } } }
-
Search Products
query { products(pagination: { skip: 0, take: 10 }, query: "search term") { id name description price } }
DATABASE_URL
: PostgreSQL connection string
DATABASE_URL
: Elasticsearch connection string
DATABASE_URL
: PostgreSQL connection stringACCOUNT_SERVICE_URL
: Account service URLCATALOG_SERVICE_URL
: Catalog service URL
ACCOUNT_SERVICE_URL
: Account service URLCATALOG_SERVICE_URL
: Catalog service URLORDER_SERVICE_URL
: Order service URL
.
├── account/ # Account service
│ ├── cmd/ # Service entry point
│ ├── pb/ # Generated protobuf files
│ ├── account.proto # Service definition
│ ├── repository.go # Database operations
│ ├── service.go # Business logic
│ └── server.go # gRPC server implementation
├── catalog/ # Catalog service
│ ├── cmd/ # Service entry point
│ ├── pb/ # Generated protobuf files
│ ├── catalog.proto # Service definition
│ ├── repository.go # Elasticsearch operations
│ ├── service.go # Business logic
│ └── server.go # gRPC server implementation
├── order/ # Order service
│ ├── cmd/ # Service entry point
│ ├── pb/ # Generated protobuf files
│ ├── order.proto # Service definition
│ ├── repository.go # Database operations
│ ├── service.go # Business logic
│ └── server.go # gRPC server implementation
├── graphql/ # GraphQL gateway
│ ├── schema.graphql # GraphQL schema definition
│ ├── generated.go # Generated GraphQL code
│ ├── resolvers/ # GraphQL resolvers
│ └── server.go # GraphQL server implementation
├── docker-compose.yaml # Service orchestration
└── go.mod # Go module definition
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.