Skip to content
dev9024Public

About

CrimeGPT - AI-Powered Crime Documentation & Legal Intelligence Platform for Indian Police Departments (BNS / BNSS / BSA compliant)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

CrimeGPT – AI-Powered Crime Documentation & Legal Intelligence Platform

CrimeGPT is a production-quality, hackathon-ready digital platform designed for Indian Police Departments. It streamlines case workflow registration (from FIR to Arrest), eliminates redundant paperwork, maintains an evolving Case Diary, and utilizes AI-powered legal matching to recommend BNS/BNSS/BSA sections and judicial precedents.


🚀 Key Platform Objectives Met

  • No Duplicate Entry: Officers input details (Victims, Accused, Location, Narratives) once into a Central Case Data Pool. Multiple document templates pull from this pool dynamically.
  • 12 Auto-Generated Documents: Supports compile, preview, and download of:
    • Supplementary (Purvani) Chargesheet
    • Medical Treatment Letter
    • Police Custody Remand Request (BNSS Sec 187)
    • Court Custody Letter
    • Seizure Receipt / Memo (BNSS Sec 185)
    • Accused Panchanama
    • Face Identification Form
    • Witness Statement Record
    • Notice of Appearance (BNSS Sec 35(3))
    • Arrest Memo (DK Basu compliant)
    • Search Memo
    • Recovery Memo (BSA Sec 23)
  • Evolving Case Diary: Maintains a chronological, tamper-evident timeline log of all actions.
  • AI Section Predictor & RAG: Matches narratives to relevant sections of BNS, BNSS, BSA, IPC, CrPC, and Evidence Act, providing explanatory reasoning and Supreme Court landmark case citations.
  • Multilingual Legal Translation: Supports legal terminology across English, Hindi, and Gujarati.
  • SHA256 Evidence Hashing: Calculates cryptographic hash of evidence files on upload, securing chain of custody and geo-tagging locations.
  • Security Logs & Audit Trails: Tracks who changed which case variables, logging timestamps, actor, and old_value vs new_value.

🛠️ Quick Start Guide (One-Click Setup)

To start the prototype in a local environment on Windows, use the custom batch script which automatically creates a virtual environment, installs dependencies, seeds the database, and launches the dashboard.

Run with Batch Script (Recommended for Windows)

  1. Double-click or execute the runner script in PowerShell/Command Prompt:
    .\run.bat
  2. The script will initialize .venv, upgrade pip, install libraries, seed datasets, start the FastAPI server, and open your browser automatically at: http://localhost:8000/

Manual Installation (From Scratch)

If you prefer to run the commands manually:

  1. Initialize the virtual environment:
    python -m venv .venv
  2. Activate the virtual environment:
    • Windows PowerShell: .\.venv\Scripts\Activate.ps1
    • Windows CMD: .\.venv\Scripts\activate.bat
    • macOS/Linux: source .venv/bin/activate
  3. Install the dependencies:
    pip install -r backend/requirements.txt
  4. Seed the dataset JSON files:
    python datasets/generate_datasets.py
  5. Run the server:
    python -m uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 --reload
  6. Open your browser and navigate to: http://localhost:8000/

🔐 Default Authentication Credentials

The system pre-seeds default credentials at database startup for demo flows:

  • Investigation Officer (IO):
    • Username: io_rajesh
    • Password: password123
  • Station House Officer (SHO):
    • Username: sho_arvind
    • Password: password123
  • Administrator:
    • Username: admin_ops
    • Password: password123

📐 Technology Stack

  • Frontend Workspace: React, TypeScript, Material UI (MUI), Lucide, Tailwind, React Router.
  • FastAPI Hosting Environment: Served as a Single Page Application at root, CORS enabled.
  • Backend Server: Python FastAPI, Pydantic, SQLAlchemy.
  • Database & Storage: SQLite (crimegpt.db), filesystem upload registers.
  • AI, NLP & RAG: Python TF-IDF, Cosine Similarity, keyword boosting vector matcher.
  • Document Engines: python-docx for .docx formatting, native ReportLab for print-ready .pdf generations.
  • Deployment: Dockerfile, docker-compose.yml configuration files.

📂 Codebase Layout

CrimeGPT/
├── backend/
│   ├── app/
│   │   ├── routes/             # Authentication, Case CRUD, Evidence, AI RAG, Audit
│   │   ├── static/             # Host directory for React Dashboard (index.html)
│   │   ├── auth.py             # Bcrypt direct hashing and JWT sign verification
│   │   ├── config.py           # Uploads/documents static directory configurations
│   │   ├── database.py         # SQLAlchemy engine and local SQLite setup
│   │   ├── models.py           # User, Case, Victim, Accused, Witness, Evidence, Diary
│   │   └── main.py             # FastAPI entrypoint, mounts routers & static SPA
│   └── requirements.txt
├── frontend/                   # Standalone Vite + React + TypeScript compilation workspace
│   ├── package.json
│   ├── tsconfig.json
│   └── src/
├── ai_engine/                  # NLP engines (FIR summarizer, risks, duplicates)
├── legal_engine/               # RAG mappings for BNS/IPC and judgements datasets
├── document_engine/            # docx compile engines & native ReportLab PDF generators
├── ocr_engine/                 # Document scan regex-assisted entity extractors
├── datasets/                   # Seeding datasets (100 FIRs, witness logs, judgements)
├── docker/                     # Dockerfile and Docker Compose configurations
├── docs/                       # Architecture, user manual, and demo scripts
├── tests/                      # 9 Pytest cases verifying core system functions
└── run.bat                     # Bootstrapper batch file

🧪 Running the Verification Test Suite

Verify the system compliance and compilation functions using the Pytest suite. Ensure the virtual environment is active first.

python -m pytest tests/test_crimegpt.py

The test runner will execute 9 comprehensive tests validating:

  1. Password hashing security algorithms.
  2. JWT token creation and encryption.
  3. User database insertion.
  4. Case registration and data pool variable matching.
  5. AI RAG section recommendations from incident text.
  6. AI landmark judgements citation accuracy.
  7. AI compliance risk warnings.
  8. DOCX and PDF compilation.
  9. OCR text parsing and form filling.

About

CrimeGPT - AI-Powered Crime Documentation & Legal Intelligence Platform for Indian Police Departments (BNS / BNSS / BSA compliant)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages