A production-ready web application that analyzes COVID-19 related tweets using AI/ML models for sentiment analysis, toxicity detection, and content classification.
cd PandemicSentinel
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate
cd backend
pip install -r requirements.txt
cp ..\.env.example ..\.env
# Edit .env with your settings
cd ..
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
Backend will be available at: http://localhost:8000
cd frontend
npm install
# Windows
echo VITE_API_URL=http://localhost:8000 > .env.local
# macOS/Linux
echo "VITE_API_URL=http://localhost:8000" > .env.local
npm run dev
Frontend will be available at: http://localhost:5173
cd backend
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
cd ..
uvicorn backend.main:app --reload
cd frontend
npm install
npm run dev
mongod
# or use Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest
GET /health
Response:
{
"status": "healthy",
"version": "1.0.0"
}
POST /analyze-text
Content-Type: application/json
{
"text": "Your tweet text here"
}
Response:
{
"tweet_text": "...",
"classification": "Informational",
"tone": "Positive",
"confidence": {
"sentiment": 0.95,
"toxicity": 0.05,
"sarcasm": 0.02,
"toxicity_details": {
"toxicity": 0.01,
"severe_toxicity": 0.0,
"obscene": 0.0,
"identity_attack": 0.0,
"insult": 0.02,
"threat": 0.0
}
},
"toxicity_score": 0.05,
"sarcasm_detected": false,
"risk_level": "Low",
"summary": "..."
}
POST /analyze-link
Content-Type: application/json
{
"link": "https://twitter.com/user/status/1234567890"
}
GET /statistics
Response:
{
"status": "success",
"statistics": {
"total_analyzed": 42,
"toxic_percentage": 15.5,
"informational_percentage": 45.2,
"positive_tone_percentage": 60.8
}
}
Model: cardiffnlp/twitter-roberta-base-sentiment
Model: unitary/toxic-bert
Model: mrm8488/t5-base-finetuned-sarcasm-twitter
# Backend
BACKEND_PORT=8000
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
# Database
MONGODB_URL=mongodb://localhost:27017
# Twitter API (Optional)
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_BEARER_TOKEN=your_bearer_token
# Frontend
VITE_API_URL=http://localhost:8000
backend/
βββ main.py # Entry point
βββ schemas.py # Pydantic models
βββ database.py # MongoDB async driver
βββ requirements.txt # Dependencies
βββ models/
β βββ sentiment.py # Sentiment analyzer
β βββ toxicity.py # Toxicity detector
β βββ sarcasm.py # Sarcasm detector
βββ services/
βββ twitter_service.py # Tweet fetching
βββ analyzer.py # Analysis orchestration
frontend/
βββ index.html
βββ package.json
βββ vite.config.js
βββ tailwind.config.js
βββ postcss.config.js
βββ src/
βββ App.jsx
βββ main.jsx
βββ index.css
βββ components/
β βββ Hero.jsx # Landing section
β βββ Analyzer.jsx # Main analyzer
β βββ ResultCard.jsx # Results display
β βββ RiskMeter.jsx # Risk gauge
β βββ Loader.jsx # Loading animation
βββ pages/
β βββ Home.jsx # Main page
βββ animations/
βββ gsapAnimations.js # GSAP animations
pip install gunicorn
gunicorn backend.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker
npm run build
# Outputs to /dist for serving with Nginx/Apache
Backend Dockerfile:
FROM python:3.10-slim
WORKDIR /app
COPY backend/requirements.txt .
RUN pip install -r requirements.txt
COPY backend/ .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0"]
Docker Compose:
version: '3.8'
services:
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- MONGODB_URL=mongodb://mongodb:27017
depends_on:
- mongodb
frontend:
build: ./frontend
ports:
- "5173:5173"
mongodb:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
volumes:
mongodb_data:
β οΈ Medical Information Disclaimer
This tool analyzes the tone and content of tweets but should NOT be used as a sole source for COVID-19 medical information.
Always verify information with:
The analysis provided is for informational and research purposes only.
Models not downloading
# Clear cache and restart
rm -rf .huggingface_cache
python main.py
MongoDB connection error
mongod or Docker containerPort already in use
# Change port in .env: BACKEND_PORT=8001
uvicorn backend.main:app --reload --port 8001
Vite port conflict
npm run dev -- --port 5174
API connection failed
Contributions welcome! Please:
MIT License - see LICENSE file for details
Created as a comprehensive full-stack AI application demonstrating:
For issues, questions, or suggestions:
/docsThis project demonstrates:
Last Updated: February 2024 Status: Production Ready β
A production-ready web application that analyzes COVID-19 related tweets using AI/ML models for sentiment analysis, toxicity detection, and content classification.
cd PandemicSentinel
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate
cd backend
pip install -r requirements.txt
cp ..\.env.example ..\.env
# Edit .env with your settings
cd ..
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
Backend will be available at: http://localhost:8000
cd frontend
npm install
# Windows
echo VITE_API_URL=http://localhost:8000 > .env.local
# macOS/Linux
echo "VITE_API_URL=http://localhost:8000" > .env.local
npm run dev
Frontend will be available at: http://localhost:5173
cd backend
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
cd ..
uvicorn backend.main:app --reload
cd frontend
npm install
npm run dev
mongod
# or use Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest
GET /health
Response:
{
"status": "healthy",
"version": "1.0.0"
}
POST /analyze-text
Content-Type: application/json
{
"text": "Your tweet text here"
}
Response:
{
"tweet_text": "...",
"classification": "Informational",
"tone": "Positive",
"confidence": {
"sentiment": 0.95,
"toxicity": 0.05,
"sarcasm": 0.02,
"toxicity_details": {
"toxicity": 0.01,
"severe_toxicity": 0.0,
"obscene": 0.0,
"identity_attack": 0.0,
"insult": 0.02,
"threat": 0.0
}
},
"toxicity_score": 0.05,
"sarcasm_detected": false,
"risk_level": "Low",
"summary": "..."
}
POST /analyze-link
Content-Type: application/json
{
"link": "https://twitter.com/user/status/1234567890"
}
GET /statistics
Response:
{
"status": "success",
"statistics": {
"total_analyzed": 42,
"toxic_percentage": 15.5,
"informational_percentage": 45.2,
"positive_tone_percentage": 60.8
}
}
Model: cardiffnlp/twitter-roberta-base-sentiment
Model: unitary/toxic-bert
Model: mrm8488/t5-base-finetuned-sarcasm-twitter
# Backend
BACKEND_PORT=8000
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
# Database
MONGODB_URL=mongodb://localhost:27017
# Twitter API (Optional)
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_BEARER_TOKEN=your_bearer_token
# Frontend
VITE_API_URL=http://localhost:8000
backend/
βββ main.py # Entry point
βββ schemas.py # Pydantic models
βββ database.py # MongoDB async driver
βββ requirements.txt # Dependencies
βββ models/
β βββ sentiment.py # Sentiment analyzer
β βββ toxicity.py # Toxicity detector
β βββ sarcasm.py # Sarcasm detector
βββ services/
βββ twitter_service.py # Tweet fetching
βββ analyzer.py # Analysis orchestration
frontend/
βββ index.html
βββ package.json
βββ vite.config.js
βββ tailwind.config.js
βββ postcss.config.js
βββ src/
βββ App.jsx
βββ main.jsx
βββ index.css
βββ components/
β βββ Hero.jsx # Landing section
β βββ Analyzer.jsx # Main analyzer
β βββ ResultCard.jsx # Results display
β βββ RiskMeter.jsx # Risk gauge
β βββ Loader.jsx # Loading animation
βββ pages/
β βββ Home.jsx # Main page
βββ animations/
βββ gsapAnimations.js # GSAP animations
pip install gunicorn
gunicorn backend.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker
npm run build
# Outputs to /dist for serving with Nginx/Apache
Backend Dockerfile:
FROM python:3.10-slim
WORKDIR /app
COPY backend/requirements.txt .
RUN pip install -r requirements.txt
COPY backend/ .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0"]
Docker Compose:
version: '3.8'
services:
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- MONGODB_URL=mongodb://mongodb:27017
depends_on:
- mongodb
frontend:
build: ./frontend
ports:
- "5173:5173"
mongodb:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
volumes:
mongodb_data:
β οΈ Medical Information Disclaimer
This tool analyzes the tone and content of tweets but should NOT be used as a sole source for COVID-19 medical information.
Always verify information with:
The analysis provided is for informational and research purposes only.
Models not downloading
# Clear cache and restart
rm -rf .huggingface_cache
python main.py
MongoDB connection error
mongod or Docker containerPort already in use
# Change port in .env: BACKEND_PORT=8001
uvicorn backend.main:app --reload --port 8001
Vite port conflict
npm run dev -- --port 5174
API connection failed
Contributions welcome! Please:
MIT License - see LICENSE file for details
Created as a comprehensive full-stack AI application demonstrating:
For issues, questions, or suggestions:
/docsThis project demonstrates:
Last Updated: February 2024 Status: Production Ready β