See it. Ask it. Understand the risk.
RedFlag AI is a hackathon demo for scam detection and safety storytelling. The app analyzes suspicious text, screenshots, links, and voice-style transcripts, then generates structured safety guidance and a short educational story that explains how the scam could unfold.
The project is now optimized for a single-service deployment on Google Cloud Run.
That gives you:
- one public demo link
- one Next.js app handling both UI and API routes
- optional live Gemini mode
- optional locked free demo mode for judges
Browser UI
-> Next.js app on Cloud Run
-> /api/analyze-text
-> /api/analyze-link
-> /api/analyze-image
-> /api/generate-story
-> Gemini via Google GenAI JavaScript SDK
-> Structured JSON returned to the UI
- Next.js frontend captured text, links, screenshots, and optional voice transcript input.
- FastAPI handled backend routes.
- Gemini was called through the Google SDK for multimodal analysis.
- The backend returned structured JSON for risk level, summary, signals, guidance, and confidence note.
- A second Gemini prompt generated the creative story layer.
- The intended host was Google Cloud Run with a split frontend/backend setup.
- Next.js still drives the UI.
- Next.js API routes now act as the backend.
- Gemini is called server-side with the Google GenAI JavaScript SDK.
- Story mode includes both narrative output and a visual scene description.
- The app can run on Cloud Run either in live Gemini mode or in a locked free demo mode.
Free demo mode is meant for judge-facing public links.
When NEXT_PUBLIC_DEMO_MODE_LOCK=true:
- the app stays in demo mode
- built-in sample buttons use instant mock outputs
- custom live Gemini analysis is blocked
- you can deploy without consuming Gemini credits during the demo flow
This is the safest public demo setup.
NEXT_PUBLIC_DEMO_MODE_DEFAULT=true
NEXT_PUBLIC_DEMO_MODE_LOCK=trueGemini variables are optional in this mode because built-in sample scenarios do not call Gemini.
GEMINI_API_KEY=your_google_genai_api_key
GEMINI_MODEL=gemini-2.0-flash
NEXT_PUBLIC_DEMO_MODE_DEFAULT=false
NEXT_PUBLIC_DEMO_MODE_LOCK=falseGEMINI_API_KEY=your_google_genai_api_key
GEMINI_MODEL=gemini-2.0-flash
NEXT_PUBLIC_DEMO_MODE_DEFAULT=true
NEXT_PUBLIC_DEMO_MODE_LOCK=falseThat lets you start in free demo mode but still toggle into live mode yourself.
cd frontend
npm install
npm run devCreate frontend/.env.local with either the free demo or live mode values above.
Open http://localhost:3000.
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud run deploy redflag-ai \
--source ./frontend \
--region us-central1 \
--platform managed \
--allow-unauthenticated \
--set-env-vars NEXT_PUBLIC_DEMO_MODE_DEFAULT=true,NEXT_PUBLIC_DEMO_MODE_LOCK=truegcloud run deploy redflag-ai \
--source ./frontend \
--region us-central1 \
--platform managed \
--allow-unauthenticated \
--set-env-vars GEMINI_API_KEY=YOUR_API_KEY,GEMINI_MODEL=gemini-2.0-flash,NEXT_PUBLIC_DEMO_MODE_DEFAULT=false,NEXT_PUBLIC_DEMO_MODE_LOCK=falsegcloud run deploy redflag-ai \
--source ./frontend \
--region us-central1 \
--platform managed \
--allow-unauthenticated \
--set-env-vars GEMINI_API_KEY=YOUR_API_KEY,GEMINI_MODEL=gemini-2.0-flash,NEXT_PUBLIC_DEMO_MODE_DEFAULT=true,NEXT_PUBLIC_DEMO_MODE_LOCK=falseGET /api/healthPOST /api/analyze-textPOST /api/analyze-linkPOST /api/analyze-imagePOST /api/generate-story