How anjeyy/grpc-sample works
• grpc-proto – houses the shared .proto files to define the gRPC services and message contracts;
• grpc-server – implements the server-side logic (using grpc-spring-boot-starter) with REST endpoints, controllers, service and DAO layers, plus configuration for exception handling and interceptors;
• grpc-client – serves as the client-side consumer of the gRPC services, with its own APIs to interface with the server.
Main Components
a. Modules:
• Proto Module: Contains the .proto files (e.g., DocumentService.proto, HelloService.proto). This is the common contract used by both server and client.
• gRPC Server: Implemented with Spring Boot. It includes REST controllers (e.g., DocumentController) and gRPC service implementations (e.g., GrpcDocumentService, GrpcHelloService). It also includes application configuration, global exception handling, interceptors, and a DAO/data-access layer (document repository, entity, and SQL setup file).
• gRPC Client: Also implemented with Spring Boot that calls the gRPC server. It comprises API controllers and client service classes (e.g., GrpcDocumentServiceClient, GrpcHelloServiceClient).
b. Supporting Infrastructure:
• Deployment Configurations: Kubernetes YAML files for both client and server, Dockerfiles, and scripts for deployment and service removal.
• Build/CI Environment: GitHub workflows under .github for building and pushing Docker images along with Maven wrapper files.
• Configuration Files: Application configuration (application.yml, application-kubernetes.yml) to adjust environment-based behavior.
b. Server component with its internal layers:
• API Layer (Controllers providing REST endpoints for testing or non-gRPC interactions)
• Service Layer (Business logic and interaction with the gRPC framework)
• Data Access Layer (DAO, Repository, using a relational database as indicated by the SQL scripts)
• Infrastructure Layer (Global exception handling, interceptors, configuration setups)
c. Client as the consumer of the gRPC Server:
• Client API module to convert external requests into gRPC calls.
• gRPC Client Services that call the server endpoints using the shared .proto definitions.
d. Deployment elements:
• Docker containers wrapping both the Server and Client modules.
• Kubernetes configuration showing separate load balancers, one for each module. Note the direction for dynamic gRPC load balancing for the client when making calls to the server.
Important Architectural Patterns and Technologies
a. Modular Design: Clear separation between service contracts (proto), server implementation, and client consumption.
b. Layered Architecture (especially in the server module): Controllers, Services, and Data Access.
c. Use of gRPC and REST together, enabled by grpc-spring-boot-starter Spring Boot integrations.
d. CI/CD Integration: Automated builds and container deployment via GitHub workflows and Maven wrapper.
e. Containerization and Orchestration via Docker and Kubernetes.
What
– Proto Module
– gRPC Server (with sub-layers: API controllers, service layer, data access)
– gRPC Client (including its API layer)
– External systems (e.g., database, load balancers)
– Shared dependency of Server and Client on the Proto Module.
– Requests flowing from the Client to the Server.
– Data flow within the Server from Controllers to Business Services and finally to the Database.