Skip to content

About

Intelligent Conversational AI for KSP Crime Database. The proposed solution should enable users to discover hidden relationships between crimes, offenders, victims, locations, and socio-economic patterns, support investigative decision making, and provide predictive and preventive insights to strengthen proactive law enforcement.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KSP Crime Conversational AI & Crime Analytics Platform

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.


🚀 Key Features

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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).
  7. Explainable AI (XAI) Transparency:

    • Collapsible panel under every chatbot response detailing the exact SQLite query executed, reasoning path, and database table matches.
  8. 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.

🛠️ Technology Stack

  • 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)

📁 Directory Structure

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)

🗄️ Database Schema Design

The system runs on a relational SQLite database (ksp_crime.db) with five core tables:

  1. firs: ID, district, station, crime type, Modus Operandi (MO), date, time, coordinates, severity, and socio-economic variables (education_index, economic_stress, migration_index).
  2. accused: ID, FIR ID, name, age, gender, contact phone, bank account, past crime count, gang association, risk score, and behavioral profile description.
  3. victims: ID, FIR ID, name, age, gender, relationship to accused, and impact severity.
  4. transactions: ID, FIR ID, sender account, receiver account, transfer amount, date, status, and risk flag.
  5. audit_logs: Log ID, user role, action, timestamp, and details text.

🚀 Setup & Execution Instructions

Follow these steps to run the application on your local machine:

1. Prerequisiets

Ensure Python 3.13+ is installed on your Windows machine.

2. Install Python Dependencies

Open PowerShell or Command Prompt, navigate to the project directory, and run:

pip install -r requirements.txt

Dependencies include: fastapi, uvicorn, pandas, reportlab, scikit-learn, networkx

3. Start the Local Server

Launch the FastAPI application:

python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload

This automatically runs database initialization (app/database.py) if ksp_crime.db is missing, populates seed records, and runs the development server.

4. Access the Web Dashboard

Open your web browser and navigate to:

http://127.0.0.1:8000

🧪 Testing and Verification

You can verify the backend functionality using the automated test suite located in the brain scratchpad folder:

  1. 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.

  2. 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.

About

Intelligent Conversational AI for KSP Crime Database. The proposed solution should enable users to discover hidden relationships between crimes, offenders, victims, locations, and socio-economic patterns, support investigative decision making, and provide predictive and preventive insights to strengthen proactive law enforcement.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages