Spring boot application with PostgreSQL DB to track mood. This application exposes APIs that can be used to create a full stack Mood Tracker Application.
POST /api/v1/auth/signup
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your unique username |
email |
string |
Required. Your unique email |
password |
string |
Required. Password for account |
role |
List of roles |
Role to be provided to user (ROLE_MOD,ROLE_USER,ROLE_ADMIN) |
POST /api/v1/auth/signin
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your username |
password |
string |
Required. Your password |
This will return some parameters, of which one is accessToken
. This will be authorization bearer token for further use of API by each user. This is JWT. This token is valid of 1 day only for now.
Create mood for today. If mood for today's date already added it will throw error.
POST /api/v1/mood
Parameter | Type | Description |
---|---|---|
feeling |
string/int |
Required. Mood value |
notes |
string |
Notes for today. |
Mood value can be VERY_SAD/0, SAD/1, NEUTRAL/2, HAPPY/3, VERY_HAPPY/4.
You also need to authorize this request.
Authorization | Type | Description |
---|---|---|
Required | Bearer Token |
accessToken from SignIn Request |
This will return all saved moods of current user.
GET /api/v1/mood
Parameter | Type | Description |
---|---|---|
startDate |
string |
Filter by Start Date |
endDate |
string |
Filter by End Date. |
feeling |
string |
Filter by Feeling. |
E.g.: /api/v1/mood?startDate=2023-05-05&endDate=2023-05-16&feeling=very_sad
You also need to authorize this request.
Authorization | Type | Description |
---|---|---|
Required | Bearer Token |
accessToken from SignIn Request |
This will return mood by mood id. This will only succeed if mood id belongs to authorized user.
GET /api/v1/mood/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Mood ID |
You also need to authorize this request.
Authorization | Type | Description |
---|---|---|
Required | Bearer Token |
accessToken from SignIn Request |
Update any previously created mood by mood id. This will only succeed if mood id belongs to authorized user.
PUT /api/v1/mood/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Mood ID |
Provide these values in request body to update mood.
Parameter | Type | Description |
---|---|---|
feeling |
string |
New mood value |
notes |
string |
New notes for this mood |
You also need to authorize this request.
Authorization | Type | Description |
---|---|---|
Required | Bearer Token |
accessToken from SignIn Request |
Delete any previously created mood by mood id. This will only succeed if mood id belongs to authorized user.
PUT /api/v1/mood/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Mood ID |
Clone the project
git clone https://github.com/theankitbhardwaj/MoodGuardian
Create .env files in ./src/main/resources and ./docker folder using examples provided.
Go to the docker directory under project root
cd ./docker
Docker Build
docker-compose build
Start the containers
docker-compose up
Also, please insert roles in Roles table by using below SQL Statements for the first time setting up database.
INSERT INTO roles(name) VALUES('ROLE_USER');
INSERT INTO roles(name) VALUES('ROLE_MODERATOR');
INSERT INTO roles(name) VALUES('ROLE_ADMIN');