API for managing foreign exchange for currencies
- Setup enviroment variables
- Run
docker-compose up
to start app
- Install Java 8 and Postgresql
- Setup environment variables
- Create DB and user, then import sql dump to DB
- Run
gradlew build
thengradlew test
- Run
gradlew bootRun
to start app
App will be running on port 8080.
GET /api/v1/currency-pairs/
List all currency pairs.
POST /api/v1/currency-pairs/
Insert new currency pair.
Request body structure:
{
"from": "base-currency",
"to": "quote-currency"
}
DELETE /api/v1/currency-pairs/{id}
Delete currency pair by id.
GET /api/v1/exchange-rates/
List all daily exchange rates.
POST /api/v1/exchange-rates/
Insert new exchange rates.
Request body structure:
{
"date": "yyyy-MM-dd",
"from": "base-currency",
"to": "quote-currency",
"rate": 1.2345
}
GET /api/v1/exchange-rates/track/?date=yyyy-MM-dd
List all exchange rates to be tracked.
GET /api/v1/exchange-rates/trend/?from=str&to=str
List exchange rate trend.
There are two relations, currency_pair and exchange_rate. Relation currency_pair stores base and quote currency while relation exchange_rate stores exchange rate with specific date and currency pair (foreign key from relation currency_pair). The relation between currency_pair and exchange_rate is One-to-Many because a single currency pair can have many exchange rates with different dates.
Environment variables contain database information. Before running the app, please create .env
file (by copying and modifying .env.example). See .env.example for more details.
If you want to run the app locally, you should export the environment variables by exporting .env variables in bashrc.