Skip to content

murtuja55/SentimentSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SentimentSync - Full-Stack Sentiment Analysis Web App

A comprehensive social media sentiment analysis platform built with React, FastAPI, and machine learning.

πŸš€ Features

  • CSV Upload & Data Preview: Drag-and-drop CSV upload with automatic sentiment analysis
  • ML Model Training: Logistic Regression and Naive Bayes models with evaluation metrics
  • Interactive Dashboard: Real-time charts and sentiment distribution analytics
  • AI-Powered Insights: Claude API integration for intelligent analysis
  • Real-Time Social Search: Dynamic social media content generation with sentiment analysis
  • Trending Topics Discovery: Real-time trending topics from multiple platforms
  • Advanced Search: Multi-platform search with filtering options
  • Topic Insights: Comprehensive analysis with AI-powered summaries

πŸ› οΈ Tech Stack

Frontend

  • React 18 with Vite
  • TailwindCSS for styling
  • Lucide React for icons
  • Axios for API calls
  • Chart.js for data visualization

Backend

  • FastAPI for REST API
  • Python 3.12 with async support
  • NLTK for NLP preprocessing
  • scikit-learn for ML models
  • TextBlob for sentiment analysis
  • Pandas for data processing

Deployment

  • GitHub for version control
  • Render for hosting
  • Docker for containerization

πŸ“‹ Prerequisites

  • Python 3.12+
  • Node.js 18+
  • Git
  • GitHub account
  • Render account

πŸš€ Quick Start

Local Development

  1. Clone the repository
git clone https://github.com/murtuja55/SentimentSync.git
cd SentimentSync
  1. Backend Setup
cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python -m uvicorn main:app --reload --port 8000
  1. Frontend Setup
cd frontend
npm install
npm run dev
  1. Access the application

🌐 Deployment

GitHub Deployment

  1. Push to GitHub
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/murtuja55/SentimentSync.git
git push -u origin main
  1. Repository Structure
SentimentSync/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ .env.example
β”‚   └── ...
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── ...
β”œβ”€β”€ README.md
β”œβ”€β”€ .gitignore
β”œβ”€β”€ render.yaml
└── docker-compose.yml

Render Deployment

Backend Deployment

  1. Create Render Web Service

    • Go to Render Dashboard
    • Click "New" β†’ "Web Service"
    • Connect your GitHub repository
    • Select "Python" as the runtime
    • Build command: pip install -r requirements.txt
    • Start command: uvicorn main:app --host 0.0.0.0 --port $PORT
  2. Environment Variables

    PYTHON_VERSION=3.12
    FASTAPI_ENV=production
    CLAUDE_API_KEY=your_claude_api_key
    

Frontend Deployment

  1. Create Static Site

    • Click "New" β†’ "Static Site"
    • Connect your GitHub repository
    • Build command: cd frontend && npm run build
    • Publish directory: frontend/dist
  2. Environment Variables

    NODE_VERSION=18
    VITE_API_URL=https://your-backend-url.onrender.com
    

πŸ”§ Configuration

Backend Configuration

Create .env file in backend directory:

# Claude API
CLAUDE_API_KEY=your_claude_api_key_here

# Social Media APIs (Optional)
TWITTER_API_KEY=your_twitter_api_key
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret

# Production
FASTAPI_ENV=production
DEBUG=false

Frontend Configuration

Create .env file in frontend directory:

VITE_API_URL=http://localhost:8000  # For development
# VITE_API_URL=https://your-backend-url.onrender.com  # For production

πŸ“¦ Dependencies

Backend Requirements

fastapi==0.104.1
uvicorn[standard]==0.24.0
python-multipart==0.0.6
pandas==2.1.3
numpy==1.25.2
scikit-learn==1.3.2
nltk==3.8.1
textblob==0.17.1
requests==2.31.0
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4

Frontend Dependencies

{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.8.0",
    "axios": "^1.6.0",
    "tailwindcss": "^3.3.0",
    "lucide-react": "^0.292.0",
    "chart.js": "^4.4.0",
    "react-chartjs-2": "^5.2.0"
  }
}

