Skip to content
SdSarthakPublic

About

Open-source AI Governance, Risk & Compliance (AI-GRC) platform — EU AI Act compliance, LLM Guard, and RAG regulatory intelligence.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

101 stars

Watchers

2 watching

Forks

Repository files navigation

AegisAI

Open-source AI Governance, Risk & Compliance (AI-GRC) Platform

License: AGPL-3.0 Python FastAPI React PRs Welcome

Getting Started· Architecture · API Reference · Guard Module · RAG Module · Regulations · Report a Bug


📚 Table of Contents


Live Demo

A hosted demo is not available yet: the frontend at https://aegis-ai-sigma-seven.vercel.app has no backend behind it, so sign-up and login won't work there (#1177). Run it locally with the Quick Start instead; it takes a few minutes.


What is AegisAI?

The EU AI Act entered into force in August 2024 and applies in stages: prohibited practices since February 2025, general-purpose AI rules since August 2025, transparency obligations since August 2026, and high-risk requirements from December 2027 (August 2028 for AI built into regulated products). Most compliance tools cost thousands per month and are closed-source.

AegisAI is the open-source alternative — a full-stack platform that combines three things into one:

Module What it does
Compliance Engine Register AI systems, classify EU AI Act risk (Minimal / Limited / High / Unacceptable), generate required documentation (Technical Docs, Risk Assessment, Conformity Declaration), export as PDF
LLM Guard Real-time prompt injection detection using regex + DeBERTa-v3 ML classifier — protect your LLM APIs with per-user rate limiting and a standalone SDK
RAG Intelligence Ask natural language questions about EU AI Act, GDPR, ISO 42001 — grounded answers from regulatory source docs with feedback and quality tracking. The knowledge base starts empty: upload the regulation PDFs you want to query (#1473)

Tech Stack

Layer Technology
Frontend React 18, TypeScript, Vite 5, Tailwind CSS, Zustand, TanStack Query, react-hot-toast
Backend Python 3.11, FastAPI 0.109, SQLAlchemy 2.0, PostgreSQL 15, Alembic
ML (Guard) PyTorch, HuggingFace Transformers (DeBERTa-v3-small), scikit-learn
RAG LangChain 0.2, FAISS, OpenAI-compatible embeddings
MLOps MLflow, Prometheus metrics
Infra Docker Compose, Kubernetes (HPA configs included), GitHub Actions CI
Auth JWT (python-jose), bcrypt

Quick Start

Option 1 — Docker (recommended)

git clone https://github.com/SdSarthak/AegisAI.git
cd AegisAI

cp backend/.env.example backend/.env
# Edit backend/.env — set SECRET_KEY (openssl rand -hex 32) and your LLM provider
# (LLM_API_KEY / LLM_BASE_URL / LLM_MODEL), or use Ollama as in Option 3

docker compose up -d

Compose runs PostgreSQL with postgres/postgres by default and wires the backend to it, so you don't need to change DATABASE_URL. To use other credentials, set POSTGRES_USER and POSTGRES_PASSWORD in your shell or in a .env file next to docker-compose.yml.

Service URL
Frontend http://localhost:5173
Backend API http://localhost:8000
Swagger UI http://localhost:8000/docs

Option 2 — Manual (no Docker)

You need Python 3.11+ and Node.js 20+. PostgreSQL and Redis are optional for local development.

# Backend
cd backend
python -m venv venv
# macOS / Linux
source venv/bin/activate
# Windows CMD
# venv\Scripts\activate.bat
# Windows PowerShell
# venv\Scripts\Activate.ps1

# CPU-only PyTorch first (avoids a multi-GB CUDA download), then the rest
pip install --index-url https://download.pytorch.org/whl/cpu "torch>=2.11.0"
pip install -r requirements.txt

cp .env.example .env
# In .env set SECRET_KEY (openssl rand -hex 32). For the quickest start use SQLite:
#   DATABASE_URL=sqlite:///./aegisai.db
# Leave REDIS_URL empty unless Redis is running (keep DEBUG=true in that case).
uvicorn app.main:app --reload   # creates the database tables on first start

# Frontend (new terminal)
cd frontend
npm install
npm run dev                     # http://localhost:5173, proxies /api to the backend

To use PostgreSQL instead, point DATABASE_URL at it, for example postgresql://postgres:postgres@localhost:5432/aegisai_db.

For hosted frontend deployments, set VITE_API_BASE_URL to the backend API origin, for example http://localhost:8000/api/v1 locally or your deployed backend URL in production.

Option 3 — Ollama (free, no API key)

Run Ollama in a container next to the stack (no changes to backend/.env needed for the LLM):

docker compose -f docker-compose.yml -f docker-compose.ollama.yml up -d
docker compose -f docker-compose.yml -f docker-compose.ollama.yml exec ollama ollama pull llama3.2

Or use an Ollama you already run on your machine (ollama pull llama3.2) and set in backend/.env:

LLM_API_KEY=ollama
LLM_MODEL=llama3.2
# Docker setup (Option 1): the backend reaches your machine via host.docker.internal
LLM_BASE_URL=http://host.docker.internal:11434/v1
# Manual setup (Option 2): use localhost instead
# LLM_BASE_URL=http://localhost:11434/v1

See Getting Started for all provider options.


Environment Variables

Copy backend/.env.example to backend/.env, then adjust values for your setup.

cp backend/.env.example backend/.env
Variable Description Required Example
APP_NAME Display name used by the backend. Optional AegisAI
DEBUG Enables debug behavior and verbose logging. Optional true
API_V1_PREFIX Base path prefix for API routes. Optional /api/v1
DATABASE_URL SQLAlchemy database connection string (PostgreSQL in production). Yes postgresql://postgres:postgres@localhost:5432/aegisai_db
SECRET_KEY JWT signing secret. Use a long random value. Yes f2d5...
ALGORITHM JWT algorithm used for token signing. Optional HS256
ACCESS_TOKEN_EXPIRE_MINUTES JWT access token lifetime in minutes. Optional 30
LLM_API_KEY API key for your OpenAI-compatible provider. Use ollama for local Ollama mode. Yes (unless fully local mock setup) sk-... or ollama
LLM_BASE_URL Custom OpenAI-compatible base URL. Leave empty for OpenAI default. Optional http://localhost:11434/v1
LLM_MODEL Chat/completion model name used by Guard and RAG modules. Yes gpt-4o-mini
GUARD_SANITIZATION_LEVEL Prompt sanitization strictness (low, medium, high). Optional medium
GUARD_MAX_PROMPT_LENGTH Maximum prompt length accepted by Guard processing. Optional 2000
RAG_CHUNK_SIZE Document chunk size for RAG indexing. Optional 1000
RAG_CHUNK_OVERLAP Overlap between adjacent RAG chunks. Optional 200
FAISS_INDEX_PATH Filesystem path for persisted FAISS index. Optional faiss_index
S3_BUCKET_NAME Bucket used for optional document/object storage integration. Optional aegisai-docs
MLFLOW_TRACKING_URI Remote MLflow server URI. Leave empty for local ./mlruns. Optional http://localhost:5000
STRIPE_SECRET_KEY Stripe secret key for billing features. Optional sk_test_...
STRIPE_PUBLISHABLE_KEY Stripe publishable key for frontend billing flows. Optional pk_test_...
STRIPE_WEBHOOK_SECRET Stripe webhook signing secret for event validation. Optional whsec_...
STRIPE_PRICE_STARTER Stripe Price ID for starter plan. Optional price_123
STRIPE_PRICE_GROWTH Stripe Price ID for growth plan. Optional price_456
STRIPE_PRICE_SCALE Stripe Price ID for scale plan. Optional price_789

Common Setup Profiles

  • Ollama local (no paid API): set LLM_API_KEY=ollama, LLM_BASE_URL=http://localhost:11434/v1, and LLM_MODEL to a local model such as llama3.2.
  • OpenAI: set LLM_API_KEY=sk-..., leave LLM_BASE_URL empty, and keep LLM_MODEL=gpt-4o-mini (or another OpenAI model).
  • PostgreSQL local: keep DATABASE_URL=postgresql://postgres:postgres@localhost:5432/aegisai_db and make sure the database exists before startup.

Viewing RAG MLflow Runs Locally

RAG query tracking uses MLFLOW_TRACKING_URI. Leave it empty to write runs to the local ./mlruns directory, or set it to a running tracking server such as http://localhost:5000.

cd backend
mlflow ui --port 5001

Open http://localhost:5001 and select the RAG query runs to inspect question text, answer length, source count, response latency, and answer artifacts.


📓 Colab Notebooks

If you want to train the machine learning models yourself, you can run our official Google Colab notebooks on a free T4 GPU:

  • Open In Colab Fine-tune Regulatory Q&A Model (Llama-3.2-3B QLoRA)

Project Structure

AegisAI/
├── backend/
│   ├── app/
│   │   ├── api/v1/          # REST endpoints (auth, ai_systems, classification,
│   │   │                    #   documents, guard, rag, analytics, badge,
│   │   │                    #   notifications, webhooks)
│   │   ├── core/            # Config, DB, JWT security
│   │   ├── models/          # SQLAlchemy ORM models (users, ai_systems,
│   │   │                    #   documents, rag_feedback, audit_log, ...)
│   │   ├── schemas/         # Pydantic request/response schemas
│   │   └── modules/
│   │       ├── guard/       # LLM Guard — regex + DeBERTa classifier + sanitizer
│   │       │   ├── training/ # Standard ML training pipeline
│   │       │   │   ├── configs/     # YAML training configuration
│   │       │   │   ├── data/        # Dataset loading, preprocessing, splitting
│   │       │   │   ├── evaluation/  # Metrics and evaluator
│   │       │   │   ├── pipelines/   # Train and evaluate pipeline entry points
│   │       │   │   ├── trainer/     # IntentClassifier trainer wrapper
│   │       │   │   ├── utils/       # Logging, seed, checkpoints, MLflow helpers
│   │       │   │   └── artifacts/   # Checkpoints, metrics, reports
│   │       │   └── models/classifier/ # Fine-tuned guard classifier output
│   │       ├── rag/         # RAG — FAISS vector store + LangChain chain + feedback
│   │       ├── llm/         # OpenAI-compatible LLM client
│   │       └── badge/       # SVG compliance badge generator
│   ├── data/
│   │   ├── regulatory_qa.csv        # 75-row QA dataset (EU AI Act, GDPR, ISO 42001)
│   │   └── regulatory_docs/         # Add your regulatory PDFs here
│   └── tests/               # Pytest suite — unit + integration tests
├── frontend/                # React + TypeScript dashboard
│   └── src/
│       ├── pages/           # Dashboard, AISystems, Classification, Documents,
│       │                    #   Analytics, Notifications, Onboarding, Login, Register
│       ├── components/      # Layout, ComplianceChecklist, DocumentEditor,
│       │                    #   NotificationBell, ThemeToggle
│       ├── services/api.ts  # Axios client for all endpoints
│       └── stores/          # Zustand auth store
├── guard-sdk/               # Standalone Python package (v0.1.0) — importable LLMGuard
├── mcp/                     # Model Context Protocol server scaffold
├── infra/                   # Kubernetes Deployment + HPA configs
├── notebooks/               # Jupyter — train Guard classifier on GPU (Colab-ready)
├── scripts/                 # scan_prompts.py CLI for scanning .prompts/ files
├── postman/                 # Postman collection for all API endpoints
├── docs/                    # Architecture, API reference, module guides
└── docker-compose.yml

Project Status

AegisAI took part in GSSoC 2026 (May–August 2026). Thank you to the 150+ contributors whose pull requests were merged during the program. The program has ended and the backlog has been triaged. The project is open to new contributors again: see Contributing.

Added during the program:

  • Notifications: in-app notifications with an unread bell, plus outbound webhooks
  • Audit trails: Guard scan decisions and RAG queries are logged (prompt and question hashes only, never raw text)
  • Analytics: compliance timeline, summary and per-system risk endpoints with dashboard charts
  • Streaming RAG answers over Server-Sent Events, with structured article/paragraph citations
  • Per-user RAG isolation: separate FAISS index per user, with integrity checks
  • Google OAuth sign-in, password change, token invalidation and login/registration rate limiting
  • Regulation plugins: YAML rulesets loaded at startup
  • MCP server (mcp/) and a reusable compliance-check GitHub Action (action.yml)
  • Observability: structured JSON logs with request IDs, Prometheus /metrics and OpenTelemetry hooks
  • Daily compliance snapshot and reassessment-reminder jobs, an onboarding flow, dark mode, PDF export and CSV import/export

Roadmap

  • EU AI Act risk classification engine
  • AI system registry + compliance dashboard
  • Compliance document generation (Technical Docs, Risk Assessment, Conformity Declaration)
  • PDF export for compliance documents
  • LLM Guard — regex + DeBERTa ML classifier + sanitizer + rate limiting
  • RAG query endpoint + feedback loop + low-quality chunk tracking
  • SVG compliance badge generator
  • Bulk CSV import for AI systems
  • AI Systems search and filter
  • User profile management (PATCH /users/me)
  • Guard SDK (standalone package)
  • Guard scan GitHub Action
  • 75-row regulatory QA evaluation dataset
  • Notifications (model, API, bell UI)
  • Audit log for Guard scan decisions
  • MCP server
  • Google OAuth sign-in
  • Compliance score rollup over time (#137: snapshots exist, but scores are never computed)
  • Reassessment reminders (#138: job exists, needs de-duplication and expiry dates)
  • Onboarding wizard reachable from the app (#112)
  • Baseline Alembic migration so alembic upgrade head can build a fresh database (#70)
  • Pre-loaded regulatory knowledge base (EU AI Act, GDPR, ISO 42001, NIST AI RMF)
  • Regulation plugins driving classification and gap analysis (#88)
  • Role-based access control and organisations (#48, #85)
  • Guard SDK published to PyPI and tagged releases
  • Published fine-tuned Guard weights so CI can enforce the evaluation threshold

Open items are great contribution opportunities — see CONTRIBUTING.md.


Contributing

We welcome contributions of all kinds — code, docs, tests, regulatory expertise.

See CONTRIBUTING.md for the full guide.

Not sure where to start? Browse issues labelled:

Taking part through a contributor program (GSSoC, Hacktoberfest, …)? Read the Contributor Programs rules first: one assigned issue at a time, at most two open PRs.


Troubleshooting

npm install fails

Clear the npm cache and reinstall dependencies:

npm cache clean --force
npm install

Module not found error

Delete node_modules and reinstall dependencies:

rm -rf node_modules
npm install

Port already in use

Stop the process using the port (8000 for the API, 5173 for the frontend) or change the port number.

Environment variables not loading

Make sure backend/.env exists (copy it from backend/.env.example) and contains at least SECRET_KEY and LLM_API_KEY.

Application fails to start

Make sure all dependencies are installed and that you are using Python 3.11+ for the backend and Node.js 20+ for the frontend.


License

AegisAI is licensed under AGPL-3.0-only.

  • Free for open-source and self-hosted use.
  • If you run a modified version as a SaaS, you must release your source code.
  • For commercial licensing, contact the author.

Copyright (C) 2024–2026 Sarthak Doshi (@SdSarthak)


Built with care. If AegisAI helps you, give it a star.

About

Open-source AI Governance, Risk & Compliance (AI-GRC) platform — EU AI Act compliance, LLM Guard, and RAG regulatory intelligence.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

101 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages