This is a proposal of a bank API written using reactive programming and concurrent operations in memory. It exposes a web interface to the external world and handles multiple requests concurrently. Bear in mind that this project was not meant to be ran in a distributed environment since it's data is kept locally without persistance after killing the process.
- Used an in-memory data store. (will not work in distributed systems)
- Chose atomic data models with append-only structures to avoid dealing with
ACIDtransactions. - Wrote in Java 8 using
Streamsand immutable objects for composability and thread safety. - Chose to use async request handling with
JavalinandComputableFutureto allow more web concurrency. - Designed based on onion/hexagonal architecture. (core domain and infra classes are separeted)
- Followed
SOLIDprinciples such as dependency injection and inversion. - Handled debit account operations with a single Java
synchronizedfor locking to avoid deadlocks. - Used
TDDwithJUnitandMockitofor unit and integration tests.
| Method | Resource | Description |
|---|---|---|
| POST | /accounts | Creates an account |
| GET | /accounts/:id/balance | Retrieves the account balance |
| POST | /transfers | Transfer money between accounts |
| POST | /load | Load money into the account |
| POST | /unload | Unload money from the account |
$ ./gradlew build$ ./gradlew runDefault port
8080
$ ./gradlew test