Diary-based API that utilizes Artificial Intelligence to detect the sentiment analysis of the user’s diary entry. This project used Node.js, Express, PostgreSQL, and Sequelize.
You need Node.js/NPM and Git installed into your system. Also, go to IBM Cloud to register and sign up for the free tier service for their Tone Analyzer. Remember to get your API Key and API URL!
To run this application:
- In your terminal type
git clone https://github.com/Ali-Aftab/myDiary.git
to clone it to your computer. - Then type
cd myDiary
to access the folder - To install the required modules type
npm i
- Make a new PostgreSQL database by writing
createdb mydiary
- Create a .env file by typing
touch .env
to store your secret keys - In the .env file type
SECRET_JWT_KEY=|ENTER-YOUR-KEY-HERE|
IBM_WATSON_API_KEY=|ENTER-YOUR-APIKEY-HERE|
IBM_WATSON_API_URL=|ENTER-YOUR-PERSONAL-IBM-URL-HERE|
- Type
npm run start-dev
in your terminal and you can use the API!
First, we recommend installing Postman to easily test out the API. Remember to add localhost:8000
to the URL before typing in the API path. (/api/auth/signup
=>localhost:8000/api/signup
)
How to signup and login.
- POST
/api/auth/signup
allows anyone to make an account
-Requires an email and password key inside the body
-Example: {email: [email protected], password: password1}
- POST
/api/auth/signin
when logged in, the response will give the user an access token.
-Requires an email and password key inside the body. You will receive an x-access-token. For all routes below you must place your token in the header.
-The x-access-token lasts for 24 hours.
-Example: {x-access-token: |X-ACCESS-TOKEN-KEY|}
NOTE: All Routes below require your x-access-token in the header!
- POST
/api/entry/newEntry
allows registered user to submit a diary entry
-Requires a diary entry and is assigned to the message key in the body.
-Example: {message: "I love Tacos, it makes me think better during the day!"}
- GET
/api/entry/listAll
allows a user to view all their previous entries and the overall tone for each one.
-Will provide the entryToneId (will be labeled as "id" in the JSON) for each one
- GET
/api/entry/sentencetone/:entryToneId
allows a user to see the tone for each sentence written in one entry.
-Replace:entryToneId
with the id in the URL.
- GET
/api/analyze/search/entries/
allows a user to search their diary entries for any particular word. -Requires a word to be searched and assigned to the searchQuery key in the body.
-Example: {searchQuery: "taco"}
- GET
/api/analyze/search/sentences/
allows a user to search their diary entries for any particular word. Will only provide the exact sentences that match with the searched word.
-Requires a word to be searched and assigned to the searchQuery key in the body.
-Example: {searchQuery: "taco"}
- GET
/api/analyze/averagetone
allows a user to find their average tone from all their diary entries.
-Will showcase the average tone for all 8 tones.
- GET
/api/analyze/findToneMatch
allows a user to find all sentences within their entries that emit a certain tone -Tone's that a user can pick from are: "anger", "disgust", "fear", "joy", "sadness", "analytical", "confident", or "tentative"
-Requires a selected tone and assigned to the tone key in the body.
-Example: {tone: "joy"}