A full-stack application for analyzing sentiment in tweets and text using AI models. Developed by Hüseyin ASLIM as part of the Başkent University BIL479 - Pattern Recognition course project.
- Text Sentiment Analysis
- Tweet URL Sentiment Analysis
- Twitter User Sentiment Analysis
- Visualization of sentiment results
- Multi-language support (English, Turkish, and more)
- Modern UI with light and dark mode
The project uses the cardiffnlp/twitter-xlm-roberta-base-sentiment model from the Hugging Face Transformers library. This model:
- Is based on XLM-RoBERTa architecture
- Supports multilingual sentiment analysis
- Classifies text into three categories: Positive, Neutral, and Negative
- Provides confidence scores for each sentiment category
- FastAPI
- Transformers
- PyTorch
- Pandas
- Matplotlib
- Playwright (for web scraping)
- ntscraper (for Twitter scraping)
- Next.js
- React
- Tailwind CSS
- shadcn/ui (UI components)
- Axios (API client)
├── backend/ # FastAPI backend
│ ├── main.py # Main API file
│ └── requirements.txt # Python dependencies
│
└── frontend/ # Next.js frontend
├── public/ # Static assets
├── src/ # Source code
│ ├── app/ # Next.js app router
│ ├── components/ # React components
│ ├── lib/ # Utilities
│ └── types/ # TypeScript types
└── package.json # Node dependencies
-
Navigate to the backend directory:
cd backend -
Install dependencies:
pip install -r requirements.txt
-
Install Playwright browsers:
playwright install
-
Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will be available at http://localhost:3000
GET /: Check if the API is running
POST /analyze/text: Analyze sentiment of provided text- Body:
{"text": "Your text here"} - Returns: Sentiment label, confidence scores, and visualization
- Body:
POST /analyze/tweet: Analyze sentiment of a tweet from URL- Body:
{"url": "https://twitter.com/username/status/tweetid"} - Returns: Tweet content, sentiment label, confidence scores, and visualization
- Body:
POST /analyze/user: Analyze sentiment of tweets from a specific user- Body:
{"username": "username", "max_results": 20} - Returns: User statistics, sentiment distribution, top positive/negative tweets with charts
- Body:
The backend can be deployed to any server that supports Python:
- Clone the repository
- Install the requirements:
pip install -r backend/requirements.txt - Install Playwright browsers:
playwright install - Run with Gunicorn (for production):
gunicorn -w 4 -k uvicorn.workers.UvicornWorker backend.main:app
The Next.js frontend can be deployed to Vercel or any hosting provider:
-
Build the application:
cd frontend npm run build -
Start the production server:
npm start
Alternatively, deploy directly to Vercel:
vercel- Python 3.9+
- FastAPI 0.104.1+
- Transformers 4.35.0+
- PyTorch
- Playwright 1.39.0+
- Other dependencies listed in
backend/requirements.txt
- Node.js 18+
- Next.js 14+
- React 18+
- Other dependencies listed in
frontend/package.json

