🔍 TruthLens AI — Project Story


💡 Inspiration

Every day, millions of people receive suspicious messages on WhatsApp, see fake news on social media, or encounter scams disguised as job offers, bank alerts, or health cures. The problem hits hardest for those least equipped to defend themselves — elderly grandparents who trust every message they receive, teenagers who can't always tell real news from viral misinformation, and women who face targeted harassment or fake modeling scams online.

We were inspired by real stories around us:

"My grandmother almost transferred money to a scammer pretending to be from her bank." "My classmate shared a fake health cure to 200 people before anyone corrected her."

We asked ourselves: what if there was a simple tool anyone could use — no tech knowledge needed — to instantly check if something online is safe?

That question became TruthLens AI.


🛠️ How We Built It

We built TruthLens AI as a full-stack web application using tools we already knew, kept simple and focused on the demo experience.

Tech Stack

Layer Technology
Frontend HTML5, CSS3, Vanilla JavaScript
Backend Python Flask + Flask-CORS
Database MySQL
AI Engine Custom rule-based NLP scoring system
Auth bcrypt password hashing, server-side sessions

Architecture

The system follows a clean separation of concerns:

User pastes text
      ↓
Frontend (HTML/JS) sends POST /api/analyze
      ↓
Flask backend receives request
      ↓
ai_engine.py scans text against keyword dictionaries
      ↓
Scores computed across 4 risk categories
      ↓
Risk level, trust score, flags & explanation returned
      ↓
Frontend renders animated result card
      ↓
Result saved to MySQL (if logged in)

The AI Scoring Engine

Our engine scores content across four risk dimensions simultaneously:

$$\text{Trust Score} = 100 - \lfloor S_{\max} \times 0.85 \rfloor - 2 \times |F|$$

Where:

  • \( S_{\max} = \max(S_{\text{scam}},\ S_{\text{fake}},\ S_{\text{harass}},\ S_{\text{manip}}) \) — the highest risk category score
  • \( |F| \) — total number of detected keyword hits across all categories

Each category score is computed using a diminishing-returns curve so that one red flag raises concern but doesn't automatically max out the score:

$$S_{\text{category}} = \min!\left(\left\lfloor\left(\frac{h}{h_{\max}}\right)^{0.6} \times 100\right\rfloor,\ 98\right)$$

Where \( h \) is the number of keyword hits and \( h_{\max} \) is the calibrated maximum for that category.

Risk levels are then assigned:

Score Range Risk Level
\( S_{\max} \geq 75 \) 🔴 Critical
\( 50 \leq S_{\max} < 75 \) 🟠 High
\( 25 \leq S_{\max} < 50 \) 🟡 Medium
\( S_{\max} < 25 \) 🟢 Low

Special Detection Modes

We built four analysis modes that adjust sensitivity based on who is using it:

  • 👵 Elderly Mode — boosts scam detection sensitivity; returns a simple 3-word verdict (✅ SAFE / ⚠️ BE CAREFUL / 🛑 DANGEROUS) with plain language action steps
  • 📱 Teen Mode — increases harassment and cyberbullying sensitivity
  • 👩 Women Safety Mode — activates a dedicated keyword set for fake job/modeling offers, unsafe meetup requests, and threatening language
  • 🔍 Standard Mode — balanced detection for general users

📚 What We Learned

Building TruthLens AI taught us far more than we expected.

Technically, we learned how to design a full REST API with Flask, handle cross-origin requests between a frontend and backend on different ports, manage MySQL connection pooling, and implement secure bcrypt authentication with server-side sessions.

On the AI/NLP side, we learned that rule-based systems — when carefully crafted — can be surprisingly effective for domain-specific tasks. The challenge of writing keyword lists made us deeply research actual scam messages, fake news patterns, and harassment tactics, which was eye-opening.

On the design side, we learned to build a full CSS design system from scratch — custom variables, responsive grids, animated SVG rings, glassmorphism cards — without any UI framework.

Most importantly, we learned that digital safety is a human problem first, a technical problem second. The hardest part wasn't writing code — it was thinking about how a 70-year-old woman who just received a suspicious WhatsApp message would feel, and designing the result page so it genuinely helps her.


⚙️ Challenges We Faced

1. No external AI API We deliberately chose not to use any external AI API, which meant building our own scoring engine from scratch. Calibrating the keyword weights and score curves to avoid both false positives (flagging safe content as dangerous) and false negatives (missing real scams) required many iterations of testing with real-world scam examples.

2. Designing for multiple audiences simultaneously A result page that's useful for a tech-savvy adult is completely overwhelming for an elderly user. Designing the same data to be presented in two completely different ways — detailed breakdown vs. simple verdict — required rethinking the UI architecture.

3. Making it feel like AI without an AI Rule-based systems can feel mechanical. We spent significant time writing the explanation generator to produce natural, context-aware explanations that feel like a real safety advisor is talking to the user — not a keyword matcher.

4. Database connection in a hackathon environment Getting MySQL connection pooling to work reliably across different machines with different configurations took more debugging time than expected. We added graceful fallbacks to ensure the app degrades safely rather than crashing.


🌏 Impact

TruthLens AI is designed for everyone — especially the most vulnerable:

  • 🎓 Students detecting fake scholarships and cyberbullying
  • 👵 Elderly users avoiding WhatsApp and bank scams
  • 👩 Women identifying fake job offers and harassment
  • 📱 Teens navigating toxic online spaces
  • 💼 Adults spotting investment scams and fake news

In a world where misinformation spreads faster than truth, and where digital scams cost billions every year, tools like TruthLens AI represent a practical, accessible step toward a safer, more trusted internet for everyone.


"The best protection against online harm is awareness. TruthLens AI makes that awareness instant, simple, and available to all."

Built With

  • bcrypt
  • css-variables
  • css3
  • flask
  • flask-cors
  • html5
  • javascript
  • keyword-analysis
  • mysql
  • mysql-connector-python
  • python
  • python-dotenv
  • responsive-design
  • rest-api
  • rule-based-nlp
  • sentiment-analysis
  • session-authentication
  • vanilla-js
Share this project:

Updates