Uncover Reddit's pulse instantly. This application allows you to track mentions of any term on Reddit, analyze sentiment, view aggregated metrics, and leverage Google's Gemini AI for summaries, key themes, and contextual Q&A.
Live Demo: [https://reddit-mention-tracker.vercel.app/] Video Walkthrough: [https://youtu.be/JuObTRygk4w]
- Reddit Search: Fetches recent (last 7 days) public submissions and comments mentioning your search term.
- Comprehensive Metrics:
- Total mention count
- Average Reddit score
- Top subreddits & authors
- Sentiment analysis (VADER): average score, overall label (positive/negative/neutral/mixed), distribution
- Submission vs. comment breakdown
- AI-Powered Insights :
- Executive Summary of mentions
- Key Discussion Themes
- Contextual Q&A based on retrieved mentions
- Detailed Mentions List: Browse individual mentions with links, scores, sentiment, and author details (paginated).
- Search Term Highlighting: Your search term is highlighted in titles and content.
The application follows a client-server architecture:
-
Frontend (Client):
- Framework: React with TypeScript
- Key Libraries: Axios (API calls), React Router (navigation),
date-fns(date formatting),react-markdown(rendering AI output),framer-motion(animations). - Responsibilities: User interface, handling user input, making API requests to the backend, displaying results, caching simplified mention data in
localStoragefor Q&A context. - Location:
frontend/trackerdirectory.
-
Backend (Server):
- Framework: Django (Python)
- Key Libraries: Django REST framework (APIs), PRAW (Reddit API interaction), NLTK (VADER for sentiment analysis),
python-dotenv(environment variables),google-generativeai(Gemini API). - Responsibilities: Exposing REST APIs, fetching data from Reddit, performing sentiment analysis, interacting with Google Gemini (if configured), aggregating metrics.
- Location:
backend/trackerdirectory.
-
External Services:
- Reddit API: For fetching mentions.
- Google Gemini API : For AI-powered summaries, themes, and Q&A.
Data Flow:
- User searches on React frontend.
- React calls Django API (
/api/reddit-mentions/). - Django uses PRAW (Reddit) & NLTK (sentiment) and also calls Gemini for summary/themes.
- Django returns JSON data to React.
- React displays data & caches simplified mentions.
- For Q&A: React sends question & cached mentions to Django API (
/api/reddit-qna/). - Django calls Gemini for an answer, returns it to React.
- Python 3.12+ and Pip
- Node.js (v16+) and npm (or yarn)
- Git
- A Reddit API Application:
- Go to Reddit Apps
- Click "are you a developer? create an app..."
- Fill in the details (name, choose "script" type, redirect uri e.g.,
http://localhost:8000). - Note your Client ID (under personal use script) and Client Secret.
- A Google Gemini API Key :
- Go to Google AI Studio.
- Create an API key.
-
Clone the repository:
git clone https://github.com/anurag6569201/Reddit_Mention_tracker.git cd backend/ -
Create and activate a virtual environment:
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
-
Install Python dependencies:
cd backend/tracker/ pip install -r requirements.txt -
Set up environment variables: Create a
.envfile in your backend project root (e.g.,backend/.env) with the following:REDDIT_CLIENT_ID=rOVN-sdfsfsd... REDDIT_CLIENT_SECRET=sdkfbsd... REDDIT_USER_AGENT='sdf...' ENABLE_GEMINI_ANALYSIS=true GEMINI_API_KEY=sdfsdUs GEMINI_MODEL_NAME=gemini-2.0-flash GEMINI_MAX_INPUT_MENTIONS=25 # Other Backend settings (if any) REDDIT_SEARCH_LIMIT=30 REDDIT_COMMENT_REPLACE_LIMIT=30 REDDIT_TOP_AUTHORS_LIMIT=5 API_MENTIONS_LIMIT=50
-
Download NLTK VADER Lexicon (if not already present globally): Run the Django development server once. If VADER lexicon is missing, the console output from
views.pywill guide you, or you can run a Python Script:python download_nltk_data.py
-
Apply Django migrations:
python manage.py makemigrations python manage.py migrate
-
Run the Django development server:
python manage.py runserver
The backend API will typically be available at
http://127.0.0.1:8000/api/.
-
Navigate to the frontend directory:
cd frontend/tracker -
Install Node.js dependencies:
npm install
-
Configure API Base URL: The frontend
.envfile hasAPI_BASE_URLset tohttp://127.0.0.1:8000/api. Adjust this if your backend runs on a different port or domain. -
Start the React development server:
npm start
The frontend application will typically be available at
http://localhost:5173.
- Ensure both backend and frontend development servers are running.
- Open your browser and navigate to the frontend URL (e.g.,
http://localhost:5173). - You will see the Landing Page.
- Enter a search term (e.g., "Tesla", "AI ethics", "your brand") into the search bar and click "Search" or press Enter.
- The application will fetch and analyze mentions, displaying:
- AI-generated Summary & Themes .
- Core Metrics (total mentions, average score, etc.).
- Sentiment Analysis details.
- Community Hotspots (top subreddits and authors).
- A paginated list of individual mentions.
- Q&A :
- Scroll down to the "Ask About These Mentions" section.
- Type a question related to the mentions retrieved for your current search term (e.g., "What are common complaints?").
- Click "Ask AI". The AI will attempt to answer based only on the context of the displayed mentions.
- The Q&A history will be logged below the input form.
- Use the search bar in the header to perform new searches or clear the current search.
Key environment variables are managed in the backend/.env file:
REDDIT_CLIENT_ID: Your Reddit application's client ID.REDDIT_CLIENT_SECRET: Your Reddit application's client secret.REDDIT_USER_AGENT: A descriptive user agent for Reddit API requests.ENABLE_GEMINI_ANALYSIS:trueorfalseto enable/disable all Gemini AI features.GEMINI_API_KEY: Your Google Gemini API key .GEMINI_SUMMARY_MODEL_NAME: Specific Gemini model for summary/themes (default:gemini-1.5-flash-latest).GEMINI_QNA_MODEL_NAME: Specific Gemini model for Q&A (default:gemini-1.5-flash-latest).REDDIT_SEARCH_LIMIT: Max submissions to fetch from Reddit (default:25).GEMINI_MAX_INPUT_MENTIONS_FOR_SUMMARY: Max mentions to feed Gemini for summary (default:25).API_MENTIONS_LIMIT: Max mentions to return in the API response list (default:50).
Contributions are welcome! Please feel free to fork the repository, make changes, and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. (Create a LICENSE.txt file with the MIT license text if you choose this).