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.
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
-
Clone the repository
git clone https://github.com/PulastTiwari/pactguard.git cd pactguard -
Configure environment
cp .env.docker.template .env
Edit
.envand add your API keys:- Get Portia AI key: https://app.portialabs.ai/
- Get Google AI key: https://makersuite.google.com/app/apikey
-
Deploy with Docker
./docker-deploy.sh
-
Access the application
- Frontend: http://localhost:3000
- API Docs: http://localhost:8001/docs
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 --reloadFrontend Setup:
npm install
cp .env.local.template .env.local
npm run dev- Demo & Screenshots
- Project Vision
- Technical Architecture
- API Documentation
- Contributing
- Roadmap
- License
- Document Analysis: Upload or paste legal text for instant AI analysis
- Risk Assessment: Get numerical risk scores with detailed explanations
- Email Integration: Receive professional reports directly in your inbox
- Google Drive: Analyze documents directly from your Drive storage
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.
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.
- 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
PactGuard implements a decoupled, service-oriented architecture optimized for scalability and maintainability.
- 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
- 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
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)}")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.
We welcome contributions from the community! PactGuard is designed to be community-driven and collaborative.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- 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.
- Enhanced document type support (NDAs, terms of service, etc.)
- Improved risk scoring algorithms
- Document comparison features
- User authentication and personalized dashboards
- Browser extension for in-situ analysis
- Public API for third-party integrations
- Enterprise features (SSO, audit logs, multi-tenancy)
- Advanced analytics and insights
- 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.
- 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.
AgentHacks 2025 Project
- Developer: Pulast Singh Tiwari
- Timeline: 5-day intensive development period
- Focus: Rapid prototyping with production-ready architecture
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [Your contact email]
- Documentation: Project Wiki
Star this repository if PactGuard helps you with legal document analysis!
Built with love by Pulast Singh Tiwari for the legal tech community.