DEV Community

mari tang
mari tang

Posted on • Edited on

Initial planning for sentiment-chat

Alright, I'm working on a fun side project now. I'll be blogging my way through the process and the design decisions that I'm making. This is part 1.

First off, here's what I want from the app.

It's an NLP/sentiment analysis driven chat app. Two people will be able to use the app to communicate. However, instead of receiving another person's words, users will receive a block of color, based off of the results of a sentiment analysis or NLP library.

For starters, I'm planning on using sentiment. It'll return a comparative score, which is calculated by taking each word in a string, making a judgment on how positive/negative they are, and averaging all of those results to get a final score that lands somewhere between -5 (extremely negative) and 5 (extremely positive). It's only one number, but it's a floating point, so we'll be able to get a nice gradation of values along at least one axis.

Sentiment is supposed to be fairly fast, benching around 860k operations/sec on its creator's macbook pro. This should be essentially real-time for my usage.

Right now, I'm planning to implement sentiment as part of the client bundle, so users won't have to wait on network latency to see their colors. I'm imagining a flow that works something like this:

user input -> reducer (sentiment) -> state -> websockets connection -> chat partner (render it as color)

Today, I'm aiming to finish user input, reducer, state, and color-display functionality. I'll do websockets (or socket.io) next, then start work on finessing the UI/UX.

As far as the tech stack I'm on, it'll be React (with hooks) for the frontend, Node + Express for the backend, and userstorage to cache message history. At some point I might set up a database for chat history, but it doesn't matter that much for this kind of art-y project. Might be fun to export chat history as some kind of a gradient as well.

More to come in future posts.

Top comments (3)

Collapse
 
jochemstoel profile image
Jochem Stoel

This is cute. I have already made this app that you describe almost literally and I can read exactly where you're at. You're headed about right my only advice is to prevent unneccessary complexity. Don't use things you don't need.

I'll be blogging my way through the process and the design decisions that I'm making.

I followed you because I'd like to read this.

Collapse
 
leppercameron profile image
Cameron Lepper

That sounds pretty awesome! Really looking forward to seeing how this evolves!

Collapse
 
tttaaannnggg profile image
mari tang

thanks! I'm aiming to reach MVP by the end of the week!