How paulc4/microservices-demo works
Project Type and Purpose
• This is a Spring-based microservices demo application illustrating service registry/discovery with Eureka, three autonomous Spring Boot services (Registration, Accounts, Web), in-memory/configured database for accounts data, and a simple client-side UI.
• The README confirms it’s a demo of Spring Cloud microservices (RegistrationService as Eureka server, AccountsService for data, WebService acting as client and UI).
File Structure Analysis
• Top-level build files (pom.xml, build.gradle, Dockerfile) indicate Java/Spring Boot with both Maven and Gradle support.
• src/main/java/io/pivotal/microservices/services/Main.java: a “fat” JAR entry point that branches into three server modes (“registration”, “accounts”, “web”).
• services subpackages:
• services/registration – RegistrationServer (Eureka registry)
• services/accounts – AccountsServer (Spring Boot app exposing REST & JPA/H2)
• services/web – WebServer + WebAccountsService + Controllers for UI
• src/main/resources contains per-service YAML for ports and Eureka clients, HTML templates for UI, plus testdb scripts.
• Tests and configuration classes under accounts show Spring MVC and JPA pattern.
Key Architectural Insights from README
• There are three distinct Spring Boot applications, each launched via the same JAR with a mode argument.
• RegistrationService runs on port 1111, exposing Eureka dashboard.
• AccountsService registers itself, exposes account lookup REST API, backed by embedded database.
• WebService registers itself, serves HTML views on port 3333, uses client-side code (Ribbon) to discover/load-balance AccountsService.
• Docker support spins each service in its own container.
a. Main Components
• Service Registry (RegistrationService/Eureka)
• AccountsService (REST API + embedded DB)
• WebService (Spring MVC UI + discovery client)
• Database (H2 or configured RDBMS)
• End-user browser
• (Optional) Docker Host / Network
b. Relationships & Interactions
• On startup, AccountsService & WebService register with Eureka.
• Browser → HTTP GET to WebService (port 3333).
• WebService uses Eureka + Ribbon to call AccountsService REST endpoints.
• AccountsService reads/writes to embedded DB (testdb).
• Eureka dashboard viewable at RegistrationService (port 1111).
c. Architectural Patterns & Principles
• Microservices: each service isolated, independent deployable units.
• Service Registry/Discovery (Eureka) for loose coupling & dynamic endpoints.
• Client-side load balancing (Ribbon within WebService).
• Externalized configuration per-service via YAML.
• Fat JAR + embedded Tomcat pattern for cloud-native packaging.
d. Technologies & Frameworks
• Spring Boot & Spring MVC
• Spring Cloud Netflix Eureka (service registry)
• Ribbon (load balancing)
• Embedded H2 or configurable JDBC (data.sql/schema.sql)
• Thymeleaf/Spring Templates for HTML
• Maven/Gradle build, Docker containerization