A production-ready microservices demonstration project showcasing synchronous inter-service communication using GraphQL and REST APIs, orchestrated in a Kubernetes cluster with Docker containerization.
This project demonstrates a modern microservices architecture with three independent services communicating synchronously:
- Bank Service (GraphQL API) - Frontend-facing API gateway
- Accounts Service (REST API) - Account management microservice
- Profile Service (REST API) - User profile management microservice
- Auth Service (In Progress) - JWT-based authentication microservice
Each service is independently containerized and deployable to Kubernetes with horizontal pod autoscaling capabilities.
- β Synchronous Inter-Service Communication - Services communicate in real-time via HTTP
- β GraphQL Federation - Apollo Server with schema composition and code generation
- β REST APIs - Express-based microservices with TypeScript
- β Type Safety - Full TypeScript implementation with code generation for GraphQL types
- β Docker Containerization - All services packaged as Docker images
- β Docker Compose - Local development environment setup
- β
Kubernetes Ready - Complete k8s manifests including:
- Service deployments
- Service discovery
- Horizontal Pod Autoscaling (HPA)
- NGINX Ingress configuration
- β Container Orchestration - Production-grade cluster entry with NGINX Ingress
- β Code Generation - Automatic TypeScript types from GraphQL schema
- β Modular Schema - Separate schema files stitched together
- β HTTP Client Integration - Axios for internal service communication
microservices/
βββ bank/ # GraphQL API Gateway (Apollo Server)
β βββ src/
β βββ Dockerfile
β βββ package.json
βββ accounts/ # REST API (Express + TypeScript)
β βββ src/
β βββ Dockerfile
β βββ package.json
βββ profile/ # REST API (Express + TypeScript)
β βββ src/
β βββ Dockerfile
β βββ package.json
βββ auth/ # Authentication Service (In Progress)
β βββ src/
β βββ Dockerfile
β βββ package.json
βββ k8s/ # Kubernetes manifests
β βββ deployments/
β βββ services/
β βββ hpa/
βββ docker-compose.yml # Local development environment
βββ README.md # This file
βββ TESTING.md # Comprehensive testing guide
βββ .env.example # Environment configuration template
| Component | Technology |
|---|---|
| Runtime | Node.js |
| Language | TypeScript, JavaScript |
| GraphQL | Apollo Server, GraphQL Code Generator |
| REST Framework | Express.js |
| HTTP Client | Axios |
| Containerization | Docker, Docker Compose |
| Orchestration | Kubernetes, NGINX Ingress |
| Scaling | Horizontal Pod Autoscaling (HPA) |
- Docker & Docker Compose
- Node.js 16+ (for local development)
- kubectl (for Kubernetes deployment)
- A Kubernetes cluster (for production deployment)
-
Clone the repository
git clone https://github.com/surojcodes/microservices.git cd microservices -
Set up environment variables
cp .env.example .env
-
Start services
docker-compose up --build
-
Access the services
- Bank GraphQL API:
http://localhost:4001/graphql - Accounts REST API:
http://localhost:3001 - Profile REST API:
http://localhost:3002
- Bank GraphQL API:
-
Build and push Docker images
docker build -t yourusername/bank:latest ./bank docker build -t yourusername/accounts:latest ./accounts docker build -t yourusername/profile:latest ./profile docker push yourusername/bank:latest docker push yourusername/accounts:latest docker push yourusername/profile:latest
-
Deploy to cluster
kubectl apply -f k8s/
-
Verify deployment
kubectl get deployments kubectl get services kubectl get hpa
βββββββββββββββββββββββββββββββββββββββ
β NGINX Ingress (Cluster Entry) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββΌββββββββββ
β Bank Service β
β (GraphQL API) β
ββββββββββ¬ββββββββββ
β
ββββββββββ΄ββββββββββ¬ββββββββββββββ
β β β
ββββΌβββββββ βββββββΌβββ ββββββΌβββββββ
β Accounts β β Profile β β Auth β
β (REST) β β (REST) β β (REST) β
ββββββββββββ βββββββββββ βββββββββββββ
Bank Service (GraphQL)
- Port: 4001
- Purpose: Frontend-facing API gateway
- Features:
- Apollo Server with code generation
- Schema composition from multiple services
- Synchronous calls to Accounts and Profile services
- Service discovery via Kubernetes DNS
Accounts Service (REST)
- Port: 3001
- Purpose: Account management
- Features: Standalone Express server with TypeScript
Profile Service (REST)
- Port: 3002
- Purpose: User profile management
- Features: Standalone Express server with TypeScript
Auth Service (REST)
- Port: 3003
- Purpose: Authentication & Authorization (In Progress)
- Planned: JWT tokens, refresh token flow, optional JWE/Identity Provider
Each service includes HPA configuration for automatic scaling based on CPU/memory metrics:
- Minimum replicas: 2
- Maximum replicas: 10 (configurable)
- Target CPU utilization: 70%
- NGINX Ingress handles external traffic distribution
- Kubernetes Service DNS for internal load balancing
Comprehensive testing guides are available:
- TESTING.md - Detailed testing procedures and examples
- TESTING_SUMMARY.md - Quick reference and summary
See these files for:
- GraphQL query examples
- REST API endpoints
- Integration testing procedures
- Curl commands for manual testing
- Local Development: Use
docker-compose upfor isolated service testing - Testing: Follow the comprehensive guides in TESTING.md
- Deployment: Push to Kubernetes cluster via manifests in
k8s/directory - Monitoring: Check HPA and pod metrics with kubectl
Configure services using the .env file:
# Example configuration
ACCOUNTS_SERVICE_URL=http://accounts:3001
PROFILE_SERVICE_URL=http://profile:3002
AUTH_SERVICE_URL=http://auth:3003
PORT=4001
NODE_ENV=developmentSee .env.example for all available options.
- Bank Service (GraphQL API Gateway)
- Accounts Service (REST API)
- Profile Service (REST API)
- Docker Compose setup
- Kubernetes manifests
- HPA configuration
- Auth Service (JWT Tokens)
- Refresh token implementation
- JWE encryption support
- Identity Provider integration
- API documentation (OpenAPI/Swagger)
- Distributed tracing
- Centralized logging
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is open source and available under the MIT License.
For questions or issues, please open a GitHub issue or contact the maintainer.
Happy coding! π