Skip to content

Anish-2005/LawAI-PrivacyV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›๏ธ LawAI - Legal Intelligence Platform

LawAI Logo

Empowering Law Enforcement with AI - A Smart India Hackathon 2024 Project

License React Native Django Python AI Powered

๐ŸŒŸ Overview

LawAI is a revolutionary AI-powered legal intelligence platform developed for Smart India Hackathon 2024. This is the non-LLM version that leverages traditional machine learning models for legal document processing and query resolution. The platform empowers law enforcement officers with cutting-edge technology to streamline legal processes, enhance FIR filing efficiency, and provide instant access to comprehensive legal databases.

โœจ Key Features

๐Ÿค– AI-Powered Legal Assistant

  • Intelligent Query Processing: Natural Language Processing for legal queries
  • Smart Document Analysis: Automated legal document interpretation
  • Voice Recognition: Speech-to-text functionality for hands-free operation
  • Multi-language Support: Hindi, Bengali, Tamil, Telugu, Marathi, and English

๐Ÿ“š Comprehensive Legal Database

  • Bharatiya Nyaya Sanhita (BNS) - Latest criminal law framework
  • Indian Penal Code (IPC) - Traditional criminal law provisions
  • Code of Criminal Procedure (CrPC) - Criminal procedure guidelines
  • Indian Evidence Act (IEA) - Evidence law provisions
  • Code of Civil Procedure (CPC) - Civil procedure rules
  • Motor Vehicles Act (MVA) - Traffic and vehicle regulations

๐Ÿ” Advanced Search Capabilities

  • Semantic Search: Context-aware legal document retrieval
  • Section-wise Navigation: Quick access to specific legal sections
  • Keyword-based Filtering: Efficient content discovery
  • Cross-reference Analysis: Related law suggestions

๐Ÿ“„ Document Management

  • FIR Template Generation: Automated FIR document creation
  • PDF Processing: Legal document parsing and analysis
  • Export Functionality: Multiple format support
  • Document Preview: In-app PDF viewer

๐Ÿ—๏ธ Architecture

The project follows a modern three-tier architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Frontend      โ”‚    โ”‚   Mobile App    โ”‚    โ”‚    Backend      โ”‚
โ”‚   (React.js)    โ”‚โ—„โ”€โ”€โ–บโ”‚ (React Native)  โ”‚โ—„โ”€โ”€โ–บโ”‚   (Django)      โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข Web Interface โ”‚    โ”‚ โ€ข Mobile UI     โ”‚    โ”‚ โ€ข API Services  โ”‚
โ”‚ โ€ข Responsive    โ”‚    โ”‚ โ€ข Offline Mode  โ”‚    โ”‚ โ€ข ML Models     โ”‚
โ”‚ โ€ข PWA Support   โ”‚    โ”‚ โ€ข Push Notificationsโ”‚ โ€ข Database      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Technology Stack

Frontend (Web)

  • Framework: React.js 18.3.1
  • Styling: Tailwind CSS
  • Icons: React Icons, FontAwesome
  • Animations: Framer Motion
  • Charts: Recharts
  • HTTP Client: Axios

Mobile Application

  • Framework: React Native 0.76.3
  • Navigation: React Navigation 7.x
  • UI Components: React Native Paper
  • Voice Recognition: React Native Voice
  • PDF Handling: React Native PDF
  • Storage: AsyncStorage

Backend

  • Framework: Django 5.1.3
  • Database: PostgreSQL
  • API: Django REST Framework
  • CORS: Django CORS Headers
  • Authentication: JWT-based

Machine Learning & AI

  • NLP: NLTK 3.9.1
  • Text Processing: TF-IDF Vectorization
  • Web Scraping: BeautifulSoup4
  • Model Storage: Pickle files
  • Search: Semantic similarity matching

๐Ÿ“ฑ Project Structure

