https://github.com/shpota/abcdator
A REST API that performs math operations
https://github.com/shpota/abcdator
algorithms http4k kotest kotlin
Last synced: over 1 year ago
JSON representation
A REST API that performs math operations
- Host: GitHub
- URL: https://github.com/shpota/abcdator
- Owner: Shpota
- License: apache-2.0
- Created: 2020-07-30T16:31:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-02T07:09:29.000Z (almost 6 years ago)
- Last Synced: 2025-02-22T23:29:39.170Z (over 1 year ago)
- Topics: algorithms, http4k, kotest, kotlin
- Language: Kotlin
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: .github/README.md
- License: LICENSE
Awesome Lists containing this project
README
# abcdator [](https://github.com/Shpota/abcdator/actions?query=workflow%3Abuild)
A REST API that performs math operations. Implemented as
a part of a technical interview process.
## Build & Run
In order to build and run the application, you need to have
`Docker` on your machine.
### Build:
```sh
docker build --tag abcdator .
```
### Run:
```sh
docker run -p 8000:8000 abcdator
```
The REST API of the application will be available on
port 8000 with 3 endpoints:
- `/calculate/base`
- `/calculate/custom-1`
- `/calculate/custom-2`
Here are examples of `curl` queries to different substitute
expressions.
Base:
```sh
curl -X GET "http://localhost:8000/calculate/base?A=true&B=true&C=false&D=1.3&E=1&F=1"
```
Custom 1:
```sh
curl -X GET "http://localhost:8000/calculate/custom-1?A=true&B=true&C=false&D=1.3&E=1&F=1"
```
Custom 2:
```sh
curl -X GET "http://localhost:8000/calculate/custom-2?A=true&B=true&C=false&D=1.3&E=1&F=1"
```
## Architecture
The application consists of a business logic layer and
an HTTP layer.
The business logic layer operates with `predicates` and
`formulas` abstractions which represent correspondingly
boolean mappings like `A && B && !C => H` and numeric
formulas like `K = D + (D * (E - F) / 25.5)`. Predicates
and formulas can then be passed to the `execute()` function
which would produce a result based on the input.
The HTTP layer is responsible for user-facing API, input validation,
and HTTP server. It binds REST paths to the `execute()` function
and predicates/formulas based on the selected set of rules
(base/custom).
## Technologies
The application is implemented in `Kotlin` using the `http4k`
library. It is built and run using `Docker`. It is covered with
`Kotest`-based unit tests.