8000
Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏒 Enterprise Document Intelligence System

Production-ready multi-agent AI system for automated document compliance, risk assessment, and PII detection using CrewAI

Python 3.8+ CrewAI License: MIT


πŸ“– Overview

An enterprise-grade document intelligence system powered by 6 specialized AI agents working collaboratively to:

  • πŸ” Detect sensitive information (PII/PHI) across 6 pattern types
  • βš–οΈ Validate compliance with GDPR, HIPAA, and SOC2 regulations
  • πŸ“Š Calculate risk scores (0-100) with weighted algorithms
  • πŸ“ Generate audit-ready reports with actionable recommendations
  • πŸ‘€ Implement human-in-the-loop governance for critical cases

Perfect for: Healthcare, Finance, Legal, HR, and any industry handling sensitive data.


✨ Key Features

πŸ€– Multi-Agent Architecture

  • 6 Specialized Agents working in sequential workflow
  • YAML-based configuration for easy customization
  • CrewAI orchestration with modern best practices

πŸ›‘οΈ Security & Compliance

  • PII/PHI Detection: SSN, MRN, DOB, Email, Phone, Credit Cards
  • Multi-Framework Support: GDPR, HIPAA, SOC2
  • Risk-Based Processing: Automatic routing based on sensitivity
  • Human Oversight: Required for high-risk documents (score β‰₯ 75)

πŸ”§ Production-Ready

  • Custom Tools with Pydantic validation
  • Natural Language Parsing for flexible agent inputs
  • Comprehensive Logging and error handling
  • Sample Documents for testing all risk levels

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Document  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         6-Agent Sequential Pipeline         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1. Intake Specialist    β†’ Extract & Validateβ”‚
β”‚ 2. Classifier           β†’ Type & Sensitivityβ”‚
β”‚ 3. PII Scanner          β†’ Detect Sensitive  β”‚
β”‚ 4. Compliance Checker   β†’ Regulatory Review β”‚
β”‚ 5. Risk Assessor        β†’ Calculate Score   β”‚
β”‚ 6. Report Generator     β†’ Audit Report      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Report    β”‚
β”‚ Risk: 85/100β”‚
β”‚ CRITICAL    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • OpenAI API key
  • pip or conda for package management

Installation

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/enterprise-doc-intelligence.git
    cd enterprise-doc-intelligence
  2. Create virtual environment (recommended)

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp .env.example .env
    # Edit .env and add your OpenAI API key:
    # OPENAI_API_KEY=your-api-key-here

Running Your First Analysis

cd src
python main.py ../sample_documents/medical_record_sample.txt

Expected output:

  • 6 agents execute in sequence
  • PII detection: 5 types found (SSN, MRN, DOB, Email, Phone)
  • Risk score: 85/100 (CRITICAL)
  • Recommendation: Human review required
  • Report saved to outputs/compliance_report.md

πŸ“ Project Structure

enterprise-doc-intelligence/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ agents.yaml          # Agent definitions (roles, goals, backstory)
β”‚   β”‚   └── tasks.yaml           # Task definitions (descriptions, outputs)
β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”œβ”€β”€ pii_detector.py      # 6-pattern PII/PHI detection
β”‚   β”‚   β”œβ”€β”€ compliance_checker.py# GDPR/HIPAA/SOC2 validation
β”‚   β”‚   β”œβ”€β”€ risk_calculator.py   # Weighted risk scoring
β”‚   β”‚   β”œβ”€β”€ pdf_extractor.py     # PDF text extraction
β”‚   β”‚   └── text_extractor.py    # TXT file reader
β”‚   β”œβ”€β”€ crew.py                  # CrewAI orchestration
β”‚   └── main.py                  # Entry point
β”œβ”€β”€ sample_documents/            # Test files (3 risk levels)
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ COMPLETE_GUIDE.md        # Step-by-step tutorial
β”‚   └── YAML_QUICKSTART.md       # YAML configuration guide
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
└── README.md

πŸ€– The 6 Agents

Agent Role Tools Output
Intake Specialist Document Validator Text/PDF Extractor Clean text + metadata
Classifier Type Analyzer LLM Reasoning Document type + sensitivity
PII Scanner Data Detector PII Detector Sensitive data list + score
Compliance Checker Regulatory Auditor Compliance Engine Violations + remediation
Risk Assessor Risk Calculator Risk Scorer 0-100 score + level
Report Generator Documentation Writer LLM Synthesis Audit-ready report

All agents are configured in src/config/agents.yaml using CrewAI's modern declarative YAML approach.


πŸ”§ Custom Tools

1. PII Detector

Patterns: SSN, Email, Phone, MRN, Credit Cards, DOB
Risk Weights: 3-10 points per type
Output: Detection list + total risk score

2. Compliance Checker

Frameworks: GDPR, HIPAA, SOC2
Rules: 15+ compliance checks per framework
Output: Violations + recommended controls

3. Risk Calculator

Inputs: PII score + Classification + Violations
Algorithm: Weighted sum (max 100)
Output: Risk level (LOW/MEDIUM/HIGH/CRITICAL)

4. PDF/Text Extractors

Supported: PDF, TXT files
Output: Text content + metadata (size, line count)


πŸ“Š Sample Documents

Three sample documents demonstrate different risk levels:

Document Risk Level PII Types Use Case
medical_record_sample.txt CRITICAL (85) SSN, MRN, DOB, Email, Phone Healthcare PHI
invoice_sample.txt MEDIUM (45) Email, Phone Business documents
public_announcement_sample.txt LOW (10) None Public communications

🎯 Usage Examples

Basic Usage

cd src
python main.py /path/to/document.txt

Process Medical Records

python main.py ../sample_documents/medical_record_sample.txt

Batch Processing

for file in ../sample_documents/*.txt; do
    python main.py "$file"
done

View Output

cat outputs/compliance_report.md

πŸ“ˆ Sample Output

# Compliance Report

## Executive Summary
- Document Type: Medical Record
- Classification: RESTRICTED
- Risk Score: 85/100 (CRITICAL)

## PII/PHI Findings
- SSN: 123-45-6789
- MRN: MRN-987654
- DOB: 03/15/1985
- Email: patient@email.com
- Phone: 555-123-4567

## Risk Assessment
⚠️ CRITICAL RISK - Requires human review

## Recommendations
1. [HUMAN REVIEW] Require approval before processing
2. [SECURITY] Apply enhanced PII protection
3. [ACTION] Implement RBAC and encryption

πŸ” Security & Privacy

  • βœ… No data storage: Documents processed in-memory only
  • βœ… API key protection: Environment variables for credentials
  • βœ… Audit logging: Complete activity trail
  • βœ… Configurable: Adjust risk thresholds and rules
  • βœ… Extensible: Add custom compliance frameworks

πŸ› οΈ Configuration

Customize Agents

Edit src/config/agents.yaml:

pii_detection_agent:
  role: "Sensitive Data 
8000
Scanner"
  goal: "Detect all PII and PHI in documents"
  backstory: "Expert in data privacy with 15 years experience..."

Customize Tasks

Edit src/config/tasks.yaml:

pii_detection_task:
  description: "Scan the document for PII/PHI"
  expected_output: "Complete PII detection results with risk scores"

Adjust Risk Weights

Edit src/tools/risk_calculator.py:

CLASSIFICATION_WEIGHT = {
    'public': 0,
    'internal': 10,
    'confidential': 25,
    'restricted': 40
}

πŸ“š Documentation


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Ideas for Contributions

  • πŸ”Ή Additional compliance frameworks (PCI-DSS, ISO 27001)
  • πŸ”Ή More PII patterns (passport numbers, tax IDs)
  • πŸ”Ή Support for more file formats (DOCX, XLSX)
  • πŸ”Ή Web UI for document upload
  • πŸ”Ή Database integration for report storage
  • πŸ”Ή Multi-language support
  • πŸ”Ή Performance optimizations
  • πŸ”Ή Unit tests and integration tests

πŸ› Known Issues & Limitations

  • PDF extraction requires PyPDF2 (included in requirements)
  • Risk calculator currently supports text-based analysis only
  • LLM calls can be slow for large documents (>10 pages)
  • Requires OpenAI API key (costs apply)

πŸ—ΊοΈ Roadmap

  • Add support for DOCX and XLSX files
  • Implement caching for repeated analyses
  • Add FastAPI REST API endpoint
  • Create web-based UI
  • Support for custom PII patterns via config
  • Integration with document management systems
  • Performance benchmarking suite
  • Docker containerization

πŸ’‘ Use Cases

Healthcare

  • Patient record processing
  • PHI compliance validation
  • HIPAA audit preparation

Finance

  • Customer data governance
  • PCI-DSS compliance
  • Fraud detection support

Legal

  • Contract analysis
  • Discovery document review
  • Client data protection

Human Resources

  • Employee file processing
  • Background check compliance
  • GDPR data mapping

πŸ™ Acknowledgments

  • CrewAI - For the excellent multi-agent framework
  • OpenAI - For GPT-4 language models
  • Community - For feedback and contributions

πŸ“„ License

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


πŸ“ž Contact & Support


⭐ Star History

If you find this project useful, please consider giving it a star! It helps others discover the project.


Built with ❀️ using CrewAI, OpenAI, and Python


πŸ“Š Project Stats

  • Agents: 6 specialized agents
  • Tools: 5 custom tools
  • Frameworks: 3 compliance frameworks
  • PII Types: 6 detection patterns
  • Code: ~3,000 lines
  • Documentation: Comprehensive guides included

About

Compliance Checker agents

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0