π Azure Innovation Challenge Entry - Enterprise-grade legal contract analysis platform powered by CUAD (Contract Understanding Atticus Dataset) strategy and Azure AI.
A production-ready RAG system specialized for legal contract analysis with enterprise security, built for Azure with Next.js frontend and FastAPI backend.
- CUAD Integration: 41 legal clause types from Atticus dataset
- Red Flag Detection: AI-powered risk identification in contracts
- One-Click Deployment: Fully automated with data seeding
- Enterprise Security: Managed Identity with RBAC
- Legal Intelligence: Semantic search optimized for legal terminology
- Framework: Next.js 15+ with App Router
- Hosting: Azure App Service (Node.js 20 LTS)
- Authentication: Entra ID SPA registration
- Features: Contract upload, clause filtering, red flag dashboard
- Framework: FastAPI with async/await
- Hosting: Azure App Service (Python 3.11)
- Authentication: Entra ID Web API with OBO token flow
- Features: CUAD processing, legal search, AI analysis
- Authentication: Entra ID with On-Behalf-Of (OBO) flow + Managed Identity
- Search: Azure AI Search with CUAD-optimized semantic ranking
- AI: Azure OpenAI (GPT-4o) for legal analysis
- Document Processing: Azure Document Intelligence (F0 tier)
- Content Safety: Azure Content Safety (F0 tier)
- Storage: Azure Storage with automated CUAD data seeding
- Monitoring: Application Insights + Log Analytics
- Deployment: Azure Developer CLI (azd) with Bicep
- 41 Clause Types: Governing Law, Change of Control, Indemnification, etc.
- Red Flag Detection: Automated high-risk clause identification
- Legal Analyzer: Microsoft analyzer optimized for legal terminology
- Semantic Search: Legal context-aware search and ranking
- Azure CLI installed
- Azure Developer CLI (azd) installed
- Access to Azure subscription with Owner permissions
git clone <repository>
cd droitai# Place your legal documents here for automated seeding
mkdir -p data/cuad-contracts
# Add your PDF/TXT contract files
cp your-contracts/*.pdf data/cuad-contracts/# Deploys infrastructure, uploads contracts, and starts applications
azd upThat's it! π Your legal contract analysis platform is ready with:
- β Infrastructure provisioned
- β CUAD contracts uploaded automatically
- β Search index created and populated
- β Applications running and secured
azd env get-values # Get URLs and credentialsFrontend: Legal contract analysis interface
Backend API: https://<backend-app-name>.azurewebsites.net/docs
# Get Azure credentials
azd env get-values > .env.local
# Frontend
cd frontend
npm install
npm run dev
# Backend
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000/droitai
βββ /frontend (Next.js 15+ App Router)
β βββ /app
β β βββ /api/auth # Entra ID authentication
β β βββ /chat # Legal chat interface
β β βββ layout.tsx # Context providers
β βββ /components
β β βββ /chat # Legal message components
β β βββ /legal # CUAD clause filters
β βββ /hooks # useChat, useOboToken
β βββ /lib # Client utilities
βββ /backend (FastAPI)
β βββ /app
β β βββ /api # API routes (v1/chat, v1/ingest)
β β βββ /core # Security, Config
β β βββ /services # Business logic
β β β βββ search_service.py # CUAD-optimized search
β β β βββ openai_service.py # Legal analysis AI
β β β βββ docintel_service.py # Document Intelligence
β β β βββ safety_service.py # Content Safety
β β βββ main.py
β βββ /evaluators # Responsible AI metrics
β βββ /models # Pydantic schemas
βββ /infra (Infrastructure as Code)
β βββ main.bicep # Azure resources orchestration
β βββ /modules
β β βββ search.bicep # CUAD-optimized search index
β β βββ storage.bicep # Azure Storage
β β βββ ai-services.bicep # OpenAI, Document Intelligence
β β βββ monitoring.bicep # App Insights, Log Analytics
β βββ azure.yaml # AZD service configuration
βββ /data/cuad-contracts/ # Legal documents for seeding
βββ /scripts
β βββ sync-data.ps1 # Windows data upload script
β βββ sync-data.sh # Linux/Mac data upload script
β βββ test-env.ps1 # Environment verification
βββ README.md # This file
- Managed Identity: Zero secrets, Azure AD RBAC only
- Separate Identities: Frontend and backend with dedicated Entra ID apps
- OBO Token Flow: Secure token exchange between services
- Least Privilege Access: Granular role assignments
- Network Security: Storage with deny-by-default, HTTPS only
- Content Safety: Built-in legal content filtering
-
Data Encryption: All contracts encrypted at rest and in transit
-
Audit Logging: Complete legal document access trail
-
CORS Configuration: Secure cross-origin resource sharing
-
Token Validation: Both frontend and backend validate tokens
- CUAD Analysis: 41 clause types automatically identified
- Red Flag Detection: AI-powered risk assessment
- Legal Semantic Search: Context-aware contract search
- Faceted Filtering: Filter by clause types, risk level, document
- Document Intelligence: PDF, Word, and image processing
- One-Click Deployment: Automated infrastructure and data seeding
- Managed Identity: Production-ready security without API keys
- Scalable Architecture: Microservices with container support
- Responsible AI: Legal evaluation metrics and governance
- Developer Experience: Full local development with Docker
- Governing Law, Change of Control, Indemnification
- Limitation of Liability, Warranty Duration, Confidentiality
- Non-Compete, Assignment, Termination for Convenience
- And 32 more specialized legal clause types
- Free Tiers: Search (Free), Document Intelligence (F0), Content Safety (F0)
- Basic Tiers: App Service (B1), Storage (Standard_LRS)
- Pay-as-you-go: OpenAI (S0) with usage-based billing
- Monitoring: Free tier for Application Insights and Log Analytics
# Preview infrastructure changes
azd provision --preview
# Deploy infrastructure only
azd provision
# Deploy application only
azd deploy# Add new contracts
cp new-contracts/*.pdf data/cuad-contracts/
azd up # Re-deploys with new data
# Clear and reseed data
rm -rf data/cuad-contracts/*
azd up- Application Insights: Legal document processing tracking
- Log Analytics: Centralized legal audit logging
- Health Checks: Application and legal service monitoring
- Error Tracking: Comprehensive legal AI error reporting
- Zero Manual Steps: Contracts uploaded during deployment
- Idempotent Operations: Safe re-deployment with data preservation
- Cross-Platform: Works on Windows, Linux, and Mac
- Keyless Architecture: No API keys or secrets in code
- RBAC-First: Role-based access control throughout
- Identity-Based: Uses Azure AD identities exclusively
- CUAD Integration: Industry-standard legal clause dataset
- Semantic Legal Search: Optimized for legal terminology
- Risk Intelligence: Automated red flag identification
- π CUAD Data Guide - Contract data structure
- π§ Deployment Guide - Step-by-step deployment
- π API Documentation - Interactive API docs
- Azure AD App Registration Setup - Configure frontend and backend app registrations
- Permission Grants & Admin Consent - Required API permissions and consent workflow
- OBO Token Flow Architecture - On-Behalf-Of token exchange between services
- Managed Identity Configuration - Keyless authentication setup
- Azure Architecture Overview - Complete infrastructure diagram and components
- Bicep Infrastructure as Code - Infrastructure deployment and customization
- Networking & Security - VNet, private endpoints, and security groups
- Monitoring & Observability - Application Insights and Log Analytics setup
- Microservices Design - Frontend, backend, and AI service architecture
- Data Processing Pipeline - Document ingestion and vector indexing
- Legal AI Integration - OpenAI, Document Intelligence, and Content Safety
- CUAD Dataset Integration - Legal clause analysis and red flag detection
- Local Development Setup - Docker, environment configuration, and debugging
- Testing Strategy - Unit tests, integration tests, and legal AI validation
- Deployment Automation - AZD workflows and CI/CD pipeline
- Troubleshooting Guide - Common issues and solutions
- Fork the repository
- Create a feature branch
- Test with
azd up - Submit a pull request
MIT License - see LICENSE file for details
π Built for Azure Innovation Challenge 2026
π Enterprise-Grade Legal AI with CUAD Integration
π One-Click Deployment with Automated Data Seeding

