This chapter presents a real-world example. The functionality is only part of a large business use case: sports betting. The idea is to create three actors at the business’s core:
- The market is a sporting event with specific odds that can be bet against. For example, the Liverpool vs. Real Madrid soccer match has a market where bets can be placed on a home win, an away win, or a draw.
- The wallet represents a user’s account with their balance.
- The bet is the amount of money invested in a market and secured by a wallet.
These entities reside in a cluster, so they can communicate directly. To communicate with them from the outside, the application has ports: two gRPC services and one Akka HTTP service. Figure 12.1 shows the big picture of how everything is related.
This example is just the first step to give you insight into the process of beginning a professional project, including how to get started and what to focus on. Like any project, it will evolve later, further splitting some boundaries and blending others. So, the actors will also evolve. Let’s look at the definition of the actors and their protocols.
NOTE
The source code for this chapter is available at www.manning.com/books/akka-in-action-second-edition or https://github.com/franciscolopezsancho/akka-topics/tree/main/betting-house.