How caueferreira/akka-bank works
Project Type and Purpose
Akka Bank is a concurrent and event-sourced financial operations application built using the [Akka](https://akka.io/) framework. The primary purpose of the project is to emulate financial operations such as reading account balances, crediting, debiting, and transferring funds between accounts. It ensures idempotence, parallelism, and concurrency in its operations, leveraging event sourcing to maintain immutable event records.
File Structure Analysis
• Top-Level Directories:
• .circleci, .github: Configuration for CI/CD pipelines and GitHub integrations.
• src: Contains all source code and tests.
• main/java: Application source code.
• actors: Defines Akka actors like Account, AccountSupervisor, and TransferSaga.
• commands, requests, responses: Define the various command, request, and response types used in operations.
• server: Contains server setup (BankServer.kt, Main.kt).
• source: Includes EventStore.kt for event sourcing.
• test/java: Unit tests for actors, commands, requests, and the event store.
• test/resources: Includes Mockito extensions for testing.
• pom.xml: Maven configuration for project dependencies and build.
• .gitignore, README.md: Standard project files.
• Architectural Patterns:
• Actor Model: Utilizes Akka actors (Account, AccountSupervisor, TransferSaga) to handle concurrent operations.
• Event Sourcing: Implements an EventStore to manage immutable events, reconstructing account states from event histories.
• Saga Pattern: Uses TransferSaga to manage complex transfer transactions and compensations.
README Insights
The README elaborates on:
• Core Operations: READ, CREDIT, DEBIT, TRANSFER.
• Architecture: Emphasis on event sourcing, actor supervision, idempotent operations, and concurrency management.
• Technical Stack: Akka, Akka-Http, JUnit.
• Execution Details: Instructions to run the server and tests.
a. Identify Main Components:
• Frontend (If Applicable): Not explicitly present; the focus is on backend operations.
• Backend Components:
• Actors:
• Account
• AccountSupervisor
• TransferSaga
• Event Store: EventStore
• Server: BankServer, Main
• External Services:
• Clients: Interaction points for sending requests.
• CI/CD Pipelines: CircleCI configurations.
b. Determine Relationships and Interactions:
• Client Requests: Sent to BankServer, which interacts with AccountSupervisor.
• AccountSupervisor: Manages Account actors and forwards events.
• TransferSaga: Handles transfer logic by coordinating Account actors.
• EventStore: Stores and retrieves events for accounts, enabling state reconstruction.
• Actors: Communicate asynchronously to handle operations, ensuring concurrency and idempotence.
c. Highlight Architectural Patterns:
• Actor Model: Enables concurrent processing of requests.
• Event Sourcing: Maintains a history of immutable events for state management.
• Saga Pattern: Manages long-running transactions and compensations in transfers.
d. Include Relevant Technologies:
• Frameworks/Libraries: Akka, Akka-Http, JUnit.
• Build Tools: Maven (pom.xml).
• CI/CD Tools: CircleCI.
• Testing Tools: Mockito for mocking in tests.
External Client
• Sends Requests to BankServer.
BankServer
• Routes requests to AccountSupervisor.
AccountSupervisor
• Manages Account actors.
• Forwards operations to appropriate Account.
Account Actors
• Handle Credit, Debit, Read operations.
• Interact with EventStore for event logging and retrieval.
TransferSaga
• Coordinates Transfer operations between two Account actors.
• Manages compensations in case of failures.
EventStore
• Stores all immutable events.
• Provides event history to Account actors for state reconstruction.
CI/CD Pipeline
• Represents automated testing and deployment via CircleCI.