-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
2,218 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,136 @@ | ||
# crypto-wallet | ||
|
||
A demo crypto wallet app using with teaching purposes. This app allows clients to manage their crypto currency portfolio. It uses [Coinmarketcap API](https://coinmarketcap.com/api/) for getting the updated cryptocurrencies quotation. | ||
|
||
It provides the following functionalities: | ||
|
||
* managing users (CRUD operations, uses for admins) | ||
* buy, sell and transfer crypto currencies | ||
* allow users to see their portfolio balance (the quotation of their cryptocurrencies portfolio converted to USD) | ||
* allows users to see their transaction history | ||
|
||
## Tech Stack | ||
|
||
* Java 11 | ||
* Spring Boot | ||
* Postgres | ||
* Kafka | ||
* Docker | ||
|
||
## Architecture | ||
|
||
The following diagram shows the systems architecture: | ||
|
||
![Alt text](diagrams/cw-architecture.png?raw=true "Architecture") | ||
|
||
## Data Model | ||
|
||
The following diagram shows the data model: | ||
|
||
![Alt text](diagrams/cw-data-model.png?raw=true "Title") | ||
|
||
## Run the app | ||
|
||
1. Start containers using docker compose: | ||
|
||
``` | ||
docker-compose up | ||
``` | ||
|
||
2. Run the application | ||
|
||
``` | ||
mvn spring-boot:run | ||
``` | ||
|
||
It runs the application on http://localhost:8080 | ||
|
||
## API | ||
|
||
* 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 | ||
``` | ||
|
||
## Extra notes | ||
|
||
* A ready [docker-compose](docker-compose.yml) 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](postman-collection/crypto.postman_collection.json) is provided. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: '3.7' | ||
|
||
services: | ||
|
||
cw-postgres: | ||
image: postgres:latest | ||
environment: | ||
- "TZ=Europe/Amsterdam" | ||
- "POSTGRES_USER=root" | ||
- "POSTGRES_PASSWORD=root" | ||
- "POSTGRES_DB=cryptodb" | ||
ports: | ||
- 45432:5432 | ||
volumes: | ||
- ./sql:/docker-entrypoint-initdb.d | ||
|
||
cw-adminer: | ||
image: adminer | ||
restart: always | ||
ports: | ||
- 8083:8080 | ||
|
||
cw-zookeeper: | ||
image: wurstmeister/zookeeper | ||
ports: | ||
- 2181:2181 | ||
|
||
cw-kafka: | ||
image: wurstmeister/kafka | ||
ports: | ||
- 9092:9092 | ||
environment: | ||
KAFKA_BROKER_ID: 0 | ||
KAFKA_ZOOKEEPER_CONNECT: cw-zookeeper:2181 | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT | ||
KAFKA_ADVERTISED_LISTENERS: INSIDE://localhost:19092,OUTSIDE://localhost:9092 | ||
KAFKA_LISTENERS: INSIDE://0.0.0.0:19092,OUTSIDE://0.0.0.0:9092 | ||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE | ||
KAFKA_LOG_DIRS: /kafka/kafka-logs | ||
KAFKA_DELETE_TOPIC_ENABLE: "true" | ||
KAFKA_DEFAULT_REPLICATION_FACTOR: 1 | ||
KAFKA_NUM_PARTITIONS: 3 | ||
links: | ||
- cw-zookeeper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.