Advanced Multimodal AI Library for Fake News & Psyops Detection
Project description
Trust Sense โ Full AI Intelligence Platform
Production-ready, scalable AI platform for trust and credibility analysis of text, audio, video, and images.
Backend: Python 3.11 + FastAPI + SQLAlchemy + Claude/HuggingFace + WebSockets
Frontend: React 18 + Vite + TailwindCSS + Recharts
Security: JWT, RBAC (Admin/Analyst/Viewer), CORS, Rate Limiting, Network Policies
Deployment: Kubernetes with PostgreSQL, Nginx Ingress, SSL/TLS
๐ Documentation
- DEPLOYMENT.md โ Production deployment guide (Kubernetes, security, monitoring)
- API Docs โ Available at
http://localhost:8000/docswhen running locally
โก Quick Start (5 minutes)
1. Backend Setup
cd backend
# Create virtual environment
python -m venv venv
# Activate (Mac/Linux)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure .env with API keys (see below)
# nano .env or code .env
# Start the API server
python -m uvicorn app.main:app --reload --port 8000
Backend: http://localhost:8000
API Docs: http://localhost:8000/docs
2. Frontend Setup
cd frontend
npm install
npm run dev
Frontend: http://localhost:5173
3. Configure API Keys
Edit backend/.env:
# NLP Engines
ANTHROPIC_API_KEY=sk-ant-... # https://console.anthropic.com
HUGGINGFACE_API_KEY=hf_... # https://huggingface.co/settings/tokens
# Power BI Integration (Optional)
POWERBI_DATASET_ID=your-dataset-id
POWERBI_TOKEN=your-powerbi-token
๐ฏ Modules & Features
Text Analysis โ
- Trust score (0-100)
- Sentiment analysis (-1 to +1)
- Fake news probability
- Manipulation detection
- Emotional signals
- Language analysis
curl -X POST http://localhost:8000/api/analyze-text \
-H "Content-Type: application/json" \
-d '{"text":"Some text to analyze"}'
Audio Analysis โ
- Speech-to-text transcription
- Voice emotion detection (joy, sadness, anger, fear, neutral)
- Pitch & energy metrics
- Transcript credibility analysis
curl -X POST http://localhost:8000/api/analyze-audio \
-F "file=@speech.mp3"
Video Analysis โ
- Deepfake detection (FaceNet512 embeddings)
- Facial emotion analysis (7 emotions)
- Face consistency scoring
- Frame-by-frame emotion timeline
curl -X POST http://localhost:8000/api/analyze-video \
-F "file=@video.mp4"
Multimodal Analysis โ
- Combined audio + video analysis
- Cross-modal consistency checking
- Integrated risk assessment
curl -X POST http://localhost:8000/api/analyze-multimodal \
-F "audio_file=@audio.mp3" \
-F "video_file=@video.mp4"
Image Analysis โ
- OCR (optical character recognition)
- Image description & understanding
- Visual credibility assessment
Power BI Integration โ
- Real-time data sync
- Custom dashboards
- Visualization & reporting
- REST API integration
๐ Project Structure
trust-sense/
โโโ backend/
โ โโโ app/
โ โ โโโ main.py # FastAPI app entry
โ โ โโโ core/
โ โ โ โโโ config.py # Settings (UPDATED)
โ โ โ โโโ database.py # SQLAlchemy
โ โ โ โโโ security.py # JWT & auth
โ โ โโโ models/
โ โ โ โโโ models.py # DB models (UPDATED)
โ โ โโโ routers/
โ โ โ โโโ auth.py # Authentication
โ โ โ โโโ analysis.py # Text analysis
โ โ โ โโโ audio_video.py # AV analysis (NEW)
โ โ โโโ services/
โ โ โโโ nlp_service.py # Claude+HuggingFace (ENHANCED)
โ โ โโโ av_service.py # Audio/Video (NEW)
โ โ โโโ powerbi_service.py # Power BI (NEW)
โ โโโ requirements.txt # ALL deps (UPDATED)
โ โโโ .env # Config (UPDATED)
โโโ frontend/
โโโ src/
โโโ pages/
โโโ components/
โโโ services/api.js
๐ API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register user |
| POST | /auth/login |
Login, get JWT |
| POST | /api/analyze-text |
Text analysis |
| POST | /api/analyze-audio |
Audio analysis |
| POST | /api/analyze-video |
Video analysis |
| POST | /api/analyze-multimodal |
Combined A/V |
| GET | /api/powerbi-status |
Power BI status |
| POST | /api/powerbi-sync |
Manual sync |
| GET | /api/analysis-history |
History (auth) |
| GET | /api/stats |
Statistics (admin only) |
| GET | /api/stats/summary |
Public summary stats |
| GET | /health |
Health check |
| GET | /docs |
Swagger UI |
| WebSocket | /ws/live |
Live alerts |
๐ง NLP Engine Features
Primary: Anthropic Claude
- Advanced reasoning
- Image analysis (with vision)
- Structured JSON output
- Multilingual support
Fallback: HuggingFace
- Distilbert sentiment analysis
- Local model caching
- No API key required
- Fast inference
Graceful Degradation
1. Try Claude API
2. If unavailable โ Fall back to HuggingFace
3. If HuggingFace fails โ Use rule-based analysis
๐ Power BI Integration
Real-time data sync from Trust Sense to Power BI dashboards.
Setup: Follow POWERBI_SETUP.md
Synced Data:
- Analysis ID, User ID, Input Type
- Trust Score, Sentiment, Credibility
- Risk Level, Emotions, Timestamps
- Deepfake Probability, Voice Emotion
Triggers:
- Automatic on analysis completion
- Manual via
/api/powerbi-syncendpoint - Batch sync via background jobs
๐ Usage Examples
Python
import requests
# Text analysis
response = requests.post(
"http://localhost:8000/api/analyze-text",
json={"text": "Breaking news about AI safety"}
)
print(response.json()["trust_score"])
# Audio analysis
with open("speech.mp3", "rb") as f:
response = requests.post(
"http://localhost:8000/api/analyze-audio",
files={"file": f}
)
print(response.json()["voice_emotion"])
JavaScript/React
// Text analysis
const response = await fetch("http://localhost:8000/api/analyze-text", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text: "Some text..." })
});
const result = await response.json();
console.log(result.trust_score);
See QUICK_REFERENCE.md for more examples.
๐ Documentation
| File | Purpose |
|---|---|
| PROJECT_DESCRIPTION.md | Full project description โ vision, features, stack, API, security, deployment |
| PROJECT_ROADMAP.md | Tech roadmap, phases, free hosting link |
| HOSTING.md | Step-by-step free hosting (Vercel, Render, Upstash) |
| INTEGRATION_GUIDE.md | Setup & architecture (if present) |
| POWERBI_SETUP.md | Power BI configuration (if present) |
| QUICK_REFERENCE.md | Code examples (if present) |
๐ Security Features
- JWT authentication
- Password hashing (bcrypt)
- RBAC: Admin, Analyst, Viewer roles
- CORS (configurable via
CORS_ORIGINS) - Rate limiting by subscription tier
- Environment variable secrets
๐ Performance
- Text: < 500ms per analysis
- Audio: 2-5s (depends on file size)
- Video: 5-15s (depends on length)
- Batch sync: Bulk Power BI uploads
๐ Deployment
Docker
docker compose up -d --build
Frontend: http://localhost:5173 โ Backend: http://localhost:8000 โ Redis: 6379
Free hosting (Vercel + Render)
See HOSTING.md for step-by-step free deployment.
Other
- Railway / Heroku: Connect repo; set root dir and env (see HOSTING.md).
- render.yaml included for Render Web Service (root directory:
backend).
๐ง System Requirements
- Python 3.11+
- Node.js 16+
- 4GB RAM minimum
- Optional: FFmpeg, Tesseract OCR
โ๏ธ Environment Variables
# Database
DATABASE_URL=sqlite:///./trust_sense.db
# Security
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440
# NLP
ANTHROPIC_API_KEY=sk-ant-...
HUGGINGFACE_API_KEY=hf_...
# Power BI
POWERBI_DATASET_ID=...
POWERBI_TOKEN=...
POWERBI_API_URL=https://api.powerbi.com/v1.0/myorg
POWERBI_TABLE_NAME=AnalysisResults
๐ Troubleshooting
| Issue | Solution |
|---|---|
| CORS errors | Verify backend running on :8000 |
| "Analysis failed" | Check API key, restart backend |
| Video processing slow | Reduce video size, use GPU |
| Power BI sync fails | Verify token/dataset ID |
See INTEGRATION_GUIDE.md for detailed fixes.
๐ Feature Checklist
- โ Text analysis with Claude + HuggingFace + psychological analysis
- โ Audio transcription & emotion detection
- โ Video deepfake detection & facial emotions
- โ Image OCR & analysis
- โ Social media import (multiple platforms)
- โ Power BI real-time sync (optional)
- โ JWT auth + RBAC (Admin / Analyst / Viewer)
- โ WebSockets (/ws/live) for live alerts
- โ SQLite / PostgreSQL + Redis (Docker)
- โ REST API with Swagger docs
- โ React + Vite + TailwindCSS frontend
- โ Docker + CI/CD (GitHub Actions)
- โ Free hosting guide (Vercel + Render)
- โ Production-ready code
๐ Support
- API Docs: http://localhost:8000/docs (Swagger)
- Claude: https://docs.anthropic.com
- HuggingFace: https://huggingface.co/docs
- Power BI: https://learn.microsoft.com/power-bi
- FastAPI: https://fastapi.tiangolo.com
Version: 2.0.0
Status: Production Ready โ
Last Updated: March 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trust_sense-0.1.0.tar.gz.
File metadata
- Download URL: trust_sense-0.1.0.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d343a38dc1da19079a1d65f31b273cf5d2008600321a7bf1ef1c270e4a1394
|
|
| MD5 |
cb9c6888e672ea58654128830fc37462
|
|
| BLAKE2b-256 |
08a95bb683d62004b25c63daa22920b7c239de5422cda4bc1ed05abbf43dde32
|
File details
Details for the file trust_sense-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trust_sense-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06aae8b32c89cb480c57239fb558a9f252a09d1bc3c88ba33e96a86cd8462118
|
|
| MD5 |
84472be4a374b11f7274f29fe4e1c5cd
|
|
| BLAKE2b-256 |
f454dedaee2436da59b50b8400762679d8867587da494a3026e0d67f589dc359
|