A comprehensive digital platform for seamless Police-to-Court case handover and management
| 🏆 Hackathon | 🎯 Domain | 🎬 Demo |
|---|---|---|
| Hack The Winter | Governance |
- Overview
- Features
- System Architecture
- Tech Stack
- AI-POC Module
- Database Schema
- Installation
- Commands Reference
- User Roles
- Case Flow
- API Documentation
- Project Structure
- Contributing
NyayaSankalan is a modern, full-stack Case Management System designed to digitize and streamline the entire lifecycle of criminal cases from FIR registration to court disposal. The system bridges the gap between police investigations and court proceedings, ensuring transparency, accountability, and efficiency.
- Role-Based Access Control - Police, SHO, Court Clerk, and Judge roles
- End-to-End Case Tracking - From FIR to judgment
- Document Management - Automated templates for charge sheets, evidence lists, and more
- Real-Time Status Updates - Live case state tracking
- Audit Trail - Complete history of all actions and changes
- Secure File Storage - Cloudinary integration for evidence and documents
- Validation Engine - Ensures mandatory documents before submission
- FIR Registration - Digital FIR entry with auto-case creation
- Case Assignment - SHO assigns cases to investigating officers
- Investigation Management - Track searches, seizures, statements, and transfers
- Evidence Upload - Photos, reports, forensic data, and witness statements
- Document Generation - Auto-generate charge sheets, evidence lists, and closure reports
- Document Requests - Request warrants, remand orders, and other court documents
- Bail Tracking - Monitor bail applications and status
- Case Intake - Review and acknowledge police submissions
- Cognizance & Charges - Record court actions and orders
- Trial Tracking - Monitor hearing dates and trial progress
- Judgment Upload - Store final judgments and sentences
- Case Reopen Requests - Handle requests to reopen closed cases
- JWT Authentication - Secure token-based authentication
- Role-Based Authorization - Granular access control
- Audit Logging - Track all user actions
- Access Logging - Monitor resource access
- Data Encryption - Secure sensitive information
graph TB
subgraph "Frontend Layer"
A[React SPA<br/>Vite + TypeScript]
A1[Pages]
A2[Components]
A3[Context/State]
A --> A1
A --> A2
A --> A3
end
subgraph "API Layer"
B[Express.js Server]
B1[Auth Middleware]
B2[Validation Layer]
B3[Controllers]
B --> B1
B --> B2
B --> B3
end
subgraph "Business Logic"
C[Services Layer]
C1[Case Service]
C2[Document Service]
C3[Evidence Service]
C4[Court Service]
C --> C1
C --> C2
C --> C3
C --> C4
end
subgraph "Data Layer"
D[Prisma ORM]
E[(PostgreSQL Database)]
D --> E
end
subgraph "External Services"
F[Cloudinary<br/>File Storage]
G[PDF Generation<br/>PDFKit]
end
A -->|HTTP/REST| B
B3 --> C
C --> D
C --> F
C --> G
style A fill:#61dafb,stroke:#333,stroke-width:2px
style B fill:#68a063,stroke:#333,stroke-width:2px
style C fill:#f39c12,stroke:#333,stroke-width:2px
style D fill:#2d3748,stroke:#333,stroke-width:2px
style E fill:#336791,stroke:#333,stroke-width:2px
style F fill:#3448c5,stroke:#333,stroke-width:2px
style G fill:#e74c3c,stroke:#333,stroke-width:2px
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2.0 | UI Framework |
| TypeScript | 5.9.3 | Type Safety |
| Vite | 7.2.4 | Build Tool |
| TailwindCSS | 4.1.18 | Styling |
| React Router | 7.11.0 | Routing |
| Axios | 1.13.2 | HTTP Client |
| React Hot Toast | 2.6.0 | Notifications |
| jsPDF | 3.0.4 | PDF Generation |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | ≥18.0.0 | Runtime |
| Express.js | 4.21.2 | Web Framework |
| TypeScript | 5.7.2 | Type Safety |
| Prisma | 5.22.0 | ORM |
| PostgreSQL | Latest | Database |
| JWT | 9.0.2 | Authentication |
| Bcrypt | 6.0.0 | Password Hashing |
| Cloudinary | 2.8.0 | File Storage |
| PDFKit | 0.17.2 | PDF Generation |
| Winston | 3.17.0 | Logging |
| Helmet | 8.0.0 | Security Headers |
The AI-POC (Proof of Concept) module is a specialized service that automates document processing, entity extraction, and intelligent draft generation for legal case management. It leverages advanced NLP and ML techniques to extract structured information from case documents and generate professional legal documents.
| Library | Version | Purpose |
|---|---|---|
| FastAPI | Latest | Web framework for AI service |
| Uvicorn | Latest | ASGI server |
| Pillow (PIL) | Latest | Image processing |
| pytesseract | Latest | Optical Character Recognition (OCR) |
| pdfplumber | Latest | PDF text extraction |
| spaCy | Latest | Named Entity Recognition (NER) |
| python-dotenv | Latest | Environment variable management |
| Transformers | Latest | HuggingFace transformer models |
| Requests | Latest | HTTP client |
| sentence-transformers | Latest | Text embedding generation |
| FAISS | Latest | Vector similarity search index |
| NumPy | Latest | Numerical computing |
| httpx | Latest | Async HTTP client |
graph TB
subgraph "Input Layer"
A1[Document Upload<br/>Image/PDF]
A2[Raw Text Input]
end
subgraph "Processing Pipeline"
B1[OCR Module<br/>pytesseract + pdfplumber]
B2[NER Module<br/>spaCy + regex]
B3[Text Cleaning<br/>PII Redaction]
B4[Embedding Generation<br/>sentence-transformers]
end
subgraph "AI Intelligence"
C1[Text Generation<br/>HuggingFace API]
C2[Local Transformers<br/>FLAN-T5]
C3[Semantic Search<br/>FAISS Index]
end
subgraph "Storage"
D1[Extracted Data<br/>JSON]
D2[Generated Drafts<br/>JSON]
D3[Vector Index<br/>FAISS]
end
subgraph "Output"
E1[Entities & Metadata]
E2[Redacted Text]
E3[Draft Documents]
E4[Search Results]
end
A1 --> B1
A2 --> B3
B1 --> B2
B2 --> B3
B3 --> B4
B3 --> C1
B3 --> C2
B4 --> C3
B1 --> D1
C1 --> D2
C2 --> D2
C3 --> D3
D1 --> E1
D1 --> E2
D2 --> E3
D3 --> E4
style B1 fill:#FF6B6B
style B2 fill:#4ECDC4
style B3 fill:#45B7D1
style B4 fill:#96CEB4
style C1 fill:#FFEAA7
style C2 fill:#DDA15E
style C3 fill:#BC6C25
sequenceDiagram
participant Client
participant FastAPI
participant OCR
participant NER
participant Generator
participant FAISS
participant Storage
Client->>FastAPI: POST /ocr-extract (file + caseId)
FastAPI->>OCR: Extract text from image/PDF
OCR-->>FastAPI: Extracted text
FastAPI->>NER: Extract entities & redact PII
NER-->>FastAPI: Entities, redacted text
FastAPI->>Storage: Save extraction JSON
Storage-->>FastAPI: ✓ Saved
FastAPI-->>Client: extraction ID + entities
Client->>FastAPI: POST /generate-draft (text/extractionId)
FastAPI->>Generator: Generate charge sheet draft
Generator->>Generator: Call HuggingFace API or<br/>Local Transformer
Generator-->>FastAPI: Draft content
FastAPI->>Storage: Save draft JSON
Storage-->>FastAPI: ✓ Saved
FastAPI-->>Client: document ID + draft
Client->>FastAPI: POST /index (rebuild FAISS)
FastAPI->>FAISS: Build embeddings from extractions
FAISS->>Storage: Save index + metadata
Storage-->>FastAPI: ✓ Complete
FastAPI-->>Client: Indexed count
Client->>FastAPI: GET /search?q=query&k=5
FastAPI->>FAISS: Vector similarity search
FAISS-->>FastAPI: Top-k similar documents
FastAPI-->>Client: Results with metadata
| Endpoint | Method | Description | Request Parameters |
|---|---|---|---|
/ocr-extract |
POST | Extract text from image/PDF and identify entities | file: UploadFile, caseId?: string |
/extractions/{extraction_id} |
GET | Retrieve a specific extraction result | extraction_id: string |
/generate-draft |
POST | Generate legal document draft | text?: string, extractionId?: string, model?: string |
/drafts/{doc_id} |
GET | Retrieve a generated draft document | doc_id: string |
| Endpoint | Method | Description | Request Parameters |
|---|---|---|---|
/index |
POST | Build/rebuild FAISS index from all extractions | None |
/index/doc/{extraction_id} |
POST | Index a single document | extraction_id: string |
| Endpoint | Method | Description | Request Parameters |
|---|---|---|---|
/search |
GET | Semantic similarity search across indexed documents | q: string (required), k?: int (default: 5) |
| Endpoint | Method | Description | Request Parameters |
|---|---|---|---|
/health |
GET | Service availability status | None |
The AI-POC module requires the following environment variables in .env:
# HuggingFace API Configuration
HUGGINGFACE_HUB_API_TOKEN=<your-huggingface-api-token> # Required for HuggingFace Inference API
# AI Service Configuration
MODEL_NAME=google/flan-t5-small # Default: google/flan-t5-small
# Options: google/flan-t5-large, meta-llama/Llama-2-7b, etc.
# Service Configuration
AI_SERVICE_HOST=0.0.0.0 # Bind address
AI_SERVICE_PORT=8001 # Port number
# Storage Paths
STORAGE_DIR=storage # Base storage directory
INDEX_PATH=storage/indexes/faiss.index # FAISS index pathAPI Key Details:
- HUGGINGFACE_HUB_API_TOKEN: Required for using HuggingFace Inference API
- Get it from: https://huggingface.co/settings/tokens
- Used for remote text generation via HuggingFace's hosted models
- Falls back to local transformer model if not provided
The NER module extracts the following entities:
| Entity Type | Detection Method | Redaction Status |
|---|---|---|
| IPC Sections | Regex pattern matching | Not redacted |
| Dates | Regex (YYYY-MM-DD format) | Not redacted |
| Phone Numbers | Regex (10-13 digits) | Redacted as [REDACTED_PHONE] |
| Person Names | spaCy NLP model (en_core_web_sm) | Redacted as [REDACTED] |
| Organizations | spaCy NLP model | Redacted as [REDACTED] |
-
Document Digitization: Automatically converts physical documents (photos, scans) into digital text
- OCR extracts text from images and PDFs
- Eliminates manual data entry
- Supports multiple document formats
-
Intelligent Data Extraction: Identifies and structures critical case information
- Extracts IPC sections, dates, phone numbers, names
- Provides metadata for case linking
- Reduces manual review time
-
Privacy Protection: Automatically redacts Personally Identifiable Information (PII)
- Redacts phone numbers and person names
- Maintains compliance with data protection regulations
- Preserves case integrity while protecting privacy
-
Draft Generation: Generates legal document templates automatically
- Creates charge sheet drafts from case facts
- Reduces legal document preparation time
- Ensures consistency in document format
-
Semantic Search: Enables intelligent case document retrieval
- Searches across similar cases using FAISS vector index
- Finds precedents and related documents
- Supports case law research and comparison
-
Integration with Main System:
- Generated drafts are stored and linked to specific cases
- Extractions become searchable across the database
- Audit trail tracks all AI-assisted document processing
- Case officers can review, edit, and approve AI-generated content
# Navigate to AI-POC directory
cd ai-poc
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
# Create .env file with HUGGINGFACE_HUB_API_TOKEN and other configs
# Start the service
uvicorn main:app --host 0.0.0.0 --port 8001 --reload
# Service will be available at http://localhost:8001
# API documentation: http://localhost:8001/docs (Swagger UI)
# Alternative docs: http://localhost:8001/redocai-poc/
├── main.py # FastAPI application & route handlers
├── config.py # Configuration constants
├── requirements.txt # Python dependencies
├── sanity_check.py # Validation utilities
├── test_endpoints.py # API testing script
└── utils/
├── ocr.py # pytesseract & pdfplumber integration
├── ner.py # spaCy entity extraction & PII redaction
├── generator.py # HuggingFace & local transformer wrapper
├── embeddings.py # sentence-transformers for text embeddings
└── faiss_index.py # FAISS vector index management
erDiagram
User ||--o{ Fir : registers
User ||--o{ CaseAssignment : assigns
User ||--o{ CaseAssignment : receives
User ||--o{ Evidence : uploads
User ||--o{ Document : creates
PoliceStation ||--o{ Fir : has
Court ||--o{ CourtSubmission : receives
Fir ||--|| Case : creates
Case ||--|| CurrentCaseState : has
Case ||--o{ CaseStateHistory : tracks
Case ||--o{ CaseAssignment : assigned
Case ||--o{ Accused : involves
Case ||--o{ InvestigationEvent : records
Case ||--o{ Evidence : contains
Case ||--o{ Witness : has
Case ||--o{ Document : generates
Case ||--o{ DocumentChecklist : validates
Case ||--o{ BailRecord : tracks
Case ||--o{ CourtSubmission : submitted
Case ||--o{ CourtAction : receives
Case ||--o{ DocumentRequest : requests
Case ||--o{ CaseReopenRequest : reopens
Accused ||--o{ BailRecord : applies
CourtSubmission ||--|| Acknowledgement : receives
User {
uuid id PK
string name
string email UK
string phone
UserRole role
OrganizationType organizationType
string organizationId
boolean isActive
datetime createdAt
}
Case {
uuid id PK
uuid firId FK
datetime createdAt
boolean isArchived
string closureReportUrl
}
CurrentCaseState {
uuid caseId PK
CaseState currentState
datetime updatedAt
}
graph LR
subgraph "User Roles"
UR1[POLICE]
UR2[SHO]
UR3[COURT_CLERK]
UR4[JUDGE]
end
subgraph "Case States"
CS1[FIR_REGISTERED]
CS2[CASE_ASSIGNED]
CS3[UNDER_INVESTIGATION]
CS4[INVESTIGATION_COMPLETED]
CS5[CHARGE_SHEET_PREPARED]
CS6[SUBMITTED_TO_COURT]
CS7[COURT_ACCEPTED]
CS8[TRIAL_ONGOING]
CS9[DISPOSED]
end
subgraph "Document Types"
DT1[CHARGE_SHEET]
DT2[EVIDENCE_LIST]
DT3[WITNESS_LIST]
DT4[CLOSURE_REPORT]
DT5[REMAND_APPLICATION]
end
style UR1 fill:#3498db
style UR2 fill:#e74c3c
style UR3 fill:#2ecc71
style UR4 fill:#f39c12
- Total Tables: 20
- Total Enums: 13
- Total Relations: 45+
- Indexed Fields: 30+
- Node.js ≥ 18.0.0
- PostgreSQL ≥ 14.0
- npm or yarn
- Git
git clone https://github.com/yourusername/NyayaSankalan-CMS.git
cd NyayaSankalan-CMS# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Configure environment variables
# Edit .env with your database credentials and API keysRequired Environment Variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/nyayasankalan"
# JWT
JWT_SECRET="your-super-secret-jwt-key"
JWT_EXPIRES_IN="7d"
# Cloudinary
CLOUDINARY_CLOUD_NAME="your-cloud-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"
# Server
PORT=5000
NODE_ENV=development# Generate Prisma Client
npm run db:generate
# Run database migrations
npm run db:migrate
# Seed database (optional)
npm run db:seed
# Start development server
npm run dev# Navigate to client directory
cd ../client
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Configure API endpoint
# Edit .envRequired Environment Variables:
VITE_API_URL=http://localhost:5000/api# Start development server
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Prisma Studio: Run
npm run db:studioin backend directory
| Command | Description | Use Case |
|---|---|---|
npm run dev |
Start development server with hot reload | Development |
npm run build |
Compile TypeScript to JavaScript | Production build |
npm start |
Start production server | Production |
npm run db:generate |
Generate Prisma Client | After schema changes |
npm run db:migrate |
Run database migrations | Database updates |
npm run db:push |
Push schema changes without migration | Quick prototyping |
npm run db:studio |
Open Prisma Studio GUI | Database inspection |
npm run db:seed |
Seed database with dummy data | Testing |
npm test |
Run test suite | Testing |
| Command | Description | Use Case |
|---|---|---|
npm run dev |
Start Vite dev server | Development |
npm run build |
Build for production | Deployment |
npm run preview |
Preview production build | Pre-deployment testing |
npm run lint |
Run ESLint | Code quality check |
# 1. Make changes to schema.prisma
# 2. Create a migration
npm run db:migrate
# 3. Name your migration (e.g., "add_user_avatar")
# 4. Prisma will:
# - Generate SQL migration file
# - Apply migration to database
# - Regenerate Prisma Client
# Alternative: Push without migration (dev only)
npm run db:push# Run seed script
npm run db:seed
# This will create:
# - Sample users (Police, SHO, Court Clerk, Judge)
# - Police stations
# - Courts
# - Sample FIRs and cases
# - Evidence and documentsgraph TD
A[JUDGE<br/>Highest Authority] --> B[COURT_CLERK<br/>Court Operations]
C[SHO<br/>Station Head] --> D[POLICE<br/>Investigating Officer]
style A fill:#f39c12,stroke:#333,stroke-width:3px
style B fill:#2ecc71,stroke:#333,stroke-width:2px
style C fill:#e74c3c,stroke:#333,stroke-width:2px
style D fill:#3498db,stroke:#333,stroke-width:2px
| Feature | POLICE | SHO | COURT_CLERK | JUDGE |
|---|---|---|---|---|
| Register FIR | ✅ | ✅ | ❌ | ❌ |
| Assign Cases | ❌ | ✅ | ❌ | ❌ |
| Upload Evidence | ✅ | ✅ | ❌ | ❌ |
| Create Documents | ✅ | ✅ | ❌ | ❌ |
| Request Documents | ✅ | ❌ | ❌ | ❌ |
| Approve Document Requests | ❌ | ✅ | ❌ | ❌ |
| Submit to Court | ❌ | ✅ | ❌ | ❌ |
| Acknowledge Submission | ❌ | ❌ | ✅ | ✅ |
| Record Court Actions | ❌ | ❌ | ✅ | ✅ |
| Approve Case Reopen | ❌ | ❌ | ❌ | ✅ |
| View All Cases | ❌ | ✅ | ✅ | ✅ |
flowchart TD
Start([👮 Police/SHO]) --> A[1️⃣ FIR Registration]
A --> B[2️⃣ Auto Case Creation]
B --> C[3️⃣ SHO Assigns to Officer]
C --> D[4️⃣ Investigation Phase]
D --> E{Investigation<br/>Complete?}
E -->|No| D
E -->|Yes| F{Outcome?}
F -->|Evidence Found| G[5️⃣ Prepare Charge Sheet]
F -->|No Evidence| H[5️⃣ Prepare Closure Report]
G --> I[6️⃣ Validation Check]
H --> I
I --> J{All Docs<br/>Present?}
J -->|No| K[❌ Missing Documents Alert]
K --> D
J -->|Yes| L[7️⃣ SHO Submits to Court]
L --> M[8️⃣ Court Clerk Review]
M --> N{Accepted?}
N -->|No| O[🔙 Return for Defects]
O --> D
N -->|Yes| P[9️⃣ Court Acknowledgement]
P --> Q[🔟 Trial Phase]
Q --> R[1️⃣1️⃣ Judgment]
R --> S([📁 Case Disposed/Archived])
style A fill:#3498db
style G fill:#2ecc71
style H fill:#e74c3c
style L fill:#f39c12
style R fill:#9b59b6
style S fill:#34495e
| From State | To State | Triggered By | Required Role |
|---|---|---|---|
| FIR_REGISTERED | CASE_ASSIGNED | Case assignment | SHO |
| CASE_ASSIGNED | UNDER_INVESTIGATION | Investigation start | POLICE |
| UNDER_INVESTIGATION | INVESTIGATION_COMPLETED | Investigation end | POLICE |
| INVESTIGATION_COMPLETED | CHARGE_SHEET_PREPARED | Charge sheet creation | POLICE |
| INVESTIGATION_COMPLETED | CLOSURE_REPORT_PREPARED | Closure report creation | POLICE |
| CHARGE_SHEET_PREPARED | SUBMITTED_TO_COURT | Court submission | SHO |
| SUBMITTED_TO_COURT | COURT_ACCEPTED | Court acceptance | COURT_CLERK |
| SUBMITTED_TO_COURT | RETURNED_FOR_DEFECTS | Court rejection | COURT_CLERK |
| COURT_ACCEPTED | TRIAL_ONGOING | Trial start | JUDGE |
| TRIAL_ONGOING | DISPOSED | Judgment | JUDGE |
http://localhost:5000/api
All protected routes require JWT token in header:
Authorization: Bearer <your_jwt_token>POST /auth/register # Register new user
POST /auth/login # Login user
GET /auth/me # Get current user
POST /auth/refresh # Refresh tokenPOST /firs # Register new FIR
GET /firs # Get all FIRs
GET /firs/:id # Get FIR by ID
PUT /firs/:id # Update FIR
DELETE /firs/:id # Delete FIRPOST /cases # Create new case
GET /cases # Get all cases
GET /cases/:id # Get case by ID
PUT /cases/:id # Update case
DELETE /cases/:id # Delete case
GET /cases/:id/timeline # Get case timeline
POST /cases/:id/assign # Assign case to officer
POST /cases/:id/state # Update case statePOST /cases/:id/events # Add investigation event
GET /cases/:id/events # Get investigation events
POST /cases/:id/evidence # Upload evidence
GET /cases/:id/evidence # Get all evidence
POST /cases/:id/witnesses # Add witness
GET /cases/:id/witnesses # Get all witnessesPOST /cases/:id/documents # Create document
GET /cases/:id/documents # Get all documents
GET /documents/:id # Get document by ID
PUT /documents/:id # Update document
POST /documents/:id/lock # Lock document
GET /documents/:id/pdf # Generate PDFPOST /cases/:id/requests # Create document request
GET /cases/:id/requests # Get all requests
PUT /requests/:id/approve # Approve request (SHO)
PUT /requests/:id/issue # Issue document (SHO)
PUT /requests/:id/reject # Reject request (SHO)POST /cases/:id/submit # Submit case to court
GET /court/submissions # Get all submissions
PUT /submissions/:id/accept # Accept submission
PUT /submissions/:id/return # Return for defects
POST /cases/:id/actions # Record court action
GET /cases/:id/actions # Get court actionsPOST /cases/:id/bail # Apply for bail
GET /cases/:id/bail # Get bail records
PUT /bail/:id # Update bail status{
"success": true,
"data": {
// Response data
},
"message": "Operation successful"
}{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Error description",
"details": []
}
}NyayaSankalan-CMS/
├── 📁 backend/
│ ├── 📁 prisma/
│ │ ├── schema.prisma # Database schema
│ │ ├── 📁 migrations/ # Database migrations
│ │ └── 📁 seed/ # Seed scripts
│ ├── 📁 src/
│ │ ├── server.ts # Entry point
│ │ ├── app.ts # Express app setup
│ │ ├── index.ts # Server initialization
│ │ ├── 📁 config/ # Configuration files
│ │ ├── 📁 middleware/ # Express middleware
│ │ │ ├── auth.ts # JWT authentication
│ │ │ ├── errorHandler.ts # Error handling
│ │ │ └── validator.ts # Request validation
│ │ ├── 📁 modules/ # Feature modules
│ │ │ ├── 📁 auth/ # Authentication
│ │ │ ├── 📁 fir/ # FIR management
│ │ │ ├── 📁 case/ # Case management
│ │ │ ├── 📁 investigation/ # Investigation
│ │ │ ├── 📁 document/ # Document management
│ │ │ ├── 📁 court/ # Court operations
│ │ │ └── 📁 bail/ # Bail management
│ │ ├── 📁 services/ # Business logic
│ │ │ ├── cloudinary.ts # File upload service
│ │ │ ├── pdf.ts # PDF generation
│ │ │ └── logger.ts # Logging service
│ │ ├── 📁 utils/ # Utility functions
│ │ └── 📁 prisma/ # Prisma client
│ ├── package.json
│ ├── tsconfig.json
│ └── .env
│
├── 📁 client/
│ ├── 📁 src/
│ │ ├── main.tsx # Entry point
│ │ ├── App.tsx # Root component
│ │ ├── App.css # Global styles
│ │ ├── index.css # Tailwind styles
│ │ ├── 📁 pages/ # Page components
│ │ │ ├── 📁 auth/ # Login, Register
│ │ │ ├── 📁 dashboard/ # Dashboard
│ │ │ ├── 📁 fir/ # FIR pages
│ │ │ ├── 📁 case/ # Case pages
│ │ │ ├── 📁 investigation/ # Investigation pages
│ │ │ ├── 📁 document/ # Document pages
│ │ │ └── 📁 court/ # Court pages
│ │ ├── 📁 components/ # Reusable components
│ │ │ ├── 📁 common/ # Common UI components
│ │ │ ├── 📁 forms/ # Form components
│ │ │ └── 📁 layout/ # Layout components
│ │ ├── 📁 context/ # React Context
│ │ │ └── AuthContext.tsx # Auth state management
│ │ ├── 📁 api/ # API client
│ │ │ └── axios.ts # Axios configuration
│ │ ├── 📁 types/ # TypeScript types
│ │ ├── 📁 utils/ # Utility functions
│ │ ├── 📁 routes/ # Route configuration
│ │ └── 📁 assets/ # Static assets
│ ├── package.json
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── .env
│
├── 📁 ai-poc/ # AI/ML proof of concept
├── Flow.md # System flow documentation
├── README.md # This file
└── .git/ # Git repository
cd backend
# Build TypeScript
npm run build
# Set environment to production
export NODE_ENV=production
# Run migrations
npm run db:migrate
# Start server
npm startcd client
# Build for production
npm run build
# Preview build (optional)
npm run preview
# Deploy dist/ folder to your hosting serviceBackend (.env)
- ✅ DATABASE_URL
- ✅ JWT_SECRET
- ✅ JWT_EXPIRES_IN
- ✅ CLOUDINARY_CLOUD_NAME
- ✅ CLOUDINARY_API_KEY
- ✅ CLOUDINARY_API_SECRET
- ✅ PORT
- ✅ NODE_ENV
Frontend (.env)
- ✅ VITE_API_URL
| Platform | Backend | Frontend | Database |
|---|---|---|---|
| Vercel | ✅ | ✅ | ❌ |
| Netlify | ❌ | ✅ | ❌ |
| Railway | ✅ | ✅ | ✅ |
| Render | ✅ | ✅ | ✅ |
| AWS | ✅ | ✅ | ✅ |
| DigitalOcean | ✅ | ✅ | ✅ |
# Backend tests
cd backend
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coveragebackend/
└── src/
└── modules/
└── case/
├── case.controller.ts
├── case.service.ts
└── __tests__/
├── case.controller.test.ts
└── case.service.test.ts
# Check PostgreSQL is running
sudo systemctl status postgresql
# Verify DATABASE_URL in .env
# Format: postgresql://user:password@localhost:5432/dbname# Regenerate Prisma Client
npm run db:generate# Find process using port 5000
lsof -i :5000
# Kill the process
kill -9 <PID>
# Or change PORT in .env// backend/src/app.ts
// Ensure frontend URL is in CORS whitelist
const corsOptions = {
origin: ['http://localhost:5173'],
credentials: true
};| Metric | Target | Current |
|---|---|---|
| API Response Time | < 200ms | ✅ |
| Database Query Time | < 50ms | ✅ |
| Frontend Load Time | < 2s | ✅ |
| Lighthouse Score | > 90 | ✅ |
- ✅ JWT token expiration (7 days)
- ✅ Password hashing with bcrypt (10 rounds)
- ✅ Helmet.js for security headers
- ✅ Input validation with express-validator
- ✅ SQL injection prevention (Prisma ORM)
- ✅ XSS protection
- ✅ CORS configuration
- ✅ Rate limiting (recommended)
- ✅ HTTPS in production (recommended)
- User authentication
- FIR registration
- Case management
- Investigation tracking
- Document generation
- Court submission
- Real-time notifications
- Advanced search & filters
- Analytics dashboard
- Mobile app (React Native)
- SMS/Email notifications
- Multi-language support
- Predictive case outcomes
- Document auto-classification
- Smart case assignment
- Anomaly detection
- Natural language processing for FIRs
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier
- Write meaningful commit messages
- Add tests for new features
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work - GitHub
- Inspired by the need for digital transformation in the Indian judicial system
- Built for Hack The Winter hackathon
- Thanks to all contributors and supporters
For support, email support@nyayasankalan.com or join our Slack channel.
- Prisma Documentation
- Express.js Guide
- React Documentation
- TypeScript Handbook
- PostgreSQL Documentation
Made with ❤️ for a better justice system
⭐ Star this repo if you find it helpful!