Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SentimentSage Logo

SentimentSage

AI-Powered Sentiment Analysis Platform

License Python React Flask

Analyze sentiments in text, social media posts, and customer feedback with cutting-edge AI.

🌐 Live Demo

The app is deployed live:

Part URL
Frontend (Netlify) https://sentiment-sage42984.netlify.app
Frontend (Vercel) https://sentiment-sage42984.vercel.app
Backend API (Render) https://sentimentsage.onrender.com/api

The frontend on Netlify/Vercel automatically talks to the backend on Render. No extra setup needed for visitors β€” everything works out of the box.

🌟 Features

  • Multi-Platform Analysis: Analyze text, CSV files, Twitter accounts, and YouTube comments
  • Advanced AI Models: Powered by OpenAI GPT and Hugging Face transformers
  • Real-time Processing: Get instant sentiment analysis results
  • Interactive Visualizations: Beautiful charts and graphs for data insights
  • User Authentication: Secure signup, login, and profile management
  • History Tracking: Save and revisit your previous analyses
  • Export Capabilities: Export results as PDF reports

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • MongoDB Community Edition
  • npm or yarn

Installation

  1. Clone the repository
git clone <repository-url>
cd SentimentSa
  1. Backend Setup
cd backend
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
# source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your configuration
  1. Frontend Setup
cd frontend
npm install
cp .env.example .env
# Edit .env with your configuration

Running the Application

Option 1: Manual Start (Recommended for Development)

  1. Start MongoDB service
  2. Start Backend:
    cd backend
    python app.py
  3. Start Frontend:
    cd frontend
    npm run dev

Option 2: Automated Start Scripts

On Windows:

  • PowerShell: .\start-dev.ps1
  • Command Prompt: start-dev.bat

Access the Application

πŸ› οΈ Development Guide

See README-DEV.md for detailed development setup and troubleshooting.

πŸ“ Project Structure

SentimentSage/
β”œβ”€β”€ backend/              # Flask API server (deployed on Render)
β”‚   β”œβ”€β”€ models/          # Database models
β”‚   β”œβ”€β”€ routes/          # API routes
β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   β”œβ”€β”€ middleware/      # Custom middleware
β”‚   β”œβ”€β”€ config.py        # Configuration
β”‚   β”œβ”€β”€ requirements.txt # Python dependencies
β”‚   └── render.yaml      # Render deployment config
β”œβ”€β”€ frontend/            # React frontend (deployed on Netlify/Vercel)
β”‚   β”œβ”€β”€ src/             # Source code
β”‚   β”‚   β”œβ”€β”€ components/  # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/       # Page components
β”‚   β”‚   β”œβ”€β”€ hooks/       # Custom hooks
β”‚   β”‚   └── utils/       # Utility functions
β”‚   β”œβ”€β”€ public/          # Static assets
β”‚   β”œβ”€β”€ netlify.toml     # Netlify deployment config
β”‚   └── vercel.json      # Vercel deployment config
└── data/                # Local database storage
    └── db/              # MongoDB data files

πŸ”§ Configuration

Backend Environment Variables (.env)

  • FLASK_CONFIG: development/production
  • MONGODB_URI: MongoDB connection string
  • SECRET_KEY: Flask secret key
  • JWT_SECRET_KEY: JWT secret key
  • API keys for external services (optional)

Frontend Environment Variables (.env)

  • VITE_API_BASE_URL: Backend API URL

πŸ”‘ Environment Variables Guide

A fully documented master copy of every variable lives in .env at the project root (it is git-ignored, so it never gets committed). The backend reads backend/.env and the frontend reads frontend/.env β€” copy the relevant values into each.

Where each file lives

File Who reads it Content
backend/.env Flask backend (backend/db/mongo_client.py) MongoDB, JWT, API keys, AI, email, CORS
frontend/.env Vite frontend at build time VITE_API_BASE_URL
.env (root) Reference copy only Everything, fully explained

How to get each value

