A Spring Boot + gRPC demo trading system built as a multi-module Maven project. It shows how to share protobuf contracts, expose gRPC services, call them from another service, and bridge gRPC to REST/SSE.
- Shared protobuf contracts in one module
- gRPC server implementations for users and stock prices
- REST gateway that consumes gRPC services
- Unary RPCs and server-streaming RPCs
- H2-backed persistence for user data
- Integration tests for gRPC and SSE flows
| Module | Responsibility |
|---|---|
proto |
Protobuf messages and generated gRPC classes |
user-service |
gRPC user service with H2 + JPA storage |
stock-service |
gRPC stock service with in-memory prices and live updates |
aggregator-service |
REST API that calls the gRPC services |
REST client -> aggregator-service -> gRPC -> user-service / stock-service
aggregator-servicehandles HTTP requests.user-servicestores users and portfolio items in H2.stock-serviceserves prices from memory and streams updates.
- Java 21
- Spring Boot 3.5
- gRPC
- Protocol Buffers
- Spring Data JPA
- H2 database
| Endpoint | Description |
|---|---|
GET /user/{id} |
Fetch user information |
POST /trade |
Buy or sell a stock |
GET /stock/updates |
Stream live stock updates as SSE |
user.UserServiceGetUserInformationTradeStock
stock.StockServiceGetStockPriceGetPriceUpdates
Build and test everything:
mvn clean testRun a specific service:
mvn spring-boot:run -pl user-service
mvn spring-boot:run -pl stock-service
mvn spring-boot:run -pl aggregator-serviceuser-serviceuses H2, so data resets when the app stops.stock-servicekeeps prices in memory, so its state also resets on restart.- The project is intended as a learning and portfolio demo for gRPC in Spring Boot.