LexiGuard is an advanced AI-powered legal document analysis platform that provides comprehensive legal document analysis, compliance checking, risk assessment, and fairness benchmarking. Built with cutting-edge technology to help individuals and businesses make informed legal decisions.
- Multi-Format Support: Upload PDF, Word documents (.doc, .docx), text files (.txt), PowerPoint (.pptx), Excel (.xlsx), and images with text
- Advanced Text Extraction: Intelligent content extraction from various document formats
- File Validation: Comprehensive file validation including size limits (10MB), type checking, and content verification
- Secure Cloud Storage: Documents stored securely on Cloudinary with automatic cleanup
- Real-time Processing: Instant document analysis with progress tracking
- Google Gemini AI Integration: Leverages advanced large language models for comprehensive analysis
- Multi-Role Analysis: Tailored analysis based on user role (Tenant, Landlord, Employee, Client, Consumer, etc.)
- Document Type Detection: Automatically identifies contract types and relevant legal frameworks
- Key Clause Extraction: Identifies critical legal clauses, terms, and conditions
- Risk Assessment: Comprehensive risk evaluation with color-coded risk levels (Low, Medium, High)
- Compliance Checking: Automated compliance verification against regulatory requirements
- Issue Detection: Identifies potential legal problems and areas of concern
- Comparative Analysis: Compare contract terms against thousands of similar agreements
- Jurisdiction-Specific Benchmarks: Analysis tailored to specific regions (India, Maharashtra, Karnataka, Delhi, etc.)
- Market Position Assessment: Understand if your terms are above average, average, below average, or concerning
- Fairness Scoring: Get quantitative fairness scores (0-100) for your contracts
- Negotiation Opportunities: Receive specific recommendations for contract improvements
- Market Insights: Access to real-time market trends and industry standards
- Document-Aware Conversations: Chat about specific documents with full context awareness
- What-If Scenario Analysis: Explore hypothetical situations and their legal implications
- Multi-Modal Communication: Support for text, file uploads, and rich formatting
- Quick Actions: One-click access to common analysis tasks
- Contextual Responses: AI responses formatted with risk indicators and actionable insights
- Real-time Analysis: Live document processing during conversations
- Comprehensive Dashboard: Overview of document analytics, team activity, and key metrics
- Document Management: Centralized document library with search and filtering
- Activity Tracking: Monitor recent activities, pending reviews, and upcoming deadlines
- Risk Analytics: Visual representation of risk distribution across documents
- Team Collaboration: Multi-user support with role-based access control
- Firebase Authentication: Secure user authentication with email/password and social logins
- User Access Control: Role-based permissions and document ownership verification
- Secure File Handling: End-to-end encryption for file uploads and storage
- CORS Protection: Comprehensive CORS configuration for secure API access
- Input Sanitization: Protection against malicious content and injection attacks
- React 18 - Modern component-based UI framework
- Vite - Fast build tool and development server
- Tailwind CSS - Utility-first CSS framework for responsive design
- Framer Motion - Advanced animations and micro-interactions
- Firebase SDK - Authentication, Firestore database, and real-time features
- Lucide React - Modern icon library
- React Markdown - Rich text formatting for AI responses
- React Router - Client-side routing and navigation
- Node.js & Express - Server runtime and web framework
- Multer - Multipart file upload handling
- Cloudinary - Cloud-based file storage and media management
- PDF-Parse - PDF text extraction
- Mammoth - Word document (.docx) text extraction
- Google Gemini AI - Advanced language model for document analysis
- Firebase Admin SDK - Server-side user verification and database operations
- CORS - Cross-origin resource sharing configuration
- Firebase Firestore - NoSQL document database for user data and metadata
- Cloudinary - Secure cloud storage for document files
- Firebase Authentication - User authentication and session management
- Google Gemini Pro - Large language model for document analysis
- Custom Fairness Benchmark Engine - Proprietary algorithm for market comparison
- Risk Assessment Models - AI-powered risk evaluation systems
- What-If Simulation Engine - Scenario analysis and prediction
Before running LexiGuard, ensure you have:
- Node.js (v16.0.0 or higher) - Download here
- npm or yarn package manager
- Git for version control
- Cloudinary Account - Sign up here
- Firebase Project - Create project here
- Google AI Studio API Key - Get API key here
- RAM: Minimum 4GB, recommended 8GB+
- Storage: At least 1GB free space
- OS: Windows 10+, macOS 10.14+, or Ubuntu 18.04+
- Browser: Chrome 90+, Firefox 88+, Safari 14+, or Edge 90+
git clone https://github.com/Soham156/LexiGuard.git
cd LexiGuardcd server
npm install
# Create environment file
cp .env.example .envConfigure your .env file with the following variables:
# Server Configuration
PORT=8080
NODE_ENV=development
# Cloudinary Configuration (Required)
CLOUDINARY_CLOUD_NAME=your_cloud_name_here
CLOUDINARY_API_KEY=your_api_key_here
CLOUDINARY_API_SECRET=your_api_secret_here
# Google Gemini AI Configuration (Required)
GEMINI_API_KEY=your_gemini_api_key_here
# CORS Configuration
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000,https://yourdomainhere.com
# Firebase Admin SDK (Optional - for advanced features)
FIREBASE_ADMIN_PRIVATE_KEY=your_firebase_private_key
FIREBASE_ADMIN_CLIENT_EMAIL=your_firebase_client_email
FIREBASE_ADMIN_PROJECT_ID=your_firebase_project_idcd ../client
npm install
# Create environment file
cp .env.example .env.localConfigure your .env.local file:
# API Configuration
VITE_API_BASE_URL=http://localhost:8080/api
VITE_APP_NAME=LexiGuard
# Firebase Configuration (Required)
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=123456789
VITE_FIREBASE_APP_ID=1:123456789:web:abcdef123456
# Additional Configuration
VITE_ENVIRONMENT=development
VITE_ENABLE_ANALYTICS=false- Sign up at Cloudinary
- Navigate to your Dashboard
- Copy your Cloud Name, API Key, and API Secret
- Configure automatic folder creation and media transformations
- Set up upload presets for different file types
- Visit Google AI Studio
- Create a new project or select existing one
- Enable the Gemini API
- Generate an API key with appropriate permissions
- Set up usage quotas and billing (if required)
- Go to Firebase Console
- Create a new project or select existing one
- Enable the following services:
- Authentication (Email/Password, Google, GitHub)
- Firestore Database (in production mode)
- Storage (for additional file handling)
- Create a web app and copy the configuration
- Set up security rules for Firestore:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /documents/{document} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.userId;
}
match /document_shares/{share} {
allow read: if request.auth != null &&
(request.auth.uid == resource.data.ownerUserId ||
request.auth.token.email == resource.data.sharedWithEmail);
allow write: if request.auth != null && request.auth.uid == resource.data.ownerUserId;
}
}
}cd server
npm start
# or for development with auto-reload
npm run devServer will run on http://localhost:8080
cd client
npm run devFrontend will run on http://localhost:5173
cd client
npm run buildcd server
vercel --prodcd client
npm run build
# Upload dist/ folder to your hosting providerLexiGuard/
βββ client/ # React frontend application
β βββ public/ # Static assets
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ ui/ # Base UI components (Button, etc.)
β β β βββ dashboard/ # Dashboard-specific components
β β β βββ Header.jsx # Main navigation header
β β β βββ Footer.jsx # Application footer
β β βββ pages/ # Route components
β β β βββ Dashboard.jsx # Main dashboard page
β β β βββ BenchmarkPage.jsx # Fairness benchmark analysis
β β β βββ ChatPage.jsx # AI chat interface
β β β βββ DocumentsPage.jsx # Document management
β β β βββ SettingsPage.jsx # User settings
β β β βββ LandingPage.jsx # Marketing/landing page
β β β βββ SignIn.jsx # Authentication
β β β βββ SignUp.jsx # User registration
β β βββ services/ # API and external service integrations
β β β βββ api.js # Base API configuration
β β β βββ documentService.js # Document CRUD operations
β β β βββ benchmarkService.js # Fairness benchmarking
β β βββ context/ # React context providers
β β β βββ AuthContext.jsx # Authentication state
β β β βββ DocumentContext.jsx # Document state management
β β β βββ ThemeContext.jsx # UI theme management
β β βββ firebase/ # Firebase configuration
β β β βββ firebase.js # Firebase initialization
β β β βββ auth.js # Authentication helpers
β β βββ layouts/ # Page layout components
β β β βββ DashboardLayout.jsx # Dashboard wrapper
β β β βββ Sidebar.jsx # Navigation sidebar
β β βββ utils/ # Utility functions
β β βββ errorHandler.js # Error handling utilities
β βββ tailwind.config.cjs # Tailwind CSS configuration
β βββ vite.config.js # Vite build configuration
β βββ package.json # Frontend dependencies
βββ server/ # Node.js backend application
β βββ routes/ # API endpoint definitions
β β βββ documentRoutes.js # Document upload/analysis endpoints
β β βββ chatRoutes.js # AI chat endpoints
β β βββ benchmarkRoutes.js # Fairness benchmark endpoints
β β βββ chat.js # Legacy chat routes
β βββ services/ # Business logic services
β β βββ documentAnalysisService.js # Core document analysis
β β βββ fairnessBenchmarkService.js # Market benchmarking
β β βββ geminiService.js # Google Gemini AI integration
β β βββ whatIfSimulatorService.js # Scenario simulation
β βββ config/ # Configuration files
β β βββ cloudinary.js # Cloudinary setup
β βββ middleware/ # Express middleware
β βββ utils/ # Utility functions
β β βββ textExtractor.js # Text extraction from files
β βββ temp/ # Temporary file storage
β βββ vercel.json # Vercel deployment configuration
β βββ server.js # Express server entry point
β βββ package.json # Backend dependencies
βββ README.md # Project documentation
βββ .gitignore # Git ignore rules
- Multi-Layer File Validation: File type, size, and content validation
- Secure File Upload: Virus scanning and malicious content detection
- User Authentication: Firebase-based secure authentication with session management
- Document Ownership Verification: Users can only access their own documents
- API Rate Limiting: Protection against abuse and denial-of-service attacks
- CORS Protection: Configured cross-origin resource sharing
- Input Sanitization: Protection against injection attacks and malicious content
- Secure Cloud Storage: Encrypted file storage with access controls
- Privacy Compliance: GDPR and data protection compliance measures
-
PDF Documents (.pdf) - Up to 10MB
- Text-based PDFs with OCR support
- Multi-page document processing
- Metadata extraction and analysis
-
Microsoft Word (.docx, .doc) - Up to 10MB
- Rich text formatting preservation
- Table and image content extraction
- Comment and revision tracking
-
Text Files (.txt) - Up to 10MB
- Plain text with encoding detection
- Large file chunking support
- Character encoding validation
-
PowerPoint (.pptx, .ppt) - Up to 10MB (Chat interface only)
- Slide content extraction
- Speaker notes analysis
- Embedded object handling
-
Excel Spreadsheets (.xlsx, .xls) - Up to 10MB (Chat interface only)
- Multi-sheet processing
- Formula and data analysis
- Chart and graph interpretation
-
Images with Text (.jpg, .png) - Up to 10MB (Chat interface only)
- OCR text extraction
- Document image processing
- Handwriting recognition
- Batch Processing: Multiple documents simultaneously
- Incremental Analysis: Progressive document processing
- Error Recovery: Robust handling of corrupted or partial files
- Format Detection: Automatic file type identification
- Content Validation: Verification of document integrity
- Automated Document Classification: Identifies contract types, legal documents, and business agreements
- Entity Recognition: Extracts parties, dates, amounts, and key terms
- Clause Categorization: Organizes content by legal significance and type
- Cross-Reference Analysis: Identifies related clauses and dependencies
- Terminology Extraction: Legal and technical term identification
- Multi-Dimensional Risk Scoring: Financial, legal, operational, and compliance risks
- Severity Classification: Risk levels from negligible to critical
- Impact Analysis: Potential consequences and likelihood assessment
- Mitigation Recommendations: Specific actions to reduce identified risks
- Historical Risk Patterns: Learning from past document analyses
- Regulatory Framework Mapping: Automatic identification of applicable laws
- Jurisdiction-Specific Analysis: Regional legal requirement checking
- Industry Standard Compliance: Sector-specific regulation verification
- Missing Clause Detection: Identification of required but absent provisions
- Version Control: Tracking changes and compliance status over time
- Market Data Integration: Comparison against industry standards
- Peer Analysis: Similar contract term comparison
- Negotiation Power Assessment: Evaluation of term favorability
- Alternative Clause Suggestions: Recommendations for fairer terms
- Market Position Scoring: Quantitative fairness measurement
POST /api/document/upload-and-analyze- Upload and analyze new documentsPOST /api/document/reanalyze- Re-analyze existing documents with updated modelsDELETE /api/document/delete- Secure document deletion with Cloudinary cleanupGET /api/document/signed-url- Generate temporary access URLsPOST /api/document/analyze-base64- Legacy Base64 document analysis
POST /api/chat/message- Send messages to AI assistantPOST /api/chat/message-with-document- Context-aware document chatGET /api/chat/documents/:userId- Retrieve user documents for chat contextGET /api/chat/what-if-examples- Get scenario analysis examples
POST /api/benchmark/analyze-fairness- Comprehensive fairness analysisPOST /api/benchmark/upload-and-analyze- Upload with immediate benchmarkingGET /api/benchmark/market-data- Access market comparison dataPOST /api/benchmark/compare-terms- Specific term comparison
- Firebase Authentication integration
- Session management and token validation
- User profile and preference management
- Access control and permission verification
- Create Account: Sign up with email/password or social login
- Choose Your Role: Select your primary role (Tenant, Employee, Consumer, etc.)
- Upload First Document: Drag and drop or browse to select a file
- Review Analysis: Examine AI-generated insights and recommendations
- Explore Features: Try chat, benchmarking, and dashboard features
-
Upload Document
- Select file (PDF, Word, or text)
- Choose your role in the document relationship
- Specify jurisdiction if relevant
- Wait for automatic processing
-
Review Analysis Results
- Risk Assessment: Review color-coded risk levels
- Key Clauses: Examine extracted important terms
- Compliance Check: Verify regulatory compliance
- Recommendations: Follow suggested improvements
-
Use Advanced Features
- Chat with Document: Ask specific questions about the content
- Fairness Benchmark: Compare terms against market standards
- What-If Analysis: Explore hypothetical scenarios
- Export Results: Download comprehensive reports
- Select Document Context: Choose a document for context-aware chat
- Ask Questions: Use natural language to inquire about specific clauses
- Scenario Planning: Ask "What if..." questions for predictive analysis
- Get Recommendations: Request specific advice and action items
- Quick Actions: Use predefined analysis shortcuts
- Select Document: Choose from uploaded documents or upload new one
- Configure Analysis: Set your role and jurisdiction
- Run Benchmark: Get comparative analysis against market data
- Review Results:
- Overall fairness score (0-100)
- Market position assessment
- Specific term comparisons
- Negotiation opportunities
- Take Action: Use insights for contract negotiations
- Document Library: Centralized view of all analyzed documents
- Activity Feed: Recent analysis activities and updates
- Analytics Overview: Risk distribution and document insights
- Team Management: Collaborate with team members
- Settings: Customize preferences and notification settings
- Clear Scans: Ensure PDFs are text-searchable, not just images
- Complete Documents: Upload full contracts for comprehensive analysis
- Recent Versions: Use the most current version of your documents
- Multiple Formats: Try different formats if one doesn't work optimally
- Accurate Role Selection: Choose your correct role for tailored analysis
- Specific Jurisdictions: Select precise location for relevant compliance checks
- Detailed Questions: Ask specific, focused questions in chat for better responses
- Regular Re-analysis: Re-analyze documents when laws or markets change
- Regular Password Updates: Change passwords periodically
- Document Cleanup: Delete outdated or unnecessary documents
- Access Control: Review and manage shared document permissions
- Privacy Settings: Configure notification and data sharing preferences
- Error: "File too large"
- Solution: Compress file under 10MB or split into smaller sections
- Error: "Invalid file type"
- Solution: Convert to supported format (PDF, DOCX, TXT)
- Error: "File appears corrupted"
- Solution: Re-save document or try a different source
- Poor Quality Results:
- Ensure document is text-searchable
- Try uploading a cleaner version
- Verify correct role and jurisdiction selection
- Missing Content:
- Check if document contains actual text (not just images)
- Verify all pages are included in the upload
- No Document Context:
- Select a document from the dropdown before asking questions
- Ensure document was successfully analyzed
- Slow Responses:
- Check internet connection
- Try refreshing the page
- Verify server status
- Login Problems:
- Clear browser cache and cookies
- Check email/password combination
- Try password reset if needed
- Session Expired:
- Re-login to refresh session
- Enable "Remember Me" for longer sessions
- Documentation: Check this README for detailed information
- Issue Tracker: Report bugs on GitHub Issues
- Community: Join discussions in GitHub Discussions
- Support: Contact maintainers for critical issues
Explore hypothetical situations and their legal implications:
- Contract Termination Scenarios: Understand consequences of early termination
- Breach of Contract Analysis: Evaluate potential breach situations
- Amendment Impact Assessment: See how proposed changes affect the agreement
- Risk Mitigation Planning: Develop strategies for identified risks
Compare multiple contracts side-by-side:
- Term Variation Analysis: Identify differences in similar contracts
- Best Practice Identification: Find optimal clauses across documents
- Consistency Checking: Ensure uniform terms across related agreements
- Template Development: Create standardized contract templates
Work together on document analysis:
- Shared Workspaces: Collaborate with team members
- Comment and Review: Add notes and feedback on analyses
- Approval Workflows: Set up document approval processes
- Activity Tracking: Monitor team document activities
Tailor analysis to specific needs:
- Industry-Specific Models: Specialized analysis for different sectors
- Regional Legal Frameworks: Jurisdiction-specific compliance checking
- Custom Risk Profiles: Personalized risk assessment criteria
- Template Matching: Compare against organizational standard templates
We welcome contributions from the community! Here's how you can help improve LexiGuard:
- Fork the Repository: Click the "Fork" button on GitHub
- Clone Your Fork:
git clone https://github.com/yourusername/LexiGuard.git - Create a Branch:
git checkout -b feature/amazing-feature - Set Up Development Environment: Follow the installation instructions above
- Frontend: Follow React best practices and ESLint configuration
- Backend: Use Node.js conventions and Express patterns
- Formatting: Use Prettier for consistent code formatting
- Naming: Use descriptive variable and function names
Use conventional commit format:
feat: add fairness benchmarking feature
fix: resolve document upload timeout issue
docs: update API documentation
style: improve responsive design
test: add unit tests for document service
- Frontend: Write Jest tests for components and utilities
- Backend: Create integration tests for API endpoints
- E2E: Add Playwright tests for critical user flows
- Coverage: Aim for 80%+ test coverage on new features
- Use the GitHub issue template
- Include steps to reproduce
- Provide browser/environment details
- Include screenshots or logs when applicable
- Check existing issues for duplicates
- Clearly describe the proposed feature
- Explain the use case and benefits
- Consider implementation complexity
- Improve code comments
- Update README sections
- Add API documentation
- Create user guides and tutorials
- Frontend Improvements: UI/UX enhancements, new components
- Backend Features: New API endpoints, service improvements
- AI/ML Enhancements: Better analysis algorithms, new models
- Performance Optimization: Speed improvements, caching strategies
- Update Documentation: Ensure README and code comments are current
- Add Tests: Include appropriate test coverage
- Check Build: Verify all tests pass and build succeeds
- Update Changelog: Add entry for your changes
- Request Review: Tag maintainers for code review
- Mobile responsiveness improvements
- Performance optimization
- Additional file format support
- Enhanced AI analysis capabilities
- Advanced dashboard analytics
- Real-time collaboration features
- API rate limiting enhancements
- Internationalization (i18n)
- Machine learning model improvements
- Blockchain integration for document integrity
- Advanced workflow automation
- Enterprise features and SSO
This project is licensed under the MIT License - see the LICENSE file for details.
- β Commercial use allowed
- β Modification allowed
- β Distribution allowed
- β Private use allowed
- β Liability and warranty not provided
- Google Gemini AI: Subject to Google's terms of service
- Cloudinary: Subject to Cloudinary's terms of service
- Firebase: Subject to Google Cloud terms of service
- React & Dependencies: Various open-source licenses (MIT, Apache 2.0, etc.)
- Documentation: Check this comprehensive README first
- FAQ: Look for common questions in GitHub Discussions
- Community: Join our GitHub Discussions for peer support
- Issues: Report bugs using GitHub Issues with detailed information
When reporting issues, please include:
- Environment: OS, browser, Node.js version
- Steps to Reproduce: Clear, numbered steps
- Expected Behavior: What should happen
- Actual Behavior: What actually happens
- Screenshots: Visual evidence when applicable
- Console Logs: Any error messages or warnings
For new feature requests:
- Use Case: Explain why this feature is needed
- User Story: Describe from a user's perspective
- Acceptance Criteria: Define what success looks like
- Implementation Ideas: Suggest technical approaches if you have them
For enterprise users requiring dedicated support:
- Priority Support: Faster response times
- Custom Development: Tailored features and integrations
- Training & Onboarding: Team training sessions
- SLA Agreements: Service level guarantees
Contact the maintainers for commercial support inquiries.
- Google Gemini AI - Powering our advanced document analysis capabilities
- Cloudinary - Providing secure and scalable file storage solutions
- Firebase - Authentication, database, and real-time features
- React Community - Excellent ecosystem and component libraries
- Node.js Community - Robust backend frameworks and tools
Special thanks to all contributors who have helped improve LexiGuard:
- Soham156 - Project creator and lead developer
- Community Contributors - Bug reports, feature suggestions, and code contributions
- Legal technology innovations in document analysis
- AI/ML research in natural language processing
- Open-source projects in the legal tech space
- User feedback and real-world use cases
This project builds upon numerous open-source libraries and frameworks. See package.json files for complete dependency lists.
Thanks to legal professionals and compliance experts who provided guidance on:
- Regulatory framework requirements
- Industry best practices
- Risk assessment methodologies
- Document analysis standards
Made with β€οΈ by the LexiGuard Team
Empowering users with AI-driven legal document analysis for better decision-making and risk management.