Variable Required? Where to get it
SECRET_KEY / JWT_SECRET_KEY Yes Any long random string: python -c "import secrets; print(secrets.token_hex(32))"
MONGODB_URI Yes Local: mongodb://localhost:27017/sage_sentiment. Cloud: MongoDB Atlas β†’ create free cluster β†’ Connect β†’ Connect your application β†’ copy string (replace <username>:<password>)
YOUTUBE_API_KEY No Google Cloud Console β†’ create project β†’ Enable APIs & Services β†’ enable YouTube Data API v3 β†’ Credentials β†’ Create Credentials β†’ API key
OPENAI_API_KEY No OpenAI Platform β†’ API keys β†’ Create new secret key (needs paid account/credits for live calls)
HUGGINGFACE_API_KEY No Hugging Face β†’ Settings β†’ Access Tokens β†’ New token
TWITTER_* keys No X Developer Platform β†’ create a Project + App β†’ copy API Key/Secret and Access Token/Secret (note: X requires paid tiers)
SMTP_USERNAME No* Your Gmail address
SMTP_PASSWORD No* Gmail App Password (not your login password): myaccount.google.com β†’ Security β†’ enable 2-Step Verification β†’ App passwords β†’ choose Mail/Other β†’ copy 16-char code
CORS_ORIGINS Yes Comma-separated list of every frontend URL (e.g. http://localhost:5173,https://sentiment-sage42984.netlify.app,https://sentiment-sage42984.vercel.app)

* Only needed if USE_MOCK_EMAIL=False. While developing, keep USE_MOCK_EMAIL=True and emails are logged instead of sent.

Setup steps

  1. Copy the root .env to backend/.env: cp .env backend/.env (Windows: copy .env backend\.env)
  2. Edit backend/.env and fill in the values from the table above.
  3. Create frontend/.env with VITE_API_BASE_URL=http://localhost:8080/api.
  4. Never commit .env files β€” they are already ignored via .gitignore.

☁️ Deployment

The app is split into two parts, deployed separately:

1. Backend on Render

  • Deploy the backend/ folder using render.yaml (already configured).
  • Set these env vars in Render: MONGODB_URI, SECRET_KEY, JWT_SECRET_KEY, CORS_ORIGINS (your frontend URLs), plus API keys (YOUTUBE_API_KEY, OPENAI_API_KEY, etc.).
  • Render auto-redeploys on every push to main.

2. Frontend on Netlify (or Vercel)

  • Connect the repo, set Base directory = frontend, Build command = npm run build, Publish directory = dist.
  • Set the env var VITE_API_BASE_URL = https://your-backend.onrender.com/api (this is how the site finds the backend).
  • Netlify uses netlify.toml; Vercel uses vercel.json. Both are included β€” you can deploy to either.

How they connect

Frontend (Netlify) β†’ VITE_API_BASE_URL β†’ Backend (Render) β†’ MongoDB + AI APIs. The backend allows requests only from the URLs in CORS_ORIGINS.

🌐 API Documentation

Authentication

  • POST /api/auth/signup - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/me - Get current user

Analysis

  • POST /api/analyze/text - Analyze text sentiment
  • POST /api/analyze/csv - Analyze CSV file
  • POST /api/analyze/twitter - Analyze Twitter account
  • POST /api/analyze/youtube - Analyze YouTube video

Profile

  • GET /api/profile - Get user profile
  • PUT /api/profile - Update user profile
  • GET /api/profile/analyses - Get user's saved analyses

πŸ“Š Data Visualization

The platform provides interactive charts including:

  • Sentiment distribution pie charts
  • Time-series sentiment trends
  • Word clouds of frequently used terms
  • Comparative analysis between datasets

πŸ”’ Security

  • JWT-based authentication
  • Password hashing with bcrypt
  • CORS protection
  • Input validation and sanitization
  • Rate limiting (coming soon)

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

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

πŸ“¦ Tech Stack

  • Backend: Python, Flask, MongoDB, JWT
  • Frontend: React, TypeScript, Vite, Tailwind CSS, shadcn/ui
  • AI: OpenAI GPT, Hugging Face
  • Hosting: Render (backend), Netlify / Vercel (frontend)

πŸ™ Acknowledgments

  • OpenAI for GPT models
  • Hugging Face for transformer models
  • MongoDB for database solutions
  • All contributors to this project

πŸ“ž Support

For support, please open an issue on GitHub or contact the development team.

About

AI sentiment analysis app with React frontend, Flask backend, secure configs, and scalable deployment.

Topics

Resources

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages