- CQRS (Command Query Responsibility Segregation) is an architectural pattern that separates a system into two parts: one for updating data (commands) and another for reading data (queries).
- CQRS is implemented in this project with running on Docker and it provides the necessary components to build an event-driven handling with Apache Kafka
Method | Url | Description | Valid Request Body | Valid Request Params | Valid Request Params and Body | No Valid Request Params and Body |
---|---|---|---|---|---|---|
POST | /api/v1/openBankAccount | Open a Bank Account | Info | |||
PUT | /api/v1/depositFunds/{id} | Deposit Fund to the Account | Info | |||
PUT | /api/v1/withdrawFunds/{id} | Withdraw Fund from Account | Info | |||
DELETE | /api/v1/closeBankAccount/{id} | Close Account | Info | |||
GET | /api/v1/bankAccountLookup/ | Get All Accounts | Info | |||
GET | /api/v1/bankAccountLookup/{id} | Get Account By Id | Info | |||
GET | /api/v1/bankAccountLookup/byHolder/{account_holder} | Get Account By Holder | Info | |||
GET | /api/v1/bankAccountLookup/withBalance/GREATER_THAN/{value} | Get Account By Balance Greather Then Value | Info | |||
GET | /api/v1/bankAccountLookup/withBalance/LESS_THAN/{value} | Get Account By Balance Less Then Value | Info | |||
GET | /api/v1/restoreReadDb | Restore Database By Read | Info |
- Core
- Spring
- Spring Boot
- Spring Data
- Spring Data JPA
- Spring
- Database
- Mysql
- Mongodb
- Kafka
- Lombok
- Docker
http://localhost:5000/api/v1/openBankAccount
{
"accountHolder" : "Account Holder 1",
"accountType" : "SAVINGS",
"openingBalance" : 50.0
}
http://localhost:5000/api/v1/closeBankAccount/{id}
http://localhost:5001/api/v1/bankAccountLookup/byId/{id}
http://localhost:5001/api/v1/bankAccountLookup/byHolder/{account_holder}
http://localhost:5001/api/v1/bankAccountLookup/withBalance/GREATER_THAN/{value}
http://localhost:5001/api/v1/bankAccountLookup/withBalance/LESS_THAN/{value}
http://localhost:5000/api/v1/depositFunds/{id}
{
"amount" : 150.0
}
http://localhost:5000/api/v1/withdrawFunds/{id}
{
"amount" : 50.0
}
http://localhost:5001/api/v1/bankAccountLookup/
http:localhost:5000/api/v1/restoreReadDb
There are 2 ways to run the app.
- Install mysql in your computer
- Install mongodb in your computer
- Run only Zookeeper and Apache Kafka from docker-compose.yml file
- Download your project from this link
https://github.com/Rapter1990/cqrs-example
- Go to the project's home directory :
cd cqrs-example
- Go to the bank-account :
cd bank-account
- Create a jar file under bank-account directory though this command
mvn clean install
- Run the project though this command
mvn spring-boot:run
- Send any request of collection under postman collections folder through Postman
- Show data from both mongodb by following all these commands shown below
-> Open Mongodb Comprass
-> Create a new connection (mongodb://localhost:27017)
-> Show data from eventStore collection of bankAccount database
- Show data from both mongodb by following all these commands shown below
-> Open Mysql Workbench
-> Use default connection
-> Show data from bank_account table of bankAccount database
- Download your project from this link
https://github.com/Rapter1990/cqrs-example
- Go to the project's home directory :
cd cqrs-example
- Go to the bank-account directory :
cd bank-account
- Run docker-compose though this command
docker-compose up --build
- Send any request of collection under postman collections folder through Postman
- Show data from both mongodb by following all these commands shown below
-> docker exec -it mongo-container bash
-> mongosh
-> show dbs
-> use bankAccount
-> show collections
-> db.eventStore.find({})
- Show data from both mysql by following all these commands shown below
-> docker exec -it mysql-database mysql -uroot -p
-> Enter password: password defined in database
-> USE bankAccount
-> show tables;
-> SELECT * FROM bank_account;