Skip to content

Anish-2005/LawAI-SIH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LawAI-SIH ๐Ÿ›๏ธโš–๏ธ

Smart India Hackathon 2024 - Legal AI Solution

A comprehensive AI-powered legal assistance platform that leverages Natural Language Processing (NLP) and Machine Learning to help law enforcement personnel identify applicable laws and regulations for FIR cases. The system provides intelligent case analysis, legal database integration, and real-time case monitoring capabilities.

๐ŸŒŸ Overview

LawAI-SIH is an innovative web application designed to bridge the gap between incident reporting and legal framework application. It utilizes Google's Gemini AI model to analyze FIR details and automatically identify relevant legal provisions, making the legal process more efficient and accessible for law enforcement agencies.

๐Ÿ—๏ธ Architecture

Frontend Architecture

Frontend/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ Footer.js
โ”‚   โ”‚   โ”œโ”€โ”€ KeyFeatures.js
โ”‚   โ”‚   โ”œโ”€โ”€ MenuBar.js
โ”‚   โ”‚   โ””โ”€โ”€ Sidebar.js
โ”‚   โ”œโ”€โ”€ pages/              # Application pages
โ”‚   โ”‚   โ”œโ”€โ”€ Landing.js      # Landing page
โ”‚   โ”‚   โ”œโ”€โ”€ Query.js        # AI Query interface
โ”‚   โ”‚   โ”œโ”€โ”€ Database.js     # Case database
โ”‚   โ”‚   โ”œโ”€โ”€ BareActs.js     # Legal acts repository
โ”‚   โ”‚   โ”œโ”€โ”€ Download.js     # Document downloads
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ styles/             # CSS modules
โ”‚   โ”œโ”€โ”€ images/             # Static assets
โ”‚   โ””โ”€โ”€ contexts/           # React Context providers

Backend Architecture

Backend/
โ”œโ”€โ”€ index.js               # Main server entry point
โ”œโ”€โ”€ gemini.js             # Google Gemini AI integration
โ”œโ”€โ”€ server.js             # MongoDB operations
โ”œโ”€โ”€ laws.js               # Legal database routes
โ”œโ”€โ”€ laws.json             # Legal acts data
โ””โ”€โ”€ vercel.json           # Deployment configuration

๐Ÿš€ Key Features

๐Ÿค– AI-Powered Legal Analysis

  • Gemini AI Integration: Utilizes Google's Gemini 1.5 Flash model for intelligent FIR analysis
  • Natural Language Processing: Interprets incident details and maps them to relevant legal provisions
  • Contextual Understanding: Provides detailed explanations of applicable laws and sections

๐Ÿ“Š Comprehensive Database Management

  • MongoDB Integration: Robust NoSQL database for case management
  • Real-time Data: Live updates and case tracking capabilities
  • Search Functionality: Advanced search by act, section, keyword, or case details

๐ŸŽจ Modern User Interface

  • Responsive Design: Mobile-first approach with Tailwind CSS
  • Dark/Light Mode: Customizable theme support
  • Accessibility: WCAG compliant design with screen reader support
  • Progressive Web App: PWA capabilities for mobile installation

๐Ÿ”Š Voice Integration

  • Speech Recognition: Voice-to-text input for FIR details
  • Multilingual Support: Support for multiple Indian languages
  • Hands-free Operation: Voice commands for better accessibility

๐Ÿ“„ Document Management

  • PDF Generation: Automated FIR and case report generation using jsPDF
  • Download Center: Centralized document download hub
  • Template System: Standardized legal document templates

๐Ÿ› ๏ธ Technology Stack

Frontend Technologies

Technology Version Purpose
React 18.3.1 Frontend framework
React Router DOM 6.26.1 Client-side routing
Tailwind CSS 3.4.10 Utility-first CSS framework
Framer Motion 11.5.6 Animation library
Axios 1.7.7 HTTP client
React Icons 5.3.0 Icon library
jsPDF 2.5.2 PDF generation
Recharts 2.12.7 Data visualization
PowerBI Client 2.23.1 Business intelligence integration

Backend Technologies

Technology Version Purpose
Node.js Latest Runtime environment
Express.js 4.21.0 Web framework
MongoDB 6.9.0 NoSQL database
Google Generative AI 0.20.0 AI/ML integration
CORS 2.8.5 Cross-origin resource sharing
dotenv 16.4.5 Environment variable management

DevOps & Deployment

  • Vercel: Frontend deployment platform
  • MongoDB Atlas: Cloud database hosting
  • Environment Variables: Secure configuration management
  • Git: Version control system

๐Ÿ“‹ Prerequisites

Before running this application, ensure you have the following installed:

  • Node.js (v16.0.0 or higher)
  • npm or yarn package manager
  • MongoDB (local installation or MongoDB Atlas account)
  • Google Gemini API Key
  • Git for version control

โš™๏ธ Installation & Setup

1. Clone the Repository

git clone https://github.com/yourusername/LawAI-SIH.git
cd LawAI-SIH

2. Backend Setup

cd Backend
npm install

Create a .env file in the Backend directory:

api_key=your_google_gemini_api_key
mongouri=your_mongodb_connection_string
PORT=5000

3. Frontend Setup

cd ../Frontend
npm install

4. Start the Development Servers

Backend Server:

cd Backend
npm start
# Server runs on http://localhost:5000

Frontend Server:

cd Frontend
npm start
# Application runs on http://localhost:3000

๐Ÿ”ง Configuration

Environment Variables

Backend (.env)

# Google Gemini AI Configuration
api_key=your_google_gemini_api_key

# MongoDB Configuration
mongouri=mongodb+srv://username:password@cluster.mongodb.net/FIR

# Server Configuration
PORT=5000
NODE_ENV=development

Frontend Environment Variables (Optional)

Create .env in Frontend directory for any client-side configurations:

REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_ENV=development

๐Ÿ“ฑ Usage Guide

1. Landing Page

  • Navigate to the application homepage
  • Explore key features and system overview
  • Access navigation menu for different modules

2. Query Module

  • Enter FIR details in natural language
  • Use voice input for hands-free operation
  • Receive AI-generated legal analysis
  • View applicable laws and sections

3. Database Module

  • Browse existing cases and FIRs
  • Search by various criteria
  • Monitor case status and updates
  • Generate reports and analytics

4. Legal Acts Repository

  • Access comprehensive legal database
  • Search by act name, section, or keywords
  • Download legal documents
  • View categorized legal provisions

๐Ÿ”Œ API Endpoints

Gemini AI Routes

POST /api/gemini/generate
- Body: { "query": "FIR details or legal question" }
- Response: AI-generated legal analysis

MongoDB Routes

GET /api/server/cases
- Response: List of all cases from database

GET /api/server/
- Response: API welcome message

Legal Database Routes

GET /api/laws/
- Response: Available legal acts and sections

POST /api/laws/search
- Body: Search parameters
- Response: Filtered legal provisions

๐Ÿ—๏ธ Project Structure

LawAI-SIH/
โ”‚
โ”œโ”€โ”€ README.md                 # Project documentation
โ”‚
โ”œโ”€โ”€ Frontend/                 # React frontend application
โ”‚   โ”œโ”€โ”€ public/              # Static assets
โ”‚   โ”‚   โ”œโ”€โ”€ index.html       # HTML template
โ”‚   โ”‚   โ”œโ”€โ”€ favicon.ico      # Application favicon
โ”‚   โ”‚   โ””โ”€โ”€ manifest.json    # PWA manifest
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ src/                 # Source code
โ”‚   โ”‚   โ”œโ”€โ”€ components/      # Reusable components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Footer.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ KeyFeatures.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MenuBar.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Sidebar.js
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ pages/           # Application pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Landing.js   # Home page
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Query.js     # AI query interface
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Database.js  # Case database
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BareActs.js  # Legal repository
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ styles/          # CSS modules
โ”‚   โ”‚   โ”œโ”€โ”€ images/          # Image assets
โ”‚   โ”‚   โ”œโ”€โ”€ App.js           # Main application component
โ”‚   โ”‚   โ””โ”€โ”€ index.js         # Application entry point
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ package.json         # Dependencies and scripts
โ”‚   โ””โ”€โ”€ tailwind.config.js   # Tailwind configuration
โ”‚
โ”œโ”€โ”€ Backend/                 # Node.js backend server
โ”‚   โ”œโ”€โ”€ index.js            # Server entry point
โ”‚   โ”œโ”€โ”€ gemini.js           # Gemini AI integration
โ”‚   โ”œโ”€โ”€ server.js           # MongoDB operations
โ”‚   โ”œโ”€โ”€ laws.js             # Legal database routes
โ”‚   โ”œโ”€โ”€ laws.json           # Legal acts data
โ”‚   โ”œโ”€โ”€ package.json        # Backend dependencies
โ”‚   โ””โ”€โ”€ vercel.json         # Deployment configuration
โ”‚
โ””โ”€โ”€ .gitignore              # Git ignore rules

๐Ÿš€ Deployment

Frontend Deployment (Vercel/Netlify)

cd Frontend
npm run build
# Deploy the 'build' folder to your hosting platform

Backend Deployment (Vercel)

cd Backend
# Configure vercel.json (already included)
vercel --prod

Environment Setup for Production

  • Set up MongoDB Atlas cluster
  • Configure Google Cloud Console for Gemini API
  • Set environment variables in hosting platform
  • Update CORS settings for production domains

๐Ÿ”’ Security Features

  • API Key Protection: Environment variables for sensitive data
  • CORS Configuration: Controlled cross-origin access
  • Input Validation: Sanitized user inputs
  • Secure Headers: HTTP security headers implementation
  • Rate Limiting: API request throttling (recommended for production)

๐Ÿงช Testing

Frontend Testing

cd Frontend
npm test                    # Run unit tests
npm run test:coverage      # Generate coverage report

Backend Testing

cd Backend
npm test                   # Run API tests

๐Ÿค Contributing

  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 React best practices and hooks patterns
  • Use Tailwind CSS for styling consistency
  • Implement proper error handling
  • Add comprehensive comments for complex logic
  • Ensure mobile responsiveness
  • Test across different browsers

๐Ÿ› Troubleshooting

Common Issues

1. MongoDB Connection Error

Error: MongoDB URI is not defined
Solution: Check your .env file and MongoDB connection string

2. Gemini API Error

Error: Failed to generate response
Solution: Verify your Google Gemini API key and quota

3. CORS Error

Solution: Ensure backend CORS is configured for your frontend domain

4. Build Errors

Solution: Delete node_modules and package-lock.json, then run npm install

๐Ÿ“Š Performance Optimization

  • Code Splitting: Lazy loading for route components
  • Image Optimization: Compressed and responsive images
  • Caching Strategy: Browser and server-side caching
  • Bundle Analysis: Webpack bundle analyzer integration
  • CDN Integration: Static asset delivery optimization

๐Ÿ”ฎ Future Roadmap

  • Multi-language support for regional languages
  • Machine learning model training for case predictions
  • Integration with government legal databases
  • Real-time collaboration features
  • Advanced analytics and reporting
  • Mobile application development
  • Blockchain integration for case integrity
  • AI-powered legal document drafting

๐Ÿ“„ License

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

๐Ÿ‘ฅ Team

Smart India Hackathon 2024 Team

  • Team Lead: [Your Name]
  • Frontend Developer: [Team Member]
  • Backend Developer: [Team Member]
  • AI/ML Engineer: [Team Member]
  • UI/UX Designer: [Team Member]

๐Ÿ™ Acknowledgments

  • Google Gemini AI for providing advanced AI capabilities
  • MongoDB for robust database solutions
  • Smart India Hackathon for the platform and opportunity
  • Government of India for supporting innovation in legal technology
  • Open Source Community for the amazing tools and libraries

๐Ÿ“ž Support

For support, email your-email@domain.com or create an issue in the repository.

๐Ÿ”— Links


Made with โค๏ธ for Smart India Hackathon 2024

Empowering Legal Professionals with AI Technology

About

๐Ÿ›๏ธ AI-powered legal assistance platform for Smart India Hackathon 2024. Analyzes FIR cases using Google Gemini AI to identify applicable laws and regulations. Built with React, Node.js, MongoDB, and Tailwind CSS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors