A real-time sentiment analysis system that analyzes public opinion on polarizing topics from Reddit using multiple NLP models.
This project provides a web-based tool that:
- Scrapes posts from Reddit using PRAW API
- Analyzes sentiment using multiple NLP models (VADER, TextBlob, BERT)
- Stores data efficiently in PostgreSQL database
- Visualizes public opinion trends with interactive charts
- Supports both topic-based search and subreddit-specific analysis
- Backend: Python, Flask
- Frontend: React.js, Vite, Material-UI, Chart.js
- NLP: NLTK, TextBlob, HuggingFace Transformers
- Data Processing: pandas, numpy
- Database: PostgreSQL
- Web Scraping: PRAW (Reddit API)
EECS 4080/
├── backend/
│ ├── api/ # API endpoints
│ ├── models/ # Database models
│ ├── scrapers/ # Reddit scraping modules
│ ├── app.py # Flask application
│ └── db_manager.py # Database management tools
├── frontend/
│ ├── src/ # React source code
│ ├── public/ # Static files
│ └── package.json # Dependencies
├── data/ # Data storage directory
├── requirements.txt # Python dependencies
└── test_api.py # API testing script
- Search All Reddit: Find posts about any topic across all subreddits
- Specific Subreddit: Analyze posts from a particular subreddit
- Topic Examples: climate change, vaccines, AI, politics, etc.
- VADER: Rule-based sentiment analysis
- TextBlob: Machine learning-based sentiment
- BERT: Advanced transformer-based sentiment and emotion classification
- PostgreSQL Database: Production-ready database with advanced features
- Duplicate Prevention: Avoids analyzing the same post twice
- Session Tracking: Complete history of all analyses
- Fast Queries: Efficient search across all stored data
- Sentiment Charts: Pie charts for each sentiment model
- Data Tables: Detailed view of posts and sentiment scores
- Real-time Updates: Immediate results after analysis
- Python 3.8+
- Node.js 14+
- Reddit API credentials
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up Reddit API credentials in
.envfile:REDDIT_CLIENT_ID=your_client_id REDDIT_CLIENT_SECRET=your_client_secret REDDIT_USERNAME=your_username REDDIT_PASSWORD=your_password REDDIT_USER_AGENT=your_user_agent -
Start the backend server:
cd backend python app.py
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
- Start backend:
cd backend && python app.py(runs on port 5001) - Start frontend:
cd frontend && npm run dev(runs on port 5173) - Open browser to
http://localhost:5173
Use the database manager to explore your data:
cd backend
python db_manager.py stats # Show database statistics
python db_manager.py history # Show analysis history
python db_manager.py search "topic" # Search posts by topic
python db_manager.py latest # Show latest analysisTest the API endpoints:
python test_api.pyGET /api/health- Health checkPOST /api/analyze- Run sentiment analysisGET /api/results- Get latest resultsGET /api/history- Get analysis historyGET /api/search- Search posts by topicGET /api/stats- Get database statistics
- User Input: Topic, post limit, search type
- Reddit Scraping: Fetch posts using PRAW API
- Sentiment Analysis: Apply VADER, TextBlob, BERT models
- Database Storage: Save to PostgreSQL with session tracking
- Results Display: Show charts and tables in frontend
This project is part of EECS 4080 Computer Science Project at York University.
- Student: Aditya Manjrekar (manjrek5@my.yorku.ca)
- Supervisor: Dr. Aijun An (aan@yorku.ca)