This project is a full-stack application that performs sentiment analysis on user-input text. It consists of a React frontend and a Python Flask backend.
The frontend is built with React and TypeScript, styled using Tailwind CSS, and structured with modular components.
frontend/ ├── public/ ├── src/ │ ├── components/ │ │ ├── SentimentForm.tsx │ │ └── SentimentResult.tsx │ ├── App.tsx │ ├── index.tsx │ └── types.ts ├── package.json ├── tsconfig.json └── README.md
- TypeScript for type safety
- Modular component structure
- Tailwind CSS for styling
-
Navigate to the frontend directory:
-
cd frontend
-
Install the required packages:
npm install -
Install TypeScript and type definitions:
npm install --save-dev typescript @types/react @types/react-dom @types/node
- From the frontend directory, run:
npm startThe application will be available at http://localhost:3000.
- App.tsx: The main component that renders the application structure and manages the overall state.
- SentimentForm.tsx: Renders the form for text input and handles the sentiment analysis request.
- SentimentResult.tsx: Displays the results of the sentiment analysis, including a visual representation of the sentiment score.
- The types.ts file contains TypeScript interfaces used throughout the application, including:
export interface AnalysisResult { text: string; sentiment: number; sentiment_label: string; }
The application uses Tailwind CSS for styling. The main styles are applied in the individual component files.
To run the frontend tests:
npm test
To create a production build:
npm run build
This will generate optimized static files in the build directory.
The backend is built with Python using the Flask framework and TextBlob for sentiment analysis.
-
Navigate to the backend directory:
cd backend -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate -
Install the required packages:
pip install -r requirements.txt
From the backend directory, run:
python run.py
The server will start on http://localhost:5000.
- Ensure both the backend and frontend servers are running.
- Open a web browser and go to
http://localhost:3000. - Enter text in the provided textarea and click "Analyze".
- The sentiment analysis results will be displayed below the input field.
The backend provides a single API endpoint:
- URL:
/analyze - Method: POST
- Body: JSON object with a
textfield - Response: JSON object with
text,sentiment(score), andsentiment_label
Example curl request:
curl -X POST -H "Content-Type: application/json" -d '{"text":"I love this product!"}' http://localhost:5000/analyze
From the backend directory, run:
python -m unittest test_app.py
From the frontend directory, run:
npm test
- Implement user authentication - DONE
- Add support for analyzing multiple texts at once
- Integrate with social media APIs for real-time sentiment analysis
- Improve sentiment analysis accuracy with machine learning models
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.

