SentinelBERT Deployment Guide
Complete deployment guide for SentinelBERT Social Media Analytics Platform.
π Quick Start
The fastest way to get SentinelBERT running:
chmod +x quick-start.sh
./quick-start.sh
This script will automatically detect your system and recommend the best deployment method.
π Prerequisites
For All Deployments
- Operating System: macOS 10.15+ or Linux (Ubuntu 18.04+, CentOS 7+)
- Memory: Minimum 8GB RAM (16GB recommended)
- Storage: 10GB free space
- Network: Internet connection for downloading dependencies
For Docker Deployment
- Docker 20.10+
- Docker Compose 2.0+
For Native Deployment
- Python 3.8+
- Node.js 16+
- npm 8+
π³ Docker Deployment (Recommended)
Quick Docker Setup
chmod +x docker-deploy.sh
./docker-deploy.sh deploy
Docker Commands
# Deploy all services
./docker-deploy.sh deploy
# Check status
./docker-deploy.sh status
# View logs
./docker-deploy.sh logs
# Stop services
./docker-deploy.sh stop
# Clean everything
./docker-deploy.sh clean
# Restart services
./docker-deploy.sh restart
What Docker Deployment Includes
- β PostgreSQL database
- β Redis cache
- β NLP service (BERT-based)
- β Streamlit dashboard
- β React frontend
- β Automatic health checks
- β Service orchestration
- β Volume persistence
π» Native Deployment
Quick Native Setup
chmod +x native-deploy.sh
./native-deploy.sh deploy
Native Commands
# Deploy all services
./native-deploy.sh deploy
# Check status
./native-deploy.sh status
# View logs
./native-deploy.sh logs
# Stop services
./native-deploy.sh stop
# Clean deployment
./native-deploy.sh clean
# Restart services
./native-deploy.sh restart
What Native Deployment Includes
- β Python virtual environment
- β NLP service (FastAPI + BERT)
- β Streamlit dashboard
- β React frontend (if Node.js available)
- β Process management
- β Health monitoring
π§ Universal Deployment Script
For advanced users who want full control:
chmod +x deploy.sh
# Docker deployment
./deploy.sh --docker
# Native deployment
./deploy.sh --native
# Development mode
./deploy.sh --native --dev
# Force reinstall
./deploy.sh --native --force
# Check status
./deploy.sh --status
# View logs
./deploy.sh --logs
# Stop services
./deploy.sh --stop
# Clean deployment
./deploy.sh --clean
π Access URLs
After successful deployment, access these URLs:
Service | URL | Description |
---|---|---|
Streamlit Dashboard | http://localhost:12000 | Government-style analytics interface |
React Frontend | http://localhost:12001 | Modern web interface |
NLP API | http://localhost:8000 | BERT-based sentiment analysis API |
API Documentation | http://localhost:8000/docs | Interactive API documentation |
π API Configuration
Required API Keys
Update the .env
file with your API keys:
# Twitter/X API
TWITTER_BEARER_TOKEN=your_bearer_token
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
# Reddit API
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
# YouTube API
YOUTUBE_API_KEY=your_youtube_api_key
Getting API Keys
Twitter/X API
- Visit Twitter Developer Portal
- Create a new app
- Generate API keys and tokens
Reddit API
- Visit Reddit App Preferences
- Create a new application
- Note the client ID and secret
YouTube API
- Visit Google Cloud Console
- Enable YouTube Data API v3
- Create credentials (API key)
ποΈ Architecture Overview
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React Frontend β βStreamlit Dashboardβ β NLP Service β
β (Port 12001) β β (Port 12000) β β (Port 8000) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β Core Services β
β βββββββββββββββ βββββββββββββββββββββββ β
β β PostgreSQL β β Redis Cache β β
β β (Optional) β β (Optional) β β
β βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββ
π Service Details
NLP Service (Port 8000)
- Technology: FastAPI + PyTorch + Transformers
- Features: BERT sentiment analysis, real-time processing
- Endpoints:
/analyze
,/health
,/docs
Streamlit Dashboard (Port 12000)
- Technology: Streamlit + Python
- Features: Government-style interface, real-time analytics
- Capabilities: Social media monitoring, viral detection
React Frontend (Port 12001)
- Technology: React + TypeScript + Material-UI
- Features: Modern web interface, interactive charts
- Capabilities: Real-time updates, responsive design
π οΈ Troubleshooting
Common Issues
Port Already in Use
# Check what's using the port
lsof -i :8000
lsof -i :12000
lsof -i :12001
# Kill processes if needed
sudo kill -9 <PID>
Docker Issues
# Restart Docker daemon
sudo systemctl restart docker # Linux
# or restart Docker Desktop on macOS
# Clean Docker system
docker system prune -a
Python Environment Issues
# Remove and recreate virtual environment
rm -rf venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements-complete.txt
Node.js Issues
# Clear npm cache
npm cache clean --force
# Remove and reinstall node_modules
rm -rf frontend/node_modules
cd frontend && npm install
Service Health Checks
Check NLP Service
curl http://localhost:8000/health
Check Streamlit Dashboard
curl http://localhost:12000
Check React Frontend
curl http://localhost:12001
Log Locations
Docker Deployment
# View all logs
docker-compose -f docker-compose.simple.yml logs -f
# View specific service logs
docker logs sentinelbert-nlp
docker logs sentinelbert-streamlit
Native Deployment
# Log files location
ls -la logs/
# View specific logs
tail -f logs/nlp_service.log
tail -f logs/streamlit.log
tail -f logs/frontend.log
π Security Considerations
Environment Variables
- Never commit
.env
files to version control - Use strong passwords for database connections
- Rotate API keys regularly
Network Security
- Services bind to localhost by default
- Use reverse proxy for production deployments
- Enable HTTPS for production
Data Protection
- Social media data is processed locally
- No data is sent to external services (except APIs)
- Implement proper access controls for production
π Production Deployment
Additional Steps for Production
-
Use Environment-Specific Configurations
bash cp .env .env.production # Edit .env.production with production values
-
Set Up Reverse Proxy
- Use Nginx or Apache
- Enable HTTPS with SSL certificates
-
Configure proper security headers
-
Database Setup
- Use managed PostgreSQL service
- Set up regular backups
-
Configure connection pooling
-
Monitoring
- Set up application monitoring
- Configure log aggregation
-
Implement health checks
-
Scaling
- Use container orchestration (Kubernetes)
- Implement load balancing
- Set up auto-scaling
π Performance Optimization
System Requirements by Scale
Scale | RAM | CPU | Storage | Concurrent Users |
---|---|---|---|---|
Development | 8GB | 4 cores | 10GB | 1-5 |
Small Team | 16GB | 8 cores | 50GB | 5-20 |
Department | 32GB | 16 cores | 100GB | 20-100 |
Enterprise | 64GB+ | 32+ cores | 500GB+ | 100+ |
Optimization Tips
- NLP Service
- Use GPU acceleration for BERT models
- Implement model caching
-
Batch process requests
-
Database
- Index frequently queried columns
- Use connection pooling
-
Implement query optimization
-
Frontend
- Enable gzip compression
- Use CDN for static assets
- Implement lazy loading
π Support
Getting Help
- Check Logs: Always check service logs first
- Review Documentation: Read this guide thoroughly
- System Requirements: Ensure your system meets requirements
- Clean Deployment: Try cleaning and redeploying
Common Solutions
Problem | Solution |
---|---|
Services won't start | Check port availability and dependencies |
API errors | Verify API keys in .env file |
Frontend not loading | Ensure Node.js dependencies are installed |
Database connection issues | Check PostgreSQL service status |
Memory issues | Increase system RAM or reduce concurrent processes |
π Development
Development Mode
For development with hot reload:
# Native development mode
./native-deploy.sh deploy
# Or using main script
./deploy.sh --native --dev
Code Structure
SentinentalBERT/
βββ services/
β βββ nlp/ # NLP service (FastAPI)
β βββ realtime/ # Real-time data connectors
β βββ viral_detection/ # Viral content detection
βββ frontend/ # React frontend
βββ enhanced_viral_dashboard.py # Streamlit dashboard
βββ deploy.sh # Universal deployment script
βββ docker-deploy.sh # Docker-specific deployment
βββ native-deploy.sh # Native deployment script
βββ quick-start.sh # Quick start script
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test with deployment scripts
- Submit a pull request
π License
This project is licensed under the MIT License. See LICENSE file for details.
π₯ Team
Team: Code X - Advanced Social Media Analytics - Government-Grade Security - Real-time Monitoring Solutions
For additional support or questions, please refer to the project documentation or contact the development team.