A demo crypto wallet app using with teaching purposes. This app allows clients to manage their crypto currency portfolio. It uses Coinmarketcap API for getting the updated cryptocurrencies quotation.
It provides the following functionalities:
- managing users (CRUD operations, uses for admins)
- buy, sell and transfer cryptocurrencies
- allow users to see their portfolio balance (the quotation of their cryptocurrencies portfolio converted to USD)
- allows users to see their transaction history
- Java 17
- Spring Boot
- Postgres
- Docker
The following diagram shows the systems architecture:
The following diagram shows the data model:
- Start containers using docker compose:
docker-compose up
- Run the application
You'll need to have configured the following env variables before running the app:
DB_URL
DB_USER
DB_PASSWORD
COINMARKETCAP_URL
: Coinmaerkap api urlCOINMARKETCAP_API_KEY
: you have to generate one API KEY on Coinmaketcap Web Site
Then execute:
./gradlew bootRun
It runs the application on http://localhost:8080
We use Flyway for database migrations. It runs the migration on application startup, so remember to have the dockers up when running the app.
- Healthcheck
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/healthcheck
- Get user by id
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/users/:userId
- Get all users
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/users
- Create user
curl -X POST -H "Content-Type: application/json" \
-d '{"username": "pepe", "password": "pass1234", "email": "[email protected]"}' \
http://localhost:8080/users
- Update user
curl -X PUT -H "Content-Type: application/json" \
-d '{"username": "pepe", "password": "pass1234", "email": "[email protected]"}' \
http://localhost:8080/users/:userId
- Delete user
curl -X "DELETE" http://localhost:8080/users/:userId
- Get quotes
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/cryptocurrencies/quotes
- Get portfolio
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/portfolios/:userId
- Get transaction history
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/transactions/8
- Transfer
curl -X POST -H "Content-Type: application/json" \
-d '{"issuer": "88", "receiver": "2", "cryptocurrency": "Huobi Token", "amount": 10}' \
http://localhost:8080/transactions/transferences
- Buy
curl -X POST -H "Content-Type: application/json" \
-d '{"userId": 3, "cryptocurrency": "Bitcoin", "amountInUsd": 100000}' \
http://localhost:8080/transactions/buys
- Sell
curl -X POST -H "Content-Type: application/json" \
-d '{"userId": 3, "cryptocurrency": "Bitcoin", "amount": 1}' \
http://localhost:8080/transactions/sells
This project uses Spotless to enforce a consistent programming style. Under the hood, it is configured to use Google Java Format. We have the following commands:
- check formatting violations:
./gradlew spotlessCheck
- apply formatting:
./gradlew spotlessApply
By default, this plugin is attached to the verify phase
of maven lifecycle.
-
A ready docker-compose is provided. It contains all the components ready for local development. It also contains dummy data for playing around with the app.
-
Also, a postman collection is provided.