Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

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

Repository files navigation

πŸ›‘οΈ AI Compliance Copilot

Python 3.9+ FastAPI Streamlit License: MIT Tests Docker

A production-quality, multi-framework AI compliance evaluation system. Assess AI systems against 7 regulatory frameworks with severity-weighted remediation plans, multi-framework comparison, compliance history tracking, and structured exports.


Problem Statement

AI adoption is accelerating across healthcare, government, finance, and critical infrastructure -- but compliance evaluation remains manual, slow, and inconsistent.

Organizations deploying AI systems face:

  • Dozens of controls across multiple frameworks with no automated way to assess them
  • Compliance teams that lack AI-specific expertise to interpret framework requirements
  • No way to compare compliance posture across frameworks simultaneously
  • No historical tracking to demonstrate compliance improvements over time
  • Undetected gaps that expose organizations to regulatory penalties and patient safety risks

Solution

AI Compliance Copilot automates compliance evaluation with structured, LLM-powered reasoning:

  1. Describe your AI system in plain text
  2. Select one or more of 7 supported frameworks
  3. Receive per-control compliance status with evidence, gaps, severity, and remediation steps
  4. Get a prioritized remediation plan ranked by risk x severity
  5. Compare results across frameworks side by side
  6. Track compliance history over time
  7. Export as PDF or JSON for audit documentation

Key Features

  • 7 compliance frameworks with 70 controls total, each with severity ratings
  • Multi-framework comparison -- evaluate against multiple frameworks in one request
  • Prioritized remediation plans -- actions ranked by risk score x control severity
  • Compliance history -- track and review past analyses over time
  • Dual export -- download results as PDF report or structured JSON
  • Prompt injection detection -- flags suspicious inputs for human review
  • Mock + real LLM -- works out of the box with mock evaluator, optional OpenAI integration
  • 34 automated tests covering engine, scoring, remediation, history, and API

Supported Frameworks

Framework Focus Areas Controls Severities
NIST AI RMF Governance, risk lifecycle, measurement, accountability 10 4 critical, 5 high
HIPAA PHI protection, encryption, access controls, audit logs 10 4 critical, 3 high
NIST CSF Identify, Protect, Detect, Respond, Recover 10 4 critical, 4 high
FedRAMP Authentication, audit logs, boundary protection 10 5 critical, 3 high
ISO 27001 ISMS, policies, incident management, governance maturity 10 3 critical, 5 high
OWASP LLM Top 10 Prompt injection, data leakage, insecure output handling 10 3 critical, 5 high
GDPR Data minimization, privacy by design, DPIA, subject rights 10 5 critical, 4 high

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Streamlit Frontend (v3)                   β”‚
β”‚   Single Analysis | Multi-Framework Comparison | History      β”‚
β”‚   Remediation Plan | PDF + JSON Export | Severity Badges      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚ POST /analyze, /analyze/multi
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FastAPI Backend (v3.0)                     β”‚
β”‚   Request ID tracking | Structured errors | CORS              β”‚
β”‚                                                              β”‚
β”‚  Compliance Engine                                           β”‚
β”‚    β”œβ”€β”€ Load controls + severity from JSON                    β”‚
β”‚    β”œβ”€β”€ For each control:                                     β”‚
β”‚    β”‚     β”œβ”€β”€ Prompt Builder (base + framework + control)      β”‚
β”‚    β”‚     └── LLM Client (mock or OpenAI)                     β”‚
β”‚    β”œβ”€β”€ Risk Scoring (Yes=0, Partial=0.5, No=1, averaged)     β”‚
β”‚    β”œβ”€β”€ Remediation Priority (risk x severity weight)          β”‚
β”‚    └── Report Generator (PDF)                                β”‚
β”‚                                                              β”‚
β”‚  History Layer (JSON persistence)                            β”‚
β”‚  Data Layer: 7 JSON control files (70 controls total)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

National Impact

  • Healthcare Safety: Evaluate AI/ML models against HIPAA and NIST before deployment, reducing PHI exposure and patient harm risk.
  • Critical Infrastructure: FedRAMP and NIST CSF alignment for AI in government and defense.
  • Regulatory Alignment: Supports Executive Order 14110 on Safe, Secure, and Trustworthy AI.
  • Risk Quantification: Severity-weighted remediation plans enable leadership to prioritize fixes by impact.
  • International Coverage: GDPR and ISO 27001 for cross-jurisdictional operations.

Quick Start

Option 1: Docker

cp .env.example .env
docker compose up --build

Backend: localhost:8000 | Frontend: localhost:8501 | API Docs: localhost:8000/docs

Option 2: Local

python3 -m venv venv && source venv/bin/activate
python3 -m pip install -r requirements.txt

# Terminal 1
python3 -m uvicorn app.main:app --reload --port 8000

# Terminal 2
python3 -m streamlit run frontend/streamlit_app.py

Option 3: Make

make install
make run-backend   # Terminal 1
make run-frontend  # Terminal 2

API Reference

Interactive docs at localhost:8000/docs when running.

POST /analyze -- Single framework analysis

curl -X POST localhost:8000/analyze \
  -H "Content-Type: application/json" \
  -d '{"system_description": "A radiology AI with RBAC and TLS.", "framework": "hipaa"}'

POST /analyze/multi -- Multi-framework comparison

curl -X POST localhost:8000/analyze/multi \
  -H "Content-Type: application/json" \
  -d '{"system_description": "A radiology AI with RBAC and TLS.", "frameworks": ["hipaa", "nist", "gdpr"]}'

GET /history -- View analysis history

DELETE /history -- Clear analysis history

GET /frameworks -- List supported frameworks

GET /health -- Liveness probe


Configuration

Variable Default Description
USE_REAL_LLM false Set true to use OpenAI instead of mock
OPENAI_API_KEY -- Required when USE_REAL_LLM=true
OPENAI_MODEL gpt-4o-mini OpenAI model to use
API_URL localhost:8000 Backend URL (for frontend)
LOG_LEVEL INFO Logging verbosity

Testing

make test
# or
python3 -m pytest tests/ -v

34 tests covering: API endpoints, compliance engine, risk scoring, remediation priority, history, and utilities.


Project Structure

ai-compliance-copilot/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py                  # FastAPI backend with multi-framework support
β”‚   β”œβ”€β”€ compliance_engine.py     # Evaluation orchestrator
β”‚   β”œβ”€β”€ llm_client.py            # Mock + OpenAI LLM integration
β”‚   β”œβ”€β”€ risk_scoring.py          # Risk computation and summary
β”‚   β”œβ”€β”€ remediation.py           # Priority-ranked remediation plans
β”‚   β”œβ”€β”€ history.py               # JSON-based compliance history
β”‚   β”œβ”€β”€ report_generator.py      # PDF generation with Unicode sanitization
β”‚   β”œβ”€β”€ utils.py                 # Shared utilities and registries
β”‚   └── prompts/                 # Modular prompt system (7 frameworks)
β”œβ”€β”€ frontend/
β”‚   └── streamlit_app.py         # Tabbed UI: single, multi, history
β”œβ”€β”€ data/                        # 7 JSON control files with severity levels
β”œβ”€β”€ tests/                       # 34 pytest tests
β”œβ”€β”€ history/                     # Analysis history (JSON persistence)
β”œβ”€β”€ examples/                    # Sample input and output
β”œβ”€β”€ reports/                     # Generated PDF reports
β”œβ”€β”€ docs/                        # Architecture + prompt design docs
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Makefile
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ SECURITY.md
β”œβ”€β”€ LICENSE
└── README.md

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

Changelog

See CHANGELOG.md.

License

MIT -- see LICENSE.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages