This is a sentiment analysis application that allows users to analyze the sentiment of a given text. A product is rated by the customer, the sentiment analysis system assigns a sentiment to the rating. User can give feedback about the sentiment, and admin(s) can all feedbacks.
The frontend employs the Metamask extension via web3 to display the balance on the ETH wallet.
- Frontend is developed in react. React components use the restful API of the backend to fetch their data and authentication. Framework is React and language is Typescript.
- Backend: serves restful APIs for authentication, storing ratings and feedbacks and showing their list. Framework is Express and language is Typescript. Renaming of 'backend' is to be considered, since there is a third component as follows:
- Analyze-engine is a module implemented in Python that uses the open-source
transformers
library of Huggin-face to categorize the sentiment of a given sentence. This module provides restful API to receive texts and return sentiments.
Currently three modules need to be set up separately:
- Analyze-engine: Make sure the python dependencies are installed.
cd ./analyze-engine
, thenpython3 app.py
. Restful API will be provided over localhost:8001 - Backend:
cd ./backend
, thennpm run dev
. The backend will provide restful API over the localhost:8000 (details further below) - Frontent:
cd ./frontend
, thennpm run build
,npm run preview
: to enablehttp://localhost:4173/
human
: representing users who sign in.uuid
: unique string user IDname
is the usernamehashed_password
,role
: A string with eitheradmin
oruser
text
: This stores the ratings that users are able to add. Columns:id
,text
,userId
: theuuid
of the user that issued the rating.sentiment
: Enum that has four values:Undefined
,Good
,Bad
,Neutral
. Default isUndefined
, until the analyze-engine evaluation is received.
Feedback
: Users' feedback about the sentiment of their rating. -id
integer primary keycontent
: The text of the feedback,textId
: Foreign key to the rating that this feedback concerns.Feedback
andtext
have a one-to-one relationship.
- To signup:
POST
toapi/auth/signup
body
:{ name: string, password: string }
. To become an admin, sys-admins have to engage manually. - To login:
POST
toapi/auth/signin
withbody
:{ name: string, password: string }
. Response is:{token : string, isAdmin: string}
. Token is the jwt token to be saved locally in the browser.isAdmin
is eithertrue
orfalse
. - Putting a new feedback for a sentiment:
POST
toapi/feedback/new
, with the jwt token in header. Send the{textId: number, feedback:string}
in the body. Possible previous feedbacks will be overwritten. - Listing feedback:
POST
api/feedback/all
with the jwtToken. Response is a list ofFeedback
objects such as following:Feedback { id: number;content: string;originalText: string;sentiment: string;}
- To add a text:
POST
toapi/text/analyze
with the jwtToken in the header, and the text in the body. - To list texts of a user:
POST
toapi/text/all
with thejwtToken
in the header. Response is an array of prototype Text:Text {id: number,text: string,sentiment: string}
- Have the sentiment for a text calculated:
Post
tolocalhost:8001/analyze
, with{text:string}
. Response is:{text: string,sentiment: string,confidence: number}
- The backend has been fitted with the
jest
library and one sample test, that checks for thehealthy
signal, to demonstrate the ability of smoketesting. Theapp
object inbackend.setup.ts
is exported now to be testable.
Features that could not arrive soon enough:
- Expand testing to cover enough of the code, and log better.
- Use https, and hash the passwords on frontend before sending over the network.
- Dockerization: 3 docker containers for the 3 modules. Don't forget logging configurations.
- Benchmarking Docker Compose, Kubernetes and rivals, and making a decision there for the orchestration of dockers.
- Benchmarking and selection of a cloud service, then using Terraform or a similar tool to configure for the IaC.
- Benchmark the deployment tools based on the need, and make a decision (Github Actions, Gitlab, Jenkins)
- Add products and implement functionality to use the Metamask for purchasing them!