Skip to content

Prahas2001/AI-Legal-Risk-Analyser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Legal Risk Analyzer

⚖️ Automated legal document auditing powered by AI

License: MIT Flutter AWS Gemini

DemoFeaturesArchitectureQuick StartDocumentation


📖 Overview

A professional, cloud-native platform for instant legal document risk analysis. Upload contracts, NDAs, or agreements and receive structured risk assessments in seconds—no legal expertise required.

Built for:

  • 🧑‍💼 Freelancers reviewing client contracts
  • 🏢 Small business owners vetting vendor agreements
  • ⚖️ Legal professionals conducting first-pass audits

✨ Features

🎯 Core Capabilities

  • Instant Risk Detection – AI identifies hidden liabilities, unfair clauses, and compliance issues
  • Severity Classification – Color-coded ratings (High/Medium/Low) with contextual explanations
  • Multi-Format Support – Process PDFs and images (JPG/PNG) via OCR
  • Cross-Platform – Native mobile app + responsive web dashboard
  • Secure & Private – User-isolated S3 storage with AWS Cognito authentication

🎨 Design System

Built with a professional Heritage Navy (#0F172A) and Brand Amber (#B45309) color palette for authority and action.


🏗️ Architecture

      ┌─────────────┐          ┌──────────────┐
      │   Mobile    │          │     Web      │
      │  (Flutter)  │          │  Dashboard   │
      └──────┬──────┘          └──────┬───────┘
             │                        │
             └───────────┐   ┌────────┘
                         ▼   ▼
┌──────────────────────────────────────────────────────────────┐
│                    AWS Infrastructure                        │
│  ┌─────────┐   ┌─────────┐   ┌─────────┐   ┌──────────────┐  │
│  │ Cognito │   │   S3    │   │ Lambda  │   │ Gemini 2.5   │  │
│  │  Auth   │   │ Storage │   │ Python  │   │ Flash (API)  │  │
│  └─────────┘   └─────────┘   └─────────┘   └──────────────┘  │
└──────────────────────────────────────────────────────────────┘

Tech Stack

Component Technology Purpose
Mobile Flutter (Dart) Cross-platform native app
Web HTML5 + Bootstrap 5 Static dashboard
Backend AWS Lambda (Python 3.12) Serverless compute
AI Google Gemini 2.5 Flash Legal text analysis
Auth AWS Cognito User authentication
Storage Amazon S3 Document storage
Validation Pydantic JSON schema enforcement

🚀 Quick Start

📱 Mobile App (Android)

  1. Download the APK
    Get the latest release: LegalRisk_v1.0.apk

  2. Install
    Follow the installation guide

  3. Launch
    Open the app, sign up, and start analyzing documents

Requirements: Android 5.0+ (API 21), 150MB storage, internet connection

🌐 Web Dashboard

  1. Configure AWS
    Copy web/.env.example and fill in your credentials

  2. Launch Locally

   cd web/
   open index.html
   # Or use a local server:
   python -m http.server 8000
  1. Deploy to S3 (Optional)
   aws s3 sync web/ s3://your-bucket-name --exclude "*.md"

⚙️ Backend Setup

  1. Create Lambda Layer
   cd backend/lambda/
   pip install -t python/ google-generativeai pydantic boto3
   zip -r layer.zip python/
  1. Deploy Function
   zip -r function.zip lambda_function.py models.py prompt.py
   aws lambda update-function-code --function-name RiskAnalyzer --zip-file fileb://function.zip
  1. Set Environment Variables
   aws lambda update-function-configuration \
     --function-name RiskAnalyzer \
     --environment Variables="{GEMINI_API_KEY=your_key,S3_BUCKET_NAME=your_bucket}"

📂 Project Structure

ai-legal-risk-analyzer/
├── app/                    # Flutter mobile application
│   ├── lib/                # Dart source code
│   ├── android/            # Android build config
│   └── README.md           # Mobile setup guide
├── web/                    # Static web dashboard
│   ├── dashboard.html      # Main workspace
│   └── README.md           # Web deployment guide
├── backend/                # AWS Lambda functions
│   ├── lambda/             # Python source code
│   ├── iam-policies/       # Security policies
│   └── README.md           # Backend deployment guide
├── releases/               # Pre-built APK files
│   └── CHANGELOG.md        # Version history
├── docs/                   # Documentation assets
│   ├── architecture.png    # The Handshake Diagram
│   └── screenshots/        # UI gallery
└── README.md               # You are here

📚 Documentation

Document Description
Mobile App Guide Flutter setup, build instructions, ProGuard config
Web Dashboard Guide HTML deployment, AWS SDK integration
Backend Guide Lambda deployment, IAM policies, AI logic
Installation Instructions APK installation steps
Changelog Version history and release notes

🔐 Security

  • Zero-Trust Architecture – Users can only access their own documents
  • IAM Least Privilege – Lambda has minimal S3 permissions
  • Encrypted Transit – All data sent via HTTPS
  • No API Keys in Code – Credentials managed via Cognito temporary tokens
  • Audit Trail – Full CloudWatch Logs for all operations

See Security Documentation for details.


🎯 Key Technical Achievements

Stable AI Output – Pydantic schema validation ensures 100% UI reliability
Mobile Optimization – R8/ProGuard shrinking reduced APK from 120MB → 70MB
User Isolation – S3 bucket policies enforce Cognito-based path restrictions
Design System – Consistent Heritage Navy + Brand Amber branding across platforms
Serverless Scale – Lambda auto-scales from 0 to 1000+ concurrent requests


🐛 Troubleshooting

Common issues and solutions:

Issue Solution
Mobile app won't install Ensure Android 5.0+, enable "Unknown sources"
Web dashboard login fails Check Cognito User Pool ID in web/ config
Lambda timeout errors Increase timeout to 30s in AWS Console
Gemini API quota exceeded Upgrade to paid tier in Google AI Studio

More help: Open an issue


🗺️ Roadmap

v1.1 (Q2 2025)

  • iOS mobile app
  • Multi-page PDF support
  • Document analysis history

v1.2 (Q3 2025)

  • Export reports as PDF
  • Biometric authentication
  • Dark mode UI

See full roadmap


📝 License

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


👤 Author

D Ram Prahasith Sharma
MSc Data Science, DAU

📧 Email: [ramprahasith01@gmail.com]
🔗 LinkedIn: [https://www.linkedin.com/in/ram-prahasith-sharma-87a8662a6/]
🐙 GitHub: Prahas2001


🙏 Acknowledgments

  • Google AI Studio for Gemini API access
  • AWS for cloud infrastructure
  • Flutter Team for the cross-platform framework

⭐ Star this repo if you found it helpful!

Report BugRequest FeatureView Demo


© 2026 D Ram Prahasith Sharma. All rights reserved.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors