Skip to main content

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/docs when 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-sync endpoint
  • 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


Version: 2.0.0
Status: Production Ready โœ…
Last Updated: March 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trust_sense-0.1.0.tar.gz (43.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trust_sense-0.1.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

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

Hashes for trust_sense-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02d343a38dc1da19079a1d65f31b273cf5d2008600321a7bf1ef1c270e4a1394
MD5 cb9c6888e672ea58654128830fc37462
BLAKE2b-256 08a95bb683d62004b25c63daa22920b7c239de5422cda4bc1ed05abbf43dde32

See more details on using hashes here.

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

Hashes for trust_sense-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06aae8b32c89cb480c57239fb558a9f252a09d1bc3c88ba33e96a86cd8462118
MD5 84472be4a374b11f7274f29fe4e1c5cd
BLAKE2b-256 f454dedaee2436da59b50b8400762679d8867587da494a3026e0d67f589dc359

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page