How spring-petclinic/spring-petclinic-microservices works
Main components
• API Gateway – This module (spring-petclinic-api-gateway) is responsible for routing external requests to internal services. It is built using Spring Cloud Gateway and handles fallback/circuit breaker logic.
• Service Registry / Discovery Server – This is the Eureka-based discovery server (spring-petclinic-discovery-server) where all microservices register.
• Config Server – (spring-petclinic-config-server) acts as the centralized management for configuration across all services.
• Microservices – There are several key domain services:
• Customers Service (spring-petclinic-customers-service)
• Vets Service (spring-petclinic-vets-service)
• Visits Service (spring-petclinic-visits-service)
• GenAI Service (spring-petclinic-genai-service) which integrates the AI Chatbot functionality.
• There is also an Admin Server (spring-petclinic-admin-server) for management and monitoring.
• Monitoring and Observability Tools – These include:
• Prometheus (docker/prometheus) for metrics.
• Grafana (docker/grafana) for dashboards.
• Tracing components (Zipkin mentioned in the README) for distributed tracing.
• Supporting Infrastructure:
• Docker configurations (docker-compose.yml, Dockerfiles) for container orchestration.
• Chaos Monkey integration (scripts/chaos) – illustrating resilience testing and fault injection.
• Database layer: with configurations for either in-memory HSQLDB or MySQL, as seen by the SQL scripts inside each service’s resources.
• External LLM providers (OpenAI or Azure OpenAI) that are interfaced via the GenAI Service.
Relationships and interactions
• The API Gateway sits at the edge and routes incoming requests to the relevant backend microservices.
• All microservices register themselves with the Discovery Server (Eureka) and obtain configuration from the Config Server.
• The Admin Server monitors the microservices, while Prometheus collects application metrics (via Micrometer) that Grafana then visualizes.
• The GenAI Service communicates with external LLM providers and may also receive calls via the API Gateway.
• The chaos scripts and watchers provide fault injection mechanisms that may trigger or simulate failures across the microservices.
Architectural patterns and design principles
• Microservices Architecture: Services are segregated by their responsibility (customers, vets, visits, GenAI, etc.) and communicate over REST APIs.
• Centralized Configuration and Service Discovery: Implementation of Spring Cloud Config Server and Eureka for dynamic service registration, making the system resilient and easily scaleable.
• Observability and Resilience: Incorporates monitoring (Prometheus/Grafana), tracers (Zipkin), and circuit breakers (Resilience4j) to handle failures gracefully.
• Containerization and orchestration: Docker compose and Dockerfiles illustrate that the system is packaged as container images to ease local and remote deployments.
• Chaos Engineering: With included Chaos Monkey configuration scripts (in the scripts/chaos folder) to simulate fault conditions.