LawAI-PrivacyV/
โ”œโ”€โ”€ ๐Ÿ“ฑ App/                    # React Native Mobile Application
โ”‚   โ”œโ”€โ”€ components/            # Reusable UI components
โ”‚   โ”œโ”€โ”€ pages/                # Screen components
โ”‚   โ”œโ”€โ”€ assets/               # Images, icons, documents
โ”‚   โ”œโ”€โ”€ Json/                 # Legal database JSON files
โ”‚   โ””โ”€โ”€ android/              # Android-specific configurations
โ”‚
โ”œโ”€โ”€ ๐ŸŒ Frontend/              # React.js Web Application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/       # React components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/           # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ styles/          # CSS styles
โ”‚   โ”‚   โ””โ”€โ”€ images/          # Static assets
โ”‚   โ””โ”€โ”€ public/              # Public assets
โ”‚
โ”œโ”€โ”€ โš™๏ธ Backend/               # Django API Server
โ”‚   โ”œโ”€โ”€ home/                # Main application
โ”‚   โ”‚   โ”œโ”€โ”€ models.py        # Database models
โ”‚   โ”‚   โ”œโ”€โ”€ views.py         # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ gemini.py        # AI integration
โ”‚   โ”‚   โ””โ”€โ”€ webscrap.py      # Web scraping utilities
โ”‚   โ”œโ”€โ”€ Project_Backend/     # Django settings
โ”‚   โ”œโ”€โ”€ nltk_data/          # NLP data
โ”‚   โ”œโ”€โ”€ *.pkl               # Trained ML models
โ”‚   โ””โ”€โ”€ requirements.txt    # Python dependencies
โ”‚
โ””โ”€โ”€ ๐Ÿ“„ Documentation/        # Project documentation

๐Ÿ› ๏ธ Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • Python (3.11 or higher)
  • PostgreSQL (v13 or higher)
  • Android Studio (for mobile development)
  • Git

Backend Setup

  1. Clone the repository
git clone https://github.com/yourusername/LawAI-PrivacyV.git
cd LawAI-PrivacyV/Backend
  1. Create virtual environment
python -m venv lawai_env
# Windows
lawai_env\Scripts\activate
# Linux/Mac
source lawai_env/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Environment setup
# Create .env file with your configurations
echo "DEBUG=True" > .env
echo "SECRET_KEY=your_secret_key_here" >> .env
echo "DATABASE_URL=postgresql://user:password@localhost:5432/lawai_db" >> .env
  1. Database migration
python manage.py migrate
python manage.py createsuperuser
  1. Run the server
python manage.py runserver

Frontend Web Setup

  1. Navigate to frontend directory
cd ../Frontend
  1. Install dependencies
npm install
  1. Start development server
npm start

Mobile App Setup

  1. Navigate to app directory
cd ../App
  1. Install dependencies
npm install
  1. Start Metro bundler
npx expo start
  1. Run on device/emulator
# For Android
npx expo run:android

# For iOS
npx expo run:ios

๐ŸŽฏ Core Functionalities

1. Intelligent Legal Query System

# Example API endpoint for legal queries
POST /encode/
{
  "query": "What is the punishment for theft under Indian law?"
}

Response:
{
  "sections": [
    {
      "act": "IPC",
      "section": "378",
      "title": "Theft",
      "description": "Whoever intends to take dishonestly any movable property..."
    }
  ]
}

2. Advanced Search Functionality

// Search by act and query
const searchLegal = async (query, act) => {
  const response = await axios.post('/search/', {
    query: query,
    act: act
  });
  return response.data;
};

3. FIR Document Generation

  • Template-based FIR creation
  • Auto-population from incident details
  • PDF export functionality
  • Digital signature support

4. Multi-language Support

  • Dynamic language switching
  • Localized UI components
  • Regional law translations
  • Voice input in multiple languages

๐Ÿค– Machine Learning Models

TF-IDF Vectorization Model

  • Purpose: Document similarity and relevance scoring
  • Training Data: Legal documents corpus
  • Features: Tokenization, stopword removal, lemmatization
  • Performance: 85% accuracy in legal document retrieval

Neural Network Model (NNM.pkl)

  • Architecture: Multi-layer perceptron
  • Input: Preprocessed legal text vectors
  • Output: Legal category classification
  • Training: 10,000+ legal documents

Natural Language Processing Pipeline