🐳 Docker Support

Docker Compose

version: '3.8'
services:
  backend:
    build: ./backend
    ports:
      - "8000:8000"
    environment:
      - FASTAPI_ENV=production
  
  frontend:
    build: ./frontend
    ports:
      - "5173:80"
    depends_on:
      - backend

πŸ“Š API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login

Data Management

  • POST /api/upload - Upload CSV data
  • GET /api/data-status - Check data status
  • GET /api/export - Export analysis results

ML Models

  • POST /api/train - Train sentiment model
  • POST /api/predict - Make predictions
  • GET /api/models - Get available models

Social Media

  • GET /api/social/trending - Get trending topics
  • POST /api/social/search - Search social media
  • POST /api/social/insights - Get topic insights

🎯 Usage

  1. Upload Data: Upload CSV files with text data for sentiment analysis
  2. Train Models: Choose between Logistic Regression or Naive Bayes
  3. View Dashboard: Interactive charts showing sentiment distribution
  4. Social Search: Search trending topics and analyze social media sentiment
  5. AI Insights: Get intelligent analysis powered by Claude API

πŸ”’ Security

  • JWT-based authentication
  • CORS protection
  • Input validation
  • Environment variable management
  • Secure API endpoints

πŸ“ˆ Performance

  • Async/await for non-blocking operations
  • Efficient data processing with Pandas
  • Optimized ML model training
  • Responsive UI with React
  • FastAPI for high-performance API

πŸ› Troubleshooting

Common Issues

  1. Port conflicts: Change ports in startup scripts
  2. Environment variables: Ensure all required variables are set
  3. CORS issues: Check frontend API URL configuration
  4. Build failures: Verify all dependencies are installed

Debug Mode

Enable debug mode by setting:

DEBUG=true
FASTAPI_ENV=development

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

For support, please:

  • Open an issue on GitHub
  • Check the troubleshooting section
  • Review the API documentation at /docs

🌟 Live Demo

Check out the live demo: SentimentSync on Render


Built with ❀️ using React, FastAPI, and Machine Learning

  • Authentication: JWT-based secure login system
  • Session History: Track and revisit past analysis sessions

Tech Stack

Frontend

  • React 18 with Vite
  • TailwindCSS for styling
  • Recharts for data visualization
  • Axios for API communication

Backend

  • FastAPI with Python
  • scikit-learn for ML models
  • NLTK for NLP preprocessing
  • TextBlob for sentiment analysis
  • JWT authentication
  • Anthropic Claude API integration

Quick Start

Backend Setup

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend Setup

cd frontend
npm install
npm run dev

Access the Application

  1. Open your browser and navigate to http://localhost:5173
  2. You'll see the Landing Page with "Bird Sound Recognition System" branding
  3. Click "Start Detection" to enter the main SentimentSync application
  4. Login with credentials: admin / password123
  5. Upload your CSV data and start analyzing sentiment!

Project Structure

sentimentsync/
|-- frontend/
|   |-- src/
|   |   |-- pages/          # React pages
|   |   |-- components/     # Reusable components
|   |   |-- App.jsx         # Main app component
|   |   `-- main.jsx        # Entry point
|   |-- package.json
|   `-- vite.config.js
|-- backend/
|   |-- main.py             # FastAPI application
|   |-- nlp_pipeline.py    # NLP preprocessing
|   |-- models.py           # ML models
|   |-- auth.py             # Authentication
|   |-- insights.py         # Claude API integration
|   `-- requirements.txt
`-- README.md

API Endpoints

  • POST /api/auth/login - User authentication
  • POST /api/upload - CSV file upload and processing
  • POST /api/train - Model training endpoint
  • GET /api/insights - AI-powered insights
  • GET /api/history - Analysis session history
  • GET /api/export/{session_id} - Export analyzed data

Default Credentials

  • Username: admin
  • Password: password123

CSV Format

The app expects CSV files with at minimum a text column. Optional columns:

  • date or timestamp - for time-based analysis
  • likes or like_count - engagement metrics
  • retweets, replies, shares - engagement metrics
  • sentiment - pre-labeled sentiment (optional)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors