AI-powered platform to detect and disrupt digital arrest scams, counterfeit currency, fraud networks, and crime hotspots - built for the "AI for Digital Public Safety" hackathon challenge.
India registered 1.14 million cybercrime complaints in 2023, and "digital arrest" scams alone defrauded citizens of over โน1,776 crore in the first nine months of 2024. This platform tackles the problem with five integrated AI modules - shifting law enforcement and citizens from reactive investigation to proactive threat detection.
| Module | What it does |
|---|---|
| ๐จ Digital Arrest Scam Detection | Analyzes call transcripts, WhatsApp/SMS/email text โ scam probability, risk level, explanation, recommended action |
| ๐ต Counterfeit Currency Detection | Computer vision analysis of currency note images โ genuine/counterfeit verdict, confidence score, highlighted suspicious regions |
| ๐ธ๏ธ Fraud Network Graph Intelligence | Maps phone/device/account linkages from transaction data โ fraud cluster detection, interactive graph visualization |
| ๐บ๏ธ Geospatial Crime Intelligence | Plots fraud incidents on a map โ hotspot detection, district-wise risk scoring |
| ๐ค Citizen Fraud Assistant | Multilingual chatbot - explains scams, analyzes suspicious messages, guides reporting to cybercrime.gov.in / 1930 |
Access is gated by a JWT login and enforced server-side - the role is not a client-side toggle. Sign in decides which modules you can reach:
| Role | Login | Can access |
|---|---|---|
| Police | police / police123 |
All modules |
| Bank | bank / bank123 |
Dashboard, Scam Checker, Currency Checker |
| Citizen | citizen / citizen123 |
Dashboard, Scam Checker, Citizen Assistant |
Currency (/currency/*) requires police or bank; Fraud Graph (/graph/*) and
Geo Intel (/geo/*) are police-only - other roles get an HTTP 403.
Auth behaviour is configurable via env vars (JWT_SECRET_KEY, JWT_EXPIRE_HOURS,
REQUIRE_AUTH).
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ React Frontend (Vite) โ
โ Dashboard | Scam Checker | Currency Scan | Graph | Map โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST (axios)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Backend (Uvicorn) โ
โ /scam /currency /graph /geo /chat routers โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโค
โ Scam ML โ CV Model โ NetworkX โ Geo utils โ LLM API โ
โ (sklearn) โ (OpenCV) โ (fraud โ (heatmap/ โ (Groq) โ
โ โ โ clusters)โ hotspot) โ โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ SQLite (app.db) โ
โ scams, currency, โ
โ transactions, โ
โ incidents โ
โโโโโโโโโโโโโโโโโโโโโ
| Layer | Technology | Why |
|---|---|---|
| Frontend | React + Vite + Tailwind CSS | Fast dev, minimal config |
| Backend | FastAPI + Uvicorn | Async, auto Swagger docs, Python-native |
| Database | SQLite (SQLAlchemy ORM) | Zero setup, easy Postgres upgrade path |
| Scam Detection | TF-IDF + Scikit-learn Logistic Regression + keyword rules | Lightweight, explainable, fast |
| Currency Detection | OpenCV heuristics (edge/sharpness/color/texture analysis) | Explainable, no training data required |
| Graph Intelligence | NetworkX + Pyvis | Fraud ring clustering + interactive visualization |
| Geospatial | React-Leaflet + OpenStreetMap | Free, no API key required |
| Chatbot | Groq API (Llama 3.1 8B Instant) | Fast, free-tier, multilingual |
digital-safety-ai/
โโโ backend/
โ โโโ app/
โ โ โโโ main.py
โ โ โโโ database.py
โ โ โโโ models.py
โ โ โโโ routers/
โ โ โ โโโ scam.py
โ โ โ โโโ currency.py
โ โ โ โโโ graph.py
โ โ โ โโโ geo.py
โ โ โ โโโ chat.py
โ โ โโโ ml/
โ โ โ โโโ scam_classifier.py
โ โ โ โโโ train_scam_model.py
โ โ โ โโโ currency_model.py
โ โ โ โโโ graph_engine.py
โ โ โ โโโ chat_service.py
โ โ โ โโโ artifacts/ # trained model files
โ โ โโโ utils/
โ โ โ โโโ geo_utils.py
โ โ โโโ static/ # generated graph HTML
โ โโโ requirements.txt
โ โโโ .env
โโโ frontend/
โโโ src/
โ โโโ App.jsx
โ โโโ api.js
โ โโโ pages/
โ โโโ Dashboard.jsx
โ โโโ ScamChecker.jsx
โ โโโ CurrencyChecker.jsx
โ โโโ FraudGraph.jsx
โ โโโ GeoIntel.jsx
โ โโโ CitizenAssistant.jsx
โโโ package.json
โโโ tailwind.config.js
- Python 3.10+
- Node.js 18+
- A free Groq API key (for the chatbot module)
git clone https://github.com/<your-username>/digital-safety-ai.git
cd digital-safety-aicd backend
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in backend/ (all values are optional - the app boots
without them; only the chatbot needs the Groq key):
GROQ_API_KEY=your_free_groq_key_here # optional - chatbot degrades gracefully if unset
DATABASE_URL=sqlite:///./app.db # swap for postgresql://โฆ in production
JWT_SECRET_KEY=change-me-in-production # optional - a default is used otherwise
JWT_EXPIRE_HOURS=8 # optional
# ALLOWED_ORIGINS=http://localhost:5173 # optional CORS allow-list
# REDIS_URL=redis://localhost:6379/0 # optional - falls back to in-memory cacheNote: the counterfeit-currency CNN is optional and not installed by default (it stays disabled and falls back to OpenCV heuristics). To enable it, install
torch/torchvisionfor your platform and drop trained weights intobackend/app/ml/weights/.
Train the scam classifier (one-time):
python -m app.ml.train_scam_modelRun the backend:
uvicorn app.main:app --reloadAPI docs available at โ http://127.0.0.1:8000/docs
cd frontend
npm install
npm run devApp available at โ http://localhost:5173
| Method | Endpoint | Role | Description |
|---|---|---|---|
POST |
/auth/login |
public | Exchange username/password for a JWT |
GET |
/auth/me |
any | Current token payload |
GET |
/dashboard/stats |
any | Aggregated dashboard statistics (cached) |
POST |
/scam/analyze |
any | Analyze text for scam indicators |
GET |
/scam/history |
any | Recent scam analysis history |
POST |
/scam/report/{id} |
any | Generate NCRB-style PDF for a scam record |
POST |
/currency/analyze |
police, bank | Upload currency note image for verification |
GET |
/currency/history |
police, bank | Recent currency check history |
POST |
/graph/ingest |
police | Ingest transaction records |
GET |
/graph/analyze |
police | Get fraud clusters |
GET |
/graph/view |
public | Interactive fraud network graph (HTML, iframe-embeddable) |
POST |
/graph/query |
police | Query the graph - COUNT, SUSPICIOUS, HUBS, or a node id |
POST |
/geo/ingest |
police | Ingest fraud incident coordinates |
GET |
/geo/heatmap |
police | Raw incident points |
GET |
/geo/hotspots |
police | Detected crime hotspots |
GET |
/geo/district-risk |
police | District-wise risk scoring |
POST |
/audio/analyze |
any | |
POST |
/chat/message |
any | Chat with the citizen fraud assistant (rate-limited) |
Use the Swagger UI at /docs to test each endpoint interactively, or use the frontend pages directly:
| Page | Route |
|---|---|
| Dashboard | / |
| Scam Checker | /scam |
| Currency Checker | /currency |
| Fraud Graph | /graph |
| Geo Intelligence | /geo |
| Citizen Assistant | /assistant |
- Scam classifier trained on a small synthetic dataset - production use would need a larger labeled corpus of real scam transcripts.
- Currency detection uses classical CV heuristics (no labeled FICN dataset available) rather than a trained CNN - a documented, explainable trade-off for hackathon scope. Swapping in a fine-tuned CNN is a planned improvement.
- Audio deepfake detection is a demo stub that returns a simulated result - it is clearly labeled as such in the UI and API and is not real spoofing detection.
- SQLite is used for simplicity - swap
DATABASE_URLfor PostgreSQL in production. - Auth ships with in-source demo users and a default JWT secret - set
JWT_SECRET_KEYand back it with a real user store for production.
- Fine-tuned CNN for counterfeit currency detection on labeled FICN datasets
- Real-time call/voice deepfake detection (speech AI)
- Direct NCRB / cybercrime.gov.in reporting integration
- Neo4j/graph database for larger-scale fraud network analysis
- Mobile app + WhatsApp/IVR integration for the citizen assistant
- Court-admissible intelligence report export (PDF)
Built for the AI for Digital Public Safety hackathon challenge - Defeating Counterfeiting, Fraud & Digital Arrest Scams.
MIT License - see LICENSE for details.