-
-
Paste text, upload a screenshot, or upload a PDF — RedFlagged runs it through rule-based detection and AI-grounded analysis.
-
Flags a fake refund scam demanding an upfront UPI 'processing fee' a classic advance-fee pattern, with evidence quoted from message
-
Tells why it was flagged and how it identified it
-
Give suggestions on what to do
-
Example with no scam message
-
correctly show low risk
-
Tells the appropriate step accordingly
-
It is based on the provided content and common scam indicators
Inspiration
Scam messages that mimic legal or government notices — fake arrest warrants, fake Aadhaar-linkage threats, fake cybercrime cell summons — work by manufacturing panic. They're written to make people act in minutes, before they have time to think or ask anyone for help. We wanted to build something that gives people back that time: a way to paste a suspicious message and immediately see why it's suspicious, in plain language, before they send money or share sensitive information.
What it does
RedFlagged takes a suspicious legal- or government-looking message — pasted as text, an image, or a PDF — and returns a structured risk assessment:
- Extraction — OCR (for images) pull out the raw content, with an editable step so the user can correct any OCR mistakes before analysis
- Deterministic risk scoring — a rule-based engine checks for known warning-sign patterns (urgent payment demands, unofficial contact channels, threat language, suspicious deadlines) and produces a transparent, explainable score
- Grounded AI explanation — an LLM interprets the flagged evidence against a curated knowledge base of how real institutions actually communicate, and generates a plain-language summary, red flags with supporting evidence, and concrete next steps
- Verification guidance — rather than declaring a message "real" or "fake," RedFlagged points the user toward how to independently verify it through official channels
We were deliberate about not claiming the system determines legal authenticity. It surfaces warning signs and evidence — the human still decides, but with far more information than a scary WhatsApp message alone gives them.
How we built it
- Frontend: React + Vite + Tailwind, deployed on Vercel
- Backend: Python + FastAPI, deployed on Render
- OCR/extraction: Tesseract (via
pytesseract) for images - Risk engine: a deterministic, weighted rule-checker (
rules.py) that runs before any AI call, so the numeric risk score itself is never something the model can hallucinate — it's the sum of points from rules that actually triggered. The risk level label (LOW/MEDIUM/HIGH), by contrast, comes from Gemini's own structured judgment of the full message and context, not from a fixed formula applied to the score — a distinction we're still tightening (see Challenges) - Knowledge grounding: a small curated knowledge base (
knowledge.py) of verified information about how institutions like police, courts, and government departments actually communicate, retrieved and passed into the prompt as context - AI layer: Google's Gemini API, called with a strict JSON response schema (via
google-genai's structured output) so the frontend always receives a predictable shape rather than freeform text
We designed the pipeline so the AI is never the only thing standing between a scam message and the user's decision — the rule engine and knowledge base do the deterministic, checkable work, and the LLM's job is narrower: turning that evidence into a clear explanation.
Challenges we ran into
- CORS between Vercel and Render. Vercel assigns a new, unique URL to every single deployment, so hardcoding one of those into our backend's allowed origins broke again the next time we deployed. We fixed it by pointing CORS at Vercel's stable production domain instead, plus a regex fallback for preview URLs.
- Getting reliable structured output from the LLM. Early on, the model occasionally wrapped its JSON in markdown fences or added extra commentary. Moving to Gemini's native structured-output schema (rather than prompting "return only JSON") solved this far more reliably than prompt engineering alone.
- OCR quality on real-world screenshots. Phone-camera photos of screens are noisy. We added an editable extracted-text step specifically so OCR imperfection never silently corrupts the analysis — the user always sees and can correct what the system read before it's analyzed.
- Staying within scope on a five-day timeline. It was tempting to add vector search, multilingual output, and a full classifier. We deliberately kept the knowledge base as curated markdown files and the classifier rule-based, so we had a fully working, polished product rather than several half-finished advanced features.
- Reconciling the rule-based score with the AI's risk level. Because the numeric score and the risk-level label come from two independent sources (our rule engine and Gemini's own judgment), they can occasionally land in different places for the same message — a moderate score alongside a HIGH label, for example. This is still an open item we'd like to tighten rather than paper over.
- A false positive we caught by deliberately testing a benign message. An early version of our rule engine matched urgency keywords (like "urgent") without checking for negation, so a message stating "there is no urgent deadline" was incorrectly flagged, and Gemini compounded it by building a "contradiction" narrative around two reputable domains (google.com, github.com) mentioned in the message. We fixed both layers: negation-aware matching in the rule engine, plus explicit prompt guidance telling Gemini not to treat well-known domains as inherently suspicious or invent contradictions the rule engine doesn't independently support. Re-tested afterward: the same message now correctly returns LOW risk with no fabricated narrative, and our existing scam test cases still correctly triggered HIGH risk — so the fix didn't cost us any true positives.
- Rule-engine coverage gaps. Testing against scam types outside our original four scenarios surfaced that our link-detection rule didn't catch shortened URLs (e.g.
bit.lylinks) — Gemini's own evidence analysis caught it independently, which was reassuring, but meant the rule engine and the AI's evidence list could disagree. We extended the link pattern to cover common shorteners and confirmed the fix on a live customs-scam test message.
Accomplishments that we're proud of
- A genuinely hybrid architecture — deterministic rules and a curated knowledge base do the load-bearing, checkable work, and the AI is used specifically where it's good: interpreting context and explaining evidence in plain language
- An end-to-end pipeline that handles three different input types (text, image, PDF) and degrades gracefully at each stage
- Clear, honest safety positioning throughout the product — the disclaimer isn't a footnote, it's part of the actual UX
- Correctly classifying scenarios outside our four built-in quick-select categories (e.g. a courier/customs phishing message was classified as its own situation type, not forced into an unrelated bucket), which suggests the AI layer generalizes rather than only pattern-matching to scenarios we hand-tuned for
What we learned
- How much of "trustworthy AI" comes from what you don't ask the model to do — pushing the risk scoring and fact-grounding into deterministic code made the whole system more explainable and harder to make say something wrong
- Practical experience with structured LLM output (JSON schemas) as a much more reliable pattern than prompt-only formatting instructions
- The real-world quirks of deploying a two-service app (Vercel + Render) — particularly around CORS and environment variable management across two different hosting platforms
What's next for RedFlagged
- Aligning the numeric rule score and the AI-assigned risk level so they consistently agree
- Hindi and Gujarati output, so the plain-language explanation reaches people in the language they're most comfortable reading
- Expanding the curated knowledge base to more scenario types (financial fraud, fake job offers, phishing)
- A "why was this flagged?" transparency panel showing the exact rule weights and knowledge sources behind each result
- Community-reported pattern sharing, so newly emerging scam wording gets picked up faster than manual knowledge-base updates alone
Log in or sign up for Devpost to join the conversation.