This project is an Emotion Classifier Web Application that analyzes text inputs and classifies them into specific emotional categories (e.g., "happy," "sad," "angry," etc.). The system uses machine learning with a Flask backend API for processing text predictions and a Next.js frontend for delivering an interactive user interface.
- Project Overview
- Technologies Used
- Prerequisites
- Backend Setup
- Frontend Setup
- Run the Application
- Project Folder Structure
- API Endpoints
- Backend: A Flask-based REST API that processes text input and predicts the class.
- Frontend: A Next.js-based web interface for user interaction with the prediction API.
- Goal: To take user input, send it to the backend for processing, and display the result dynamically with relevant visuals.
- Python 3.x
- Flask
- Scikit-learn (or any NLP libraries like spaCy, NLTK)
- JSON for API communication
- Node.js
- Next.js 15.1.0
- React.js
- Tailwind CSS
- Typescript
Before running this project, make sure you have the following installed:
- Python 3.x: Install Python
- Node.js & npm: Install Node.js
- Flask: Install Flask using pip (
pip install flask
) - Next.js: Comes with npm when installed.
- Git: Optional for cloning the repository.
Navigate to the backend folder:
cd C:\Users\<User>\emotionclassifier\backend
Install backend dependencies:
pip install flask scikit-learn
Run the Flask application:
python application.py
Backend is running at:
Navigate to the frontend folder:
cd C:\Users\<User>\emotionclassifier\frontend
Install frontend dependencies:
npm install
Run the Next.js development server:
npm run dev
Frontend is running at:
Open a terminal and run:
python application.py
Open another terminal and run:
npm run dev
Open your browser and visit:
http://localhost:3000
- Enter text in the frontend UI input box.
- The frontend sends a POST request to the Flask backend (/predict endpoint).
- The backend processes the text and returns a prediction.
- The frontend displays the prediction and relevant emoji based on the classification.
emotionclassifier/
│
├── backend/ # Flask API
│ ├── application.py # Main Flask app
│ ├── model.pkl # Serialized ML model (optional)
│ └── requirements.txt # Backend dependencies
│
├── frontend/ # Next.js frontend
│ ├── pages/ # React pages
│ ├── public/ # Static assets
│ ├── styles/ # CSS files
│ ├── package.json # Frontend dependencies
│ └── README.md # Frontend documentation
│
└── README.md # Main project README
Description: Accepts input text and returns the predicted class.
Request:
{
"text": "Sample input text"
}
Response:
{
"prediction": "happy",
"confidence": 0.95
}
- Debug Mode: This application uses Flask's development server. Do not use it in production. Deploy with WSGI servers like Gunicorn or uWSGI.
- Next.js Telemetry: Next.js collects anonymous telemetry data. Learn more here