This project is a demonstration of a microservices architecture using Go, gRPC, GraphQL, and PostgreSQL. It consists of four main services: account, order, catalog, and a graphql-gateway.
The architecture is designed to be scalable and maintainable. Each service is responsible for a specific domain and communicates with others via gRPC. The graphql-gateway acts as a single entry point for clients, aggregating data from the other services.
Here is a high-level overview of the architecture:
- Account Service: Manages user accounts.
- Order Service: Manages orders and their products.
- Catalog Service: Manages the product catalog.
- GraphQL Gateway: A GraphQL server that acts as an API gateway for the other services.
- User account creation and retrieval.
- Product creation and retrieval.
- Order creation and retrieval.
- GraphQL API for all services.
- gRPC for inter-service communication.
- Dockerized setup for easy development and deployment.
The GraphQL API is the single entry point for all client-side applications. It provides a flexible and powerful way to query and mutate data.
accounts(pagination: PaginationInput, id: String): [Account!]!
Fetches a list of accounts. Can be paginated and filtered by ID.
products(pagination: PaginationInput, query: String, id: String): [Product!]!
Fetches a list of products. Can be paginated and filtered by name or ID.
createAccount(account: AccountInput!): Account
Creates a new account.
createProduct(product: ProductInput!): Product
Creates a new product.
createOrder(order: OrderInput!): Order
Creates a new order.
To get started with this project, you'll need to have Docker and Docker Compose installed on your machine.
-
Clone the repository:
git clone https://github.com/saurabhkr78/Microservices.git cd Microservices -
Run the services using Docker Compose:
docker-compose up -d --build
The services will be available at the following ports:
- GraphQL Gateway:
http://localhost:8080 - Account Service:
http://localhost:8001 - Order Service:
http://localhost:8002 - Catalog Service:
http://localhost:8003
You can access the GraphQL Playground at http://localhost:8080 to interact with the API.
Each service has its own PostgreSQL database, which is also run in a Docker container. The data is persisted in Docker volumes.
- Account Database:
postgresql://postgres:postgres@localhost:5433/account - Order Database:
postgresql://postgres:postgres@localhost:5434/order - Catalog Database:
postgresql://postgres:postgres@localhost:5435/catalog
