piggymetrics
Microservice Architecture with Spring Boot, Spring Cloud and Docker
Piggymetrics is a sample personal-finance app built as a teaching example to demonstrate microservice architecture using Spring Boot, Spring Cloud, and Docker.
Piggy Metrics is a sample personal-finance application built mainly as a teaching example. The README is clear that the app itself, a simple financial advisor that tracks your incomes, expenses, and savings, is not the real point. The point is to show off a particular way of building software called the microservice architecture, using a set of Java tools named Spring Boot, Spring Cloud, and Docker. People are welcome to copy the project and turn it into something of their own.
The core idea of microservices is that instead of writing one large program, you split the system into several small, separate programs that each handle one job and talk to each other over the network. Piggy Metrics is broken into three such business services. The Account service handles the user's income and expense entries, savings, and settings. The Statistics service does the number-crunching, calculating figures and recording them over time so cash-flow trends can be shown. The Notification service stores contact details and reminder settings, and a scheduled worker gathers data from the other services to send email reminders. The README documents each service as a table of web addresses (endpoints) showing what each one does and whether a logged-in user is required.
A notable design rule is that each service has its own separate database, here MongoDB, so no service can reach into another's data directly. They only communicate through their published interfaces.
The rest of the README covers the supporting infrastructure that holds the small services together. A Config service keeps all the settings in one central place and can even change them while the app is running. An Auth service handles logging in and issuing security tokens, using a standard called OAuth2, both for human users and for the services to trust each other. An API Gateway acts as the single front door, taking incoming requests and routing them to the right service behind the scenes. Together these pieces demonstrate common patterns that distributed systems need, which is why the project is widely used as a reference for learning Spring Cloud.
Where it fits
- Study how to split a Java application into microservices where each service owns its own separate database.
- Learn how to wire together Spring Boot services with a shared Config service, API Gateway, and Auth service.
- Use it as a starter template for your own microservice-based Java project with Spring Cloud infrastructure already wired up.
- Understand how OAuth2 authentication works across multiple services that need to trust each other.