How devdcores/bookstoreapp-distributed-application works
Project Overview and Type
• This is a distributed Ecommerce application for a bookstore, built with a microservices architecture using Java, Spring Boot, and React.
• The application is composed of multiple backend microservices (such as Account, Billing, Catalog, Order, and Payment) along with a frontend React app.
• It uses service discovery (Eureka for local development and Consul when running via Docker) and an API gateway (Zuul) to route requests.
• Additional support components include monitoring (Prometheus, Graphana, TICK stack), distributed tracing (Zipkin), and container orchestration via Docker-compose.
Analyzing the File Structure
• The project is organized into several distinct service modules – each represented by its own directory (e.g., bookstore-account-service, bookstore-billing-service, bookstore-catalog-service, bookstore-order-service, bookstore-payment-service).
• There is a common library (“bookstore-commons”) and a Feign client module (“bookstore-feign”) that consolidate shared code and facilitate inter-service communication.
• Other components include the API gateway (bookstore-api-gateway-service), service discovery modules (eureka and potentially consul configurations), and a React frontend (bookstore-frontend-react-app).
• Configuration files like “application.yml”, Dockerfiles, and migration SQL scripts clarify deployment, containerization, and database setups.
• Monitoring and tracing components are separately managed in directories such as bookstore-prometheus, bookstore-graphana, and others.
Main Components and Their Interactions
a. Frontend:
• React Application (“bookstore-frontend-react-app”): Acts as the public UI.
• Served behind an NGINX reverse proxy, which forwards requests to Zuul (API Gateway).
b. API Gateway:
• Zuul API Gateway routes frontend requests to appropriate backend services based on URL mappings.
• It also registers with the discovery services to dynamically resolve service endpoints.
c. Service Discovery:
• Eureka Discovery Service is used in local development mode.
• In Docker environments, Consul is used to dynamically manage service endpoints and targets.
d. Microservices:
• Account Service: Handles user accounts, authentication, and authorization.
• Billing Service: Manages billing and address information.
• Catalog Service: Manages products (books), categories, reviews, and image processing.
• Order Service: Manages cart, order processing, and order-related information.
• Payment Service: Handles payment methods and payment transactions.
• Each service is built as a Spring Boot project and communicates through REST APIs and potentially via Feign clients (as seen in “bookstore-feign”).
e. Shared Libraries:
• “bookstore-commons” provides common Spring configurations (security, exception handling, auditing) and utility methods across services.
f. Monitoring & Observability:
• Monitoring components include Prometheus, Graphana, Zipkin, and TICK stack tools (Telegraf, InfluxDB, Chronograf, Kapacitor).
• Each microservice is instrumented to provide metrics and traces which help in monitoring performance and overall health.
Architectural Patterns & Design Principles
• Microservices Architecture: Each domain of the application (account, catalog, etc.) is separated into modular, independent services.
• API Gateway: All client requests are funneled through a gateway that also handles dynamic routing using service discovery.
• Service Discovery: Utilizes Eureka or Consul for dynamic service endpoint registration and resolution.
• Containerization: Dockerfiles and docker-compose enable containerized deployments of microservices, monitoring tools, and reverse-proxy setups.
• Shared Code and Communication: The “bookstore-commons” module for cross-cutting concerns and “bookstore-feign” for inter-service communication.
• DevOps and Monitoring: Integrated monitoring and alerting systems with Prometheus, Graphana, and TICK.