# Text preprocessing pipeline
def preprocess_legal_text(text):
    tokens = word_tokenize(text.lower())
    filtered_tokens = [word for word in tokens if word not in stopwords]
    lemmatized = [lemmatizer.lemmatize(word) for word in filtered_tokens]
    return ' '.join(lemmatized)

๐Ÿ“Š Database Schema

Core Models

class BNS(models.Model):
    section_id = models.CharField(max_length=10)
    section_title = models.TextField()
    description = models.TextField()
    act_type = models.CharField(default='BNS')

class Query(models.Model):
    query_text = models.TextField()
    response = models.JSONField()
    timestamp = models.DateTimeField(auto_now_add=True)
    user_session = models.CharField(max_length=100)

๐Ÿ”— API Documentation

Legal Search Endpoint

POST /search/
Content-Type: application/json

{
  "query": "string",
  "act": "string" // Options: bns, ipc, crpc, iea, cpc, mva
}

Database Retrieval

GET /database/
Content-Type: application/json

Response: {
  "data": [
    {
      "id": 1,
      "section_id": "378",
      "section_title": "Theft",
      "description": "Legal definition and punishment...",
      "act_type": "IPC"
    }
  ]
}

PDF Management

GET /pdfs/
POST /generate-pdf/

๐ŸŽจ UI/UX Features

Modern Design Elements

  • Dark/Light Theme: System preference detection
  • Responsive Layout: Mobile-first design approach
  • Accessibility: WCAG 2.1 compliance
  • Progressive Web App: Offline functionality
  • Smooth Animations: Framer Motion integration

Mobile-Specific Features

  • Gesture Navigation: Swipe-based interactions
  • Voice Commands: Hands-free operation
  • Offline Mode: Cached legal documents
  • Push Notifications: Case updates and reminders

๐ŸŒ Deployment

Backend Deployment (Vercel)

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

Frontend Deployment

# Build for production
npm run build

# Deploy to hosting service
# (Netlify, Vercel, AWS S3, etc.)

Mobile App Deployment

# Android
eas build --platform android

# iOS
eas build --platform ios

๐Ÿงช Testing

Backend Testing

python manage.py test

Frontend Testing

npm test

Mobile Testing

npx expo test

๐Ÿ“ˆ Performance Metrics

  • Query Response Time: < 500ms average
  • Database Search: < 200ms for 10,000+ records
  • Mobile App Size: < 50MB
  • Web App Load Time: < 3 seconds
  • Offline Functionality: 90% features available

๐Ÿ” Security Features

  • Data Encryption: AES-256 for sensitive data
  • API Authentication: JWT-based security
  • Input Validation: SQL injection prevention
  • CORS Configuration: Secure cross-origin requests
  • Rate Limiting: API abuse prevention

๐Ÿค Contributing

We welcome contributions from the community! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use ESLint for JavaScript code
  • Write unit tests for new features
  • Update documentation for API changes

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ฅ Team

Smart India Hackathon 2024 Team

๐Ÿ† Acknowledgments

  • Smart India Hackathon 2024 for the opportunity
  • Ministry of Electronics and Information Technology for support
  • Legal experts for domain knowledge validation
  • Open source community for amazing tools and libraries

๐Ÿ”ฎ Future Roadmap

Phase 1 (Current)

  • โœ… Core legal database integration
  • โœ… Basic AI query processing
  • โœ… Mobile and web applications
  • โœ… FIR generation system

Phase 2 (Upcoming)

  • ๐Ÿ”„ Advanced ML models integration
  • ๐Ÿ”„ Real-time case tracking
  • ๐Ÿ”„ Integration with court systems
  • ๐Ÿ”„ Blockchain for document verification

Phase 3 (Future)

  • ๐Ÿ“‹ Predictive legal analytics
  • ๐Ÿ“‹ Multi-jurisdictional support
  • ๐Ÿ“‹ Advanced AI legal reasoning
  • ๐Ÿ“‹ IoT integration for evidence collection

Made with โค๏ธ for Indian Law Enforcement

Transforming Legal Technology โ€ข Empowering Justice โ€ข Building Tomorrow

โญ Star this repo โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ก Request Feature

About

๐Ÿ›๏ธ AI-powered legal intelligence platform for law enforcement - SIH 2024 ML/non-LLM version

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors