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.
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.
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/
โโโ 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
- 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
- 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
- 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
- Speech Recognition: Voice-to-text input for FIR details
- Multilingual Support: Support for multiple Indian languages
- Hands-free Operation: Voice commands for better accessibility
- PDF Generation: Automated FIR and case report generation using jsPDF
- Download Center: Centralized document download hub
- Template System: Standardized legal document templates
| 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 |
| 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 |
- Vercel: Frontend deployment platform
- MongoDB Atlas: Cloud database hosting
- Environment Variables: Secure configuration management
- Git: Version control system
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
git clone https://github.com/yourusername/LawAI-SIH.git
cd LawAI-SIHcd Backend
npm installCreate a .env file in the Backend directory:
api_key=your_google_gemini_api_key
mongouri=your_mongodb_connection_string
PORT=5000cd ../Frontend
npm installBackend Server:
cd Backend
npm start
# Server runs on http://localhost:5000Frontend Server:
cd Frontend
npm start
# Application runs on http://localhost:3000# 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=developmentCreate .env in Frontend directory for any client-side configurations:
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_ENV=development- Navigate to the application homepage
- Explore key features and system overview
- Access navigation menu for different modules
- Enter FIR details in natural language
- Use voice input for hands-free operation
- Receive AI-generated legal analysis
- View applicable laws and sections
- Browse existing cases and FIRs
- Search by various criteria
- Monitor case status and updates
- Generate reports and analytics
- Access comprehensive legal database
- Search by act name, section, or keywords
- Download legal documents
- View categorized legal provisions
POST /api/gemini/generate
- Body: { "query": "FIR details or legal question" }
- Response: AI-generated legal analysis
GET /api/server/cases
- Response: List of all cases from database
GET /api/server/
- Response: API welcome message
GET /api/laws/
- Response: Available legal acts and sections
POST /api/laws/search
- Body: Search parameters
- Response: Filtered legal provisions
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
cd Frontend
npm run build
# Deploy the 'build' folder to your hosting platformcd Backend
# Configure vercel.json (already included)
vercel --prod- Set up MongoDB Atlas cluster
- Configure Google Cloud Console for Gemini API
- Set environment variables in hosting platform
- Update CORS settings for production domains
- 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)
cd Frontend
npm test # Run unit tests
npm run test:coverage # Generate coverage reportcd Backend
npm test # Run API tests- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- 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
1. MongoDB Connection Error
Error: MongoDB URI is not defined
Solution: Check your .env file and MongoDB connection string2. Gemini API Error
Error: Failed to generate response
Solution: Verify your Google Gemini API key and quota3. CORS Error
Solution: Ensure backend CORS is configured for your frontend domain4. Build Errors
Solution: Delete node_modules and package-lock.json, then run npm install- 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
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
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]
- 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
For support, email your-email@domain.com or create an issue in the repository.
- Live Demo: https://your-app-url.vercel.app
- API Documentation: API Docs
- Design System: Figma Design
- Project Repository: GitHub
Made with โค๏ธ for Smart India Hackathon 2024
Empowering Legal Professionals with AI Technology