Skip to content

An AI tool that transforms complex legal documents into a simple 'nutrition label', highlighting critical risks and data privacy policies. Built with the Portia AI SDK for AgentHacks 2025.

License

Notifications You must be signed in to change notification settings

PulastTiwari/pactguard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PactGuard - An Intelligent Legal Analysis Platform

License: MIT Next.js FastAPI Docker TypeScript Python

AI-powered legal document analysis platform that transforms complex legal text into actionable insights with quantitative risk assessment.

PactGuard helps individuals, small businesses, and legal professionals quickly assess legal documents for potential risks, providing structured analysis with numerical risk scores and actionable recommendations.

Features

Smart Document Analysis - AI-powered legal document risk assessment with detailed explanations
Quantitative Risk Scoring - Numerical risk evaluation (1-10 scale) with categorized findings
Automated Email Reports - Professional analysis reports delivered via Gmail integration
Google Workspace Integration - Seamless OAuth 2.0 integration with Drive and Gmail
Modern Interface - Responsive UI with dark/light themes and professional design
Easy Deployment - One-command Docker setup for quick installation
Secure Secure & Private Private - Environment-based configuration with secure credential management
High Performance - Async FastAPI backend with optimized response times

Quick Start

Option 1: Docker Deployment (Recommended)

  1. Clone the repository

    git clone https://github.com/PulastTiwari/pactguard.git
    cd pactguard
  2. Configure environment

    cp .env.docker.template .env

    Edit .env and add your API keys:

  3. Deploy with Docker

    ./docker-deploy.sh
  4. Access the application

Option 2: Manual Development Setup

Requirements: Node.js 18+, Python 3.11+, API keys

Backend Setup:

cd pactguard-backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.template .env  # Add your API keys
uvicorn main_portia:app --host 127.0.0.1 --port 8001 --reload

Frontend Setup:

npm install
cp .env.local.template .env.local
npm run dev

Table of Contents

Demo & Screenshots

Live Demo

Watch Demo

Screenshot 2025-08-25 at 3 28 31 PM Screenshot 2025-08-25 at 3 28 47 PM

Key Workflows

  1. Document Analysis: Upload or paste legal text for instant AI analysis
  2. Risk Assessment: Get numerical risk scores with detailed explanations
  3. Email Integration: Receive professional reports directly in your inbox
  4. Google Drive: Analyze documents directly from your Drive storage

Project Vision

The Problem

Legal document review is complex, time-intensive, and prone to human oversight. Traditional processes lack systematic risk quantification, creating potential blind spots in contract analysis.

Our Solution

PactGuard bridges the gap between traditional legal workflows and modern AI capabilities, functioning as a force multiplier for legal intelligence rather than a replacement for professional expertise.

Target Users

  • Individuals & SMEs: Preliminary risk assessment for contracts and legal documents
  • Legal Practitioners: Accelerated due diligence and systematic issue flagging
  • Legal Education: Structured analysis frameworks and pedagogical tools

Technical Architecture

PactGuard implements a decoupled, service-oriented architecture optimized for scalability and maintainability.

Frontend Stack

  • Next.js 15.2.4: React-based framework with server-side rendering
  • TypeScript 5.7.3: Type-safe development with compile-time error checking
  • Tailwind CSS: Utility-first styling with custom component library
  • shadcn/ui: Modern component library with accessibility compliance

Backend Stack

  • FastAPI 0.115.6: High-performance async web framework with auto-documentation
  • Python 3.13: Latest runtime with enhanced performance characteristics
  • Portia AI SDK: Primary AI orchestration with Google Gemini LLM integration
  • Uvicorn: ASGI server optimized for async Python applications

AI Integration

The system's intelligence is powered by Portia AI as the central orchestration engine, integrated with Google Gemini for natural language understanding. Key features include:

# Robust SDK loading with fallback support
try:
    from portia_ai import Portia
    from portia_ai.tools import GoogleDriveTools, GmailTools
    REAL_PORTIA_SDK = True
except ImportError:
    from .portia_mock import Portia, GoogleDriveTools, GmailTools
    REAL_PORTIA_SDK = False

async def run_legal_analysis(self, text: str) -> Dict[str, Any]:
    """Execute comprehensive legal document analysis"""
    try:
        plan_run = await self.client.run_agent(
            agent_id="legal-document-analyzer",
            inputs={"document_text": text},
            tools=self.tools
        )
        return self._parse_analysis_results(plan_run)
    except Exception as e:
        logger.error(f"Legal analysis failed: {e}")
        raise AnalysisException(f"Failed to analyze document: {str(e)}")

API Documentation

Core Endpoints

Document Analysis

POST /analyze
Content-Type: application/json

{
  "text": "Your legal document text here"
}

File Analysis

POST /analyze-file
Content-Type: multipart/form-data

file: [document.pdf]

Email Integration

POST /send-email
Content-Type: application/json

{
  "recipient_email": "[email protected]",
  "analysis_text": "Analysis results...",
  "subject": "Legal Document Analysis Report"
}

Google Drive Integration

POST /analyze-drive-file
Content-Type: application/json

{
  "file_id": "google_drive_file_id"
}

For complete API documentation, visit /docs endpoint when running the backend.

🤝 Contributing

We welcome contributions from the community! PactGuard is designed to be community-driven and collaborative.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Guidelines

  • Follow the existing code style (PEP 8 for Python, Prettier for TypeScript)
  • Write clear commit messages
  • Update documentation as needed
  • Test your changes thoroughly

See CONTRIBUTING.md for detailed guidelines.

Roadmap

Short Term (Q2 2025)

  • Enhanced document type support (NDAs, terms of service, etc.)
  • Improved risk scoring algorithms
  • Document comparison features
  • User authentication and personalized dashboards

Medium Term (Q3-Q4 2025)

  • Browser extension for in-situ analysis
  • Public API for third-party integrations
  • Enterprise features (SSO, audit logs, multi-tenancy)
  • Advanced analytics and insights

Long Term (2026+)

  • Multi-model AI orchestration with intelligent routing
  • Legal database integrations (Westlaw, LexisNexis)
  • Regulatory compliance checking
  • Contract generation capabilities

See ROADMAP.md for the complete technical roadmap.

Security & Privacy

  • Environment-based configuration for secure credential management
  • No storage of sensitive legal documents on servers
  • Encrypted data transmission
  • Regular security updates and dependency monitoring

See SECURITY.md for security policies and reporting procedures.

Recognition

AgentHacks 2025 Project

  • Developer: Pulast Singh Tiwari
  • Timeline: 5-day intensive development period
  • Focus: Rapid prototyping with production-ready architecture

License

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

Acknowledgments

  • Portia AI for AI orchestration platform
  • Google AI for Gemini LLM integration
  • AgentHacks 2025 for the development opportunity
  • The open source community for inspiration and tools

Support & Contact


Star this repository if PactGuard helps you with legal document analysis!

Built with love by Pulast Singh Tiwari for the legal tech community.

About

An AI tool that transforms complex legal documents into a simple 'nutrition label', highlighting critical risks and data privacy policies. Built with the Portia AI SDK for AgentHacks 2025.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks