An intelligent Conversational AI and Crime Analytics Platform designed for the Karnataka State Police (KSP) database. It enables investigators, supervisors, analysts, and policymakers to interact with the state crime database using natural language queries (in English and Kannada), visualize suspect networks and financial transaction money trails, inspect geo-hotspots, study sociological risk correlations, and receive AI-driven crime forecasts and early warnings.
-
Conversational Crime Intelligence Interface:
- Bilingual Support: Ask questions in English or Kannada (e.g.
"ಪ್ರಕರಣ FIR-2026-0003 ರ ಆರೋಪಿ ಯಾರು?"/"Who is the accused in FIR-2026-0003?"). - Voice Support: Integrated browser-native Speech-to-Text (STT) and Text-to-Speech (TTS) for voice input and spoken audio replies.
- Context Retention: Context-aware queries (resolves pronouns like
"Where does he live?"based on chat history). - PDF Transcripts: Local export compilation of the chat history into a formal PDF report.
- Bilingual Support: Ask questions in English or Kannada (e.g.
-
Criminal Network & Relationship Analysis:
- Interactive Vis.js relationship diagrams linking Accused, Cases (FIRs), Victims, Bank Accounts, Locations, and Organized Gangs.
- Automatically highlights links like shared contacts (suspects sharing phone numbers) and gang structures to expose organized networks.
-
Crime Pattern & Hotspot Analytics:
- Dark-mode Leaflet.js GIS map overlays highlighting crime hotspot coordinates color-coded by severity.
- Breakdown of cases by station and crime type.
-
Criminology & Sociological Insights:
- Scatter plots correlating crime frequency with socio-economic indicators across districts (e.g., Urbanization/Literacy vs. Cyber/Financial Crimes, Economic Stress vs. Property Theft).
- Breakdown of demographics (age groups and gender metrics) of tracked accused.
-
AI Crime Forecasting & Early Warnings:
- Projected monthly crime frequencies using linear trends and seasonal multipliers (highlights holiday/festival spikes).
- Alerts for active cyber rings and seasonal property crimes.
-
Offender Profiling & Case Timelines:
- Comprehensive offender profiling cards displaying calculated risk scores, aliases, behavioral notes, and case links.
- Interactive case summaries with audit-level timelines and Modus Operandi similarity scoring (compares case MO text parameters to suggest leads).
-
Explainable AI (XAI) Transparency:
- Collapsible panel under every chatbot response detailing the exact SQLite query executed, reasoning path, and database table matches.
-
Role-Based Access Control (RBAC) Governance:
- Dynamic UI masking of Personally Identifiable Information (PII) like names, phone numbers, and bank accounts for the Policymaker role.
- Secure logging of queries and file exports to a local audit database. Access to audit lists is locked to the Supervisor role.
- Backend: Python 3.13 (FastAPI, Uvicorn, Pandas, ReportLab, SQLite3)
- Frontend: Vanilla HTML5, CSS3 (Glassmorphism theme), JavaScript (ES6)
- Visualizations: Vis.js Network, Chart.js (v4), Leaflet.js (GIS Mapping)
- Voice Capabilities: Browser Web Speech API (
webkitSpeechRecognition&SpeechSynthesis)
c:\Users\saipr\OneDrive\Documents\New folder\
├── app/
│ ├── __init__.py
│ ├── database.py # SQLite schema setup and seed data population
│ ├── main.py # FastAPI routes, REST API endpoints, and static folder mounts
│ ├── nlp_engine.py # English/Kannada parser, SQL mapper, and context engine
│ └── pdf_generator.py # ReportLab PDF transcript compiler
├── frontend/
│ ├── index.html # Dashboard HTML skeleton, CDNs, and panels
│ ├── styles.css # Custom CSS, dark theme colors, and glassmorphic variables
│ └── app.js # Frontend charts, networks, maps, speech, and role switches
├── requirements.txt # Python dependencies
└── README.md # Project documentation (this file)
The system runs on a relational SQLite database (ksp_crime.db) with five core tables:
firs: ID, district, station, crime type, Modus Operandi (MO), date, time, coordinates, severity, and socio-economic variables (education_index,economic_stress,migration_index).accused: ID, FIR ID, name, age, gender, contact phone, bank account, past crime count, gang association, risk score, and behavioral profile description.victims: ID, FIR ID, name, age, gender, relationship to accused, and impact severity.transactions: ID, FIR ID, sender account, receiver account, transfer amount, date, status, and risk flag.audit_logs: Log ID, user role, action, timestamp, and details text.
Follow these steps to run the application on your local machine:
Ensure Python 3.13+ is installed on your Windows machine.
Open PowerShell or Command Prompt, navigate to the project directory, and run:
pip install -r requirements.txtDependencies include: fastapi, uvicorn, pandas, reportlab, scikit-learn, networkx
Launch the FastAPI application:
python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reloadThis automatically runs database initialization (app/database.py) if ksp_crime.db is missing, populates seed records, and runs the development server.
Open your web browser and navigate to:
http://127.0.0.1:8000
You can verify the backend functionality using the automated test suite located in the brain scratchpad folder:
-
Run Backend Test Suite:
python "C:\Users\saipr\.gemini\antigravity\brain\7329ebc5-4f24-458f-af1c-2e147a43f137\scratch\test_backend.py"This validates database query outputs, Kannada/English translations, context awareness, and PII masking.
-
Run PDF Compiler Test:
python "C:\Users\saipr\.gemini\antigravity\brain\7329ebc5-4f24-458f-af1c-2e147a43f137\scratch\test_pdf.py"This compiles a test transcript and saves it as a PDF inside the
downloads/folder.