Skip to content

mbaula/SentimentAnalyzer

Repository files navigation

Mental Health Journal

A journaling app that uses AI to analyze your entries. It detects sentiment, emotions, and topics to help you understand your mental health patterns.

Mental Health Journal

Features

  • Journal Entries: Write and save your thoughts privately
  • Sentiment Analysis: Tells you if your entry is positive or negative, with confidence scores
  • Emotion Detection: Picks out emotions from your writing (28 different emotions)
  • Topic Identification: Automatically tags what your entry is about
  • Clean UI: Simple, calming design that's easy on the eyes
  • Local Storage: Everything stays in your browser - nothing goes to external servers
  • Interactive Mascot: Cute animated dog that gives you motivational quotes

Screenshots

Main Application Interface

Main Interface

The main page with the mascot on the left and the journal form on the right. You can see the "AI Analysis Ready" status at the top when everything's connected.

Journal Entry with AI Analysis Results

AI Analysis Results

After you submit an entry, you get three cards showing the results: sentiment (positive/negative), emotions detected, and topics identified. All three appear side-by-side.

Past Entries View

Past Entries

All your past entries are saved here. Each one shows the text, when you wrote it, and the sentiment/emotions/topics that were detected. They're organized in a grid so you can scroll through them easily.

Quick Start

What You Need

  • Node.js (v16+) and npm
  • Python (v3.8+) and pip
  • The trained models should already be in the models/ folder or you can train them yourself using the notebooks in the notebooks/ folder.

Installation

  1. Get the code

    git clone <repository-url>
    cd Group4COMP377GroupProject
  2. Set up the frontend

    cd frontend
    npm install
  3. Set up the backend

    cd ../backend
    pip install -r requirements.txt

Running the Application

  1. Start the backend

    cd backend
    python main.py

    You should see it running on http://127.0.0.1:8000 or localhost:8000

  2. Start the frontend

    cd frontend
    npm run dev

    It'll open at http://localhost:3000

  3. Open it up

    • Go to http://localhost:3000 in your browser
    • Make sure the backend is running (you'll see "AI Analysis Ready" at the top)

Technology Stack

Frontend

Backend

Models

  • DistilBERT - Handles topic and emotion classification
  • TF-IDF + Linear SVM - Does the sentiment analysis
  • MultiLabelBinarizer - Encodes the multi-label outputs

🔌 API Endpoints

Here's what the backend can do:

  • GET /health - Check if everything's working
  • POST /api/topics/predict - Get topics from your entry
  • GET /api/topics/list - See all available topics
  • POST /api/emotions/predict - Get emotions from your entry
  • GET /api/emotions/list - See all available emotions
  • POST /api/sentiment/predict - Get sentiment (positive/negative)

API Docs

When the backend is running, check out:

  • Swagger UI: http://localhost:8000/docs - Interactive API docs
  • ReDoc: http://localhost:8000/redoc - Alternative docs view

API Docs

How It Works

Sentiment Analysis

Uses TF-IDF + Linear SVM trained on Sentiment140 data. It figures out if your entry is positive or negative and gives you a confidence score.

Emotion Detection

Runs a DistilBERT model we fine-tuned on GoEmotions data. It can pick out up to 28 different emotions from what you write.

Topic Identification

Another DistilBERT model that tags your entries with relevant topics. Helps you spot patterns over time. The datass was created with LLM models creating a synthetic dataset.

Development

Frontend Development

cd frontend
npm run dev      # Start dev server
npm run build    # Build for production

Backend Development

cd backend
python main.py   # Start development server

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors