Simple Personality-Test REST API for the Personality Test App built on Java17, Javalin Web Framework, ORM Lite, Jackson, and MariaDB
The API receives and returns only JSON application/json.
Each response JSON body has a status key which is an integer and a data key which contains the
data pertaining to that response.
Status value 200 means Success, with the requested information in the data key.
Status value 500 means that an error occurred, and it will return a string
description of the error under the data key.
This application uses MariaDB There is a dockerfile included and an exported SQL File pers_test_2022-09-27.sql.
- Install docker
- Run
docker compose up, to spin up a MariaDb and PhpMyAdmin container. - Access PhpMyAdmin by visiting localhost:8080 on your browser
- Use the
pers_testdatabase - Import the
pers_test_2022-09-27.sqlfile or copy its contents to import the questions.
Run the Main.java file, and you can access the routes/endpoints in REST clients at http://localhost:3030
/questionsUsed to fetch a list of simple personality-test questions.
Send a standard GET request to the /questions endpoint with no payload or body data.
Returns JSON with an array of 20 questions under the data key
{
"status": 200,
"data": [
{
"id": 1,
"text": "I prefer one-on-one conversations to group activities",
"created_on": "2022-09-26 13:58:06"
},
{
"id": 2,
"text": "I often prefer to express myself in writing",
"created_on": "2022-09-26 13:58:19"
},
{
"id": 3,
"text": "I seem to care about wealth, fame, and status less than my peers",
"created_on": "2022-09-26 13:58:37"
}
]
}
/evaluateUsed to evaluate the user's answers. Accepts input in JSON format. Content-Type has to be application/json
when calling this request with a JSON body.
The incoming JSON Body for the request should be as follows:
{
"answer_count": 5,
"answers": "true;false;true;true;true"
}
where answer_count is the number of questions that the user answered, and answers is a
concatenated string of "true" and "false" answers to the questions, separated by a semicolon;.
Any spaces in the answers string will be removed.
Returns the result of the analysis.
{
"status": 200,
"data": "Introverted"
}