Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.

Repository files navigation

RegIntel Care AI - Multi-Hub Compliance Platform

Production-grade multi-tenant compliance platform with dual-hub architecture, adversarial AI auditing, and automated regulatory monitoring

πŸ“Š Build Status & Badges

Frontend Quality Gate CI Pipeline Security Scan Docker Build

System Status Version Architecture AI Models Test Coverage Code Quality Accessibility License

🎯 Project Overview

RegIntel Care AI is a production-ready dual-hub compliance platform (10,000+ LOC) that combines:

Core Architecture

  • βœ… Fail-Closed Multi-Tenancy - PostgreSQL Row-Level Security with 4-layer enforcement
  • βœ… Adversarial AI Auditing - Gemma-3-27B hostile CQC Inspector with structured reasoning
  • βœ… Hash-Chain Audit Trails - Cryptographic integrity verification (SHA-256)
  • βœ… Multi-Channel Notifications - Email/SMS/Webhook/In-app alerts
  • βœ… Async Job Processing - BullMQ with multi-model AI routing

Care Hub (v2.3)

  • βœ… CQC Integration - Official CQC API with facility onboarding
  • βœ… Mock Inspections - AI-powered pre-inspection simulations with SAF gap analysis
  • βœ… Improvement Plans - Automated action plans from current to target ratings
  • βœ… Ground Reports - Frontline staff evidence submission
  • βœ… Geo-Fencing - GPS-based clock-in validation (500m radius)

Immigration Hub (v3.0) πŸ†•

  • βœ… Visa Dashboard - Traffic light status system (GREEN/AMBER/RED)
  • βœ… Staff Profiles - Complete CRUD for immigration data management
  • βœ… Appendix D Generation - One-click Home Office audit packs (individual + bulk)
  • βœ… 20-Hour Enforcement - Real-time student visa cap with roster write-back
  • βœ… Right-to-Work Tracking - Document expiry monitoring with automated alerts

Compliance Radar (v3.0) πŸ†•

  • βœ… AI-Powered Monitoring - 24/7 regulatory change detection (CQC, Home Office, Ofsted, HSE)
  • βœ… Impact Analysis - Automatic HIGH/MEDIUM/LOW classification with actionable recommendations
  • βœ… 10 Seeded Sources - Pre-configured regulatory URLs with daily checks
  • βœ… Change Dashboard - Recent updates with review workflow
  • βœ… Custom Sources - Add and monitor any regulatory URL

Ofsted Hub (v3.0) πŸ†•

  • βœ… Early Years Dashboard - EYFS framework compliance tracking
  • βœ… Inspection History - Record of Ofsted visits and ratings
  • βœ… Compliance Metrics - Real-time monitoring of early years requirements
  • πŸ”¨ Backend Integration - Coming soon (UI ready)

Board Reporting (v3.0) πŸ†•

  • βœ… Unified Dashboard - Executive overview aggregating all 3 hubs
  • βœ… Risk Metrics - Visa status distribution, compliance percentages
  • βœ… Regulatory Alerts - High-impact changes requiring board attention
  • βœ… Print/Export - One-click PDF generation for stakeholders

System Status: 🟒 v3.0 Complete | 18 unit tests + 22 E2E tests passing | CI/CD Pipeline Active | Production-Ready

πŸš€ Quick Start

Backend + AI Worker

# 1. Clone and navigate
cd regintel-care-ai

# 2. Start infrastructure (PostgreSQL + Redis)
cd infra/docker && docker compose up -d

# 3. Setup backend (Terminal 1)
cd ../../apps/backend
npm install
npx prisma generate
npm run start:dev  # Port 3000

# 4. Start AI worker (Terminal 2)
cd ../../services/ai-router
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 -u worker.py

# 5. Seed regulatory sources (v3.0)
cd ../../apps/backend
ts-node scripts/seed-radar-sources.ts

Frontend Dashboard

# Terminal 3
cd apps/web
npm install
npm run dev  # Port 3001

Access Points:

πŸ—οΈ Architecture

The Four Locks (Multi-Layer Security)

graph TB
    A[User Request] --> B[HTTP Middleware: x-tenant-id validation]
    B --> C[AsyncLocalStorage: Request context]
    C --> D[Prisma RLS Extension: Query interception]
    D --> E[PostgreSQL RLS: Row-level filtering]

    F[1. RLS Lock] --> G[Database-level tenant isolation]
    H[2. Visa Shield] --> I[20-hour student visa cap]
    J[3. Geo Fence] --> K[GPS fraud detection - 500m radius]
    L[4. Audit Chain] --> M[SHA-256 hash-chain immutability]
Loading

Dual-Hub System Flow (v3.0)

graph LR
    A[Care Hub] --> D[Board Report]
    B[Immigration Hub] --> D
    C[Compliance Radar] --> D
    E[Ofsted Hub] --> D
    
    D --> F[Executive Dashboard]
    
    A -->|Mock Inspections| G[AI Analysis]
    A -->|Improvement Plans| G
    B -->|Visa Alerts| H[Notifications]
    C -->|Regulatory Changes| H
    G --> I[BullMQ Queue]
    I --> J[Python Worker]
    J --> K[Gemma-3-27B]
Loading

See ARCHITECTURE.md for detailed system design.

🌐 Frontend Routes (v3.0)

Care Hub

  • / - Main dashboard with facility overview
  • /care/inspections - Mock CQC inspections with AI analysis
  • /care/improvement - Improvement plans with action items

Immigration Hub πŸ†•

  • /immigration/dashboard - Visa traffic light system
  • /immigration/staff - Staff profiles CRUD with creation modal
  • /immigration/audit - Appendix D audit pack generation

Ofsted Hub πŸ†•

  • /ofsted/dashboard - Early years compliance overview

Compliance Radar πŸ†•

  • /radar/alerts - Recent regulatory changes with impact analysis
  • /radar/sources - Monitored regulatory URLs management

Executive πŸ†•

  • /board-report - Unified board-level dashboard

πŸ”§ API Endpoints

Staff Management (v3.0) πŸ†•

# Create staff member with immigration profile (atomic transaction)
POST /staff/with-immigration
Headers: x-tenant-id: {uuid}
Body: {
  "full_name": "John Doe",
  "visaType": "SKILLED_WORKER",
  "cosNumber": "ABC123456",
  "visaStartDate": "2024-01-01",
  "visaExpiryDate": "2026-12-31",
  "workRestrictionHours": 48,
  "rtwCheckDate": "2025-01-15",
  "rtwCheckedBy": "HR Manager"
}
Response: {
  "staff": { "id": "uuid", "full_name": "John Doe" },
  "immigration": { "visa_type": "SKILLED_WORKER", "visa_status": "GREEN" }
}

# Get all staff for tenant
GET /staff
Headers: x-tenant-id: {uuid}

Immigration Hub (v3.0) πŸ†•

# Get visa dashboard with traffic light status
GET /immigration/dashboard
Headers: x-tenant-id: {uuid}
Response: {
  "stats": { "green": 45, "amber": 8, "red": 2 },
  "profiles": [
    {
      "staff_id": "uuid",
      "staff_name": "John Doe",
      "visa_status": "AMBER",
      "visa_type": "Skilled Worker",
      "visa_expiry_date": "2026-03-15",
      "documents_complete": true
    }
  ]
}

# Upsert immigration profile
POST /immigration/profiles/:staffId
Headers: x-tenant-id: {uuid}
Body: {
  "visa_type": "STUDENT",
  "visa_expiry_date": "2026-09-30",
  "is_student": true,
  "weekly_hours_limit": 20
}

# Generate Appendix D audit pack (one-click)
GET /immigration/appendix-d/:staffId
Headers: x-tenant-id: {uuid}
Response: {
  "staff_name": "John Doe",
  "sponsor_licence_number": "ABC12345",
  "documents": [...],
  "compliance_checklist": {
    "right_to_work_verified": true,
    "visa_in_date": true
  }
}

# Check shift eligibility (pre-scheduling)
POST /immigration/check-shift-eligibility
Headers: x-tenant-id: {uuid}
Body: {
  "staff_id": "uuid",
  "shift_date": "2025-12-15",
  "shift_duration_hours": 8
}
Response: { "eligible": true, "reason": "..." }

# Validate shift (runtime enforcement)
POST /immigration/validate-shift
Headers: x-tenant-id: {uuid}
Body: {
  "staffEmail": "student@example.com",
  "shiftDurationHours": 6,
  "shiftDate": "2025-12-10"
}
Response 403: {
  "error": "VISA_BREACH_PREVENTED",
  "current_hours": 18,
  "limit": 20
}

Compliance Radar (v3.0) πŸ†•

# Get recent regulatory changes
GET /radar/recent-changes?days=30
Response: [
  {
    "id": "uuid",
    "regulator": "CQC",
    "impact_level": "HIGH",
    "ai_summary": "New safe staffing guidance requires minimum 1:8 ratio...",
    "actionable_recommendations": [
      "Review current staffing ratios",
      "Update rotas to meet new requirements"
    ],
    "affected_domains": ["SAFE", "WELL_LED"],
    "reviewed": false,
    "detected_at": "2025-12-09T00:05:00Z"
  }
]

# Get unreviewed high-impact changes
GET /radar/high-impact
Response: [...]

# Manual check for specific source
POST /radar/check/:sourceId
Response: {
  "message": "Check completed",
  "changes_detected": true,
  "change_id": "uuid"
}

# Mark change as reviewed
POST /radar/mark-reviewed/:changeId
Response: { "success": true }

Board Reporting (v3.0) πŸ†•

# Get unified executive dashboard
GET /reporting/board-report
Headers: x-tenant-id: {uuid}
Response: {
  "care_hub": {
    "total_facilities": 12,
    "cqc_ratings": { "Good": 8, "Requires Improvement": 3 },
    "pending_mock_inspections": 2
  },
  "immigration_hub": {
    "total_staff": 55,
    "visa_status_breakdown": { "GREEN": 45, "AMBER": 8, "RED": 2 },
    "student_visa_breaches_blocked": 0
  },
  "compliance_radar": {
    "active_sources": 10,
    "changes_detected_30_days": 7,
    "unreviewed_high_impact": 2
  }
}

CQC Integration (v2.3)

# Onboard facility via CQC location ID
POST /cqc/onboard
Headers: x-tenant-id: {uuid}
Body: { "cqcLocationId": "1-115235818" }
Response: {
  "id": "uuid",
  "cqc_location_id": "1-115235818",
  "provider_name": "Lower Bowshaw View Nursing Home",
  "latest_rating": "Good"
}

# Get all CQC facilities
GET /cqc/metadata
Headers: x-tenant-id: {uuid}

Mock Inspections & Improvement Plans (v2.3)

# Generate improvement plan
POST /inspections/improvement-plan
Headers: x-tenant-id: {uuid}

# Run mock CQC inspection
POST /inspections/mock-inspection
Headers: x-tenant-id: {uuid}

# Submit human verdict
POST /inspections/mock-inspection/:id/verdict
Body: { "verdict": "AGREE|DISAGREE", "notes": "..." }

# Get all improvement plans
GET /inspections/improvement-plans

# Get mock inspections with filter
GET /inspections/mock-inspections?status=PENDING

Shadow Ratings (AI Analysis)

# Submit evidence for adversarial analysis
POST /analysis/shadow-rating
Headers: x-tenant-id: {uuid}
Body: { "evidence": "Medication error: wrong antibiotic administered" }
Response: { "status": "QUEUED", "jobId": "15" }

# Retrieve AI verdicts
GET /analysis/results
Headers: x-tenant-id: {uuid}
Response: [
  {
    "rating": "Inadequate",
    "reasoning": "Evidence demonstrates a serious failure...",
    "regulation": "Regulation 12",
    "reasoning_steps": [...],
    "confidence": 0.87
  }
]

Geo-Fencing (GPS Fraud Detection)

# Single clock-in validation
POST /geo/validate-clock-in
Headers: x-tenant-id: {uuid}
Body: {
  "staffEmail": "jane@example.com",
  "clientId": "uuid",
  "clockInLat": 51.5074,
  "clockInLng": -0.1278
}
Response 200: { "allowed": true, "distance_meters": 120 }
Response 403: { "allowed": false, "distance_meters": 1523, "fraud_event_id": "uuid" }

# Batch validation
POST /geo/validate-batch

Audit Trail (Hash-Chain)

# Query audit logs
GET /audit/logs?action=BLOCK&limit=50
Headers: x-tenant-id: {uuid}

# Verify cryptographic integrity
GET /audit/verify-integrity
Headers: x-tenant-id: {uuid}
Response: {
  "valid": true,
  "total_entries": 1247,
  "chain_breaks": []
}

πŸ§ͺ Testing Infrastructure (v3.0)

Frontend Tests

cd apps/web

# Vitest unit tests (18 tests)
npm run test

# Playwright E2E tests (22 tests)
npm run test:e2e

# Visual regression tests
npm run test:e2e -- visual-regression.spec.ts

# Specific test suites
npm run test:e2e -- navigation.spec.ts
npm run test:e2e -- immigration-hub.spec.ts
npm run test:e2e -- radar-alerts.spec.ts
npm run test:e2e -- board-report.spec.ts

Test Coverage:

  • βœ… Navigation between 4 hubs (10 pages)
  • βœ… Tenant selector with localStorage persistence
  • βœ… Error handling and graceful degradation
  • βœ… Immigration dashboard with visa traffic lights
  • βœ… Radar alerts with impact filtering
  • βœ… Board report metric aggregation
  • βœ… Visual regression (screenshot comparison)

Backend Tests

cd apps/backend

# Unit tests
npm run test               # All tests
npm run test:watch         # Watch mode
npm run test:cov           # With coverage

# E2E tests
npm run test:e2e

# Specific test
npm run test -- immigration.service.spec

Quality Gates (v3.0) πŸ†•

Pre-commit Hooks (Husky):

# Automatically runs on git commit:
1. TypeScript compilation (tsc --noEmit)
2. ESLint checks
3. Vitest unit tests
4. Next.js build verification

GitHub Actions CI/CD:

# .github/workflows/frontend-quality-gate.yml
- Runs on every push
- TypeScript + ESLint + Tests + Build
- Playwright E2E suite
- Visual regression checks

Comprehensive Integration Harness

# Requires all services running (DB, Redis, Backend, Worker)
chmod +x scripts/run-all-tests.sh
./scripts/run-all-tests.sh

# Tests 8 critical paths:
# 1. Backend health check
# 2. Database connection (RLS enforcement)
# 3. Geo-fence validation
# 4. Visa cap enforcement
# 5. Shadow rating queue
# 6. Audit log retrieval
# 7. Hash-chain integrity
# 8. Worker status

# Output: πŸŽ‰ All Tests PASSED - System Operational

πŸ“Š Technology Stack

Component Technology Purpose Lines of Code
Backend API NestJS + TypeScript REST API with RLS enforcement 3,500 LOC
Frontend Next.js 14 + React + TypeScript Multi-hub dashboard 2,500 LOC
AI Worker Python 3.11 + Gemini SDK Multi-model AI routing 316 LOC
Database PostgreSQL 15 + Prisma RLS-enforced multi-tenancy 307 LOC (schema)
Queue Redis + BullMQ Async job processing -
AI Models Gemma-3-27B-IT, Gemini 1.5 Adversarial analysis + monitoring -
Tests Playwright + Vitest + Jest E2E + Unit + Integration 1,500 LOC
Styling Tailwind CSS + Custom CSS WCAG AAA accessible UI 186 LOC
CI/CD GitHub Actions + Husky Automated quality gates -
Total Multi-stack 4 hubs, 10 pages, 40+ endpoints 10,000+ LOC

πŸ“ Project Structure

regintel-care-ai/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ backend/                          # NestJS API (3,500 LOC)
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ analysis/                # Shadow ratings + AI routing
β”‚   β”‚   β”‚   β”œβ”€β”€ immigration/             # Visa dashboard + enforcement (v3.0)
β”‚   β”‚   β”‚   β”œβ”€β”€ radar/                   # Regulatory monitoring (v3.0)
β”‚   β”‚   β”‚   β”œβ”€β”€ reporting/               # Board report aggregation (v3.0)
β”‚   β”‚   β”‚   β”œβ”€β”€ staff/                   # Staff CRUD module (v3.0)
β”‚   β”‚   β”‚   β”œβ”€β”€ inspections/             # Mock inspections + plans (v2.3)
β”‚   β”‚   β”‚   β”œβ”€β”€ common/                  # Geo-fencing + shared services
β”‚   β”‚   β”‚   β”œβ”€β”€ audit/                   # Hash-chain audit trail
β”‚   β”‚   β”‚   β”œβ”€β”€ notifications/           # Multi-channel alerts
β”‚   β”‚   β”‚   └── database/                # Prisma + RLS extension
β”‚   β”‚   β”œβ”€β”€ __tests__/
β”‚   β”‚   β”‚   β”œβ”€β”€ integration/             # v3.0 feature tests
β”‚   β”‚   β”‚   └── unit/                    # Service unit tests
β”‚   β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”‚   └── seed-radar-sources.ts    # Seed 10 regulatory URLs
β”‚   β”‚   └── prisma/
β”‚   β”‚       β”œβ”€β”€ schema.prisma            # 15+ models with RLS
β”‚   β”‚       └── migrations/              # Database migrations
β”‚   └── web/                             # Next.js dashboard (2,500 LOC)
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ app/
β”‚       β”‚   β”‚   β”œβ”€β”€ care/                # Care Hub pages
β”‚       β”‚   β”‚   β”œβ”€β”€ immigration/         # Immigration Hub (v3.0)
β”‚       β”‚   β”‚   β”œβ”€β”€ ofsted/              # Ofsted Hub (v3.0)
β”‚       β”‚   β”‚   β”œβ”€β”€ radar/               # Compliance Radar (v3.0)
β”‚       β”‚   β”‚   β”œβ”€β”€ board-report/        # Board Report (v3.0)
β”‚       β”‚   β”‚   └── dashboard/           # Admin dashboards
β”‚       β”‚   β”œβ”€β”€ components/
β”‚       β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx          # Multi-hub navigation (v3.0)
β”‚       β”‚   β”‚   β”œβ”€β”€ TenantSelector.tsx   # Tenant context (v3.0)
β”‚       β”‚   β”‚   β”œβ”€β”€ ThemeToggle.tsx      # Dark mode (v3.0)
β”‚       β”‚   β”‚   └── dashboard/           # Reusable components
β”‚       β”‚   └── contexts/
β”‚       β”‚       └── TenantContext.tsx    # Global tenant state (v3.0)
β”‚       └── tests/
β”‚           β”œβ”€β”€ e2e/                     # Playwright E2E (22 tests)
β”‚           └── unit/                    # Vitest unit tests (18 tests)
β”œβ”€β”€ services/
β”‚   └── ai-router/                       # Python AI worker (316 LOC)
β”‚       β”œβ”€β”€ worker.py                    # BullMQ consumer + Gemini
β”‚       └── requirements.txt
β”œβ”€β”€ infra/
β”‚   └── docker/
β”‚       β”œβ”€β”€ docker-compose.yml           # Development infrastructure
β”‚       └── init-scripts/                # 7 SQL migrations
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── frontend-quality-gate.yml    # CI/CD pipeline (v3.0)
β”œβ”€β”€ .husky/                              # Pre-commit hooks (v3.0)
β”œβ”€β”€ scripts/
β”‚   └── run-all-tests.sh                # Integration test harness
β”œβ”€β”€ README.md                            # Main project overview
β”œβ”€β”€ CLAUDE.md                            # Developer guide (in root)
β”œβ”€β”€ docs/                                # πŸ“š All documentation (45+ files)
β”‚   β”œβ”€β”€ README.md                        # Documentation index
β”‚   β”œβ”€β”€ ARCHITECTURE.md                  # System design
β”‚   β”œβ”€β”€ V3_0_DEPLOYMENT_GUIDE.md         # Production deployment
β”‚   β”œβ”€β”€ TESTING_STRATEGY.md              # Test approach
β”‚   β”œβ”€β”€ *.md                             # Markdown documentation
β”‚   β”œβ”€β”€ *.pdf                            # Business documents
β”‚   └── *.docx                           # Strategy documents
└── docker-compose.prod.yml              # Production deployment

🎨 Frontend Features (v3.0)

UI/UX Enhancements

  • βœ… Tenant Context - Global state with localStorage persistence
  • βœ… Next.js API Rewrites - Consistent /api/* routing pattern
  • βœ… Dark Mode - Full support with theme toggle
  • βœ… Sidebar Navigation - 4 hubs with active state indicators
  • βœ… Responsive Design - Mobile-first with Tailwind CSS
  • βœ… Loading States - Skeleton screens and spinners
  • βœ… Error Boundaries - Graceful degradation when backend unavailable

Accessibility (WCAG AAA)

  • βœ… Input Contrast - 14.8:1 contrast ratio (dark text on white background)
  • βœ… Keyboard Navigation - Full keyboard support
  • βœ… Screen Reader Friendly - ARIA labels and semantic HTML
  • βœ… Focus States - Clear visual indicators (2px blue outline)

Developer Experience

  • βœ… TypeScript Strict Mode - Type safety throughout
  • βœ… Consistent Patterns - All features follow Mock Inspections template
  • βœ… Error Handling - Try-catch with user feedback
  • βœ… API Abstraction - Centralized fetch utilities

πŸ”’ Security Features

1. The RLS Lock (Fail-Closed Multi-Tenancy)

// Without tenant context? Query returns [], not all data
if (!context.tenantId) {
  throw new Error('Tenant context required');
}

Four-Layer Enforcement:

  1. HTTP Middleware - Enforces x-tenant-id header
  2. AsyncLocalStorage - Request-scoped context
  3. Prisma RLS Extension - Intercepts ALL queries
  4. PostgreSQL RLS - Database-level row filtering

Critical: Uses app_user role (non-superuser) to prevent RLS bypass.

2. The Visa Shield (Immigration Compliance)

// 20-hour/week student visa cap - hard block
if (projectedTotal > 20) {
  // Automatically triggers:
  // 1. Roster write-back to Deputy/Nourish
  // 2. CRITICAL notification to compliance team
  // 3. Audit log entry with hash-chain
  
  throw new ForbiddenException('VISA_BREACH_PREVENTED');
}

3. The Geo Fence (GPS Fraud Detection)

// Haversine distance calculation
const distance = calculateDistance(
  clockInLat, clockInLng,
  clientLat, clientLng
);

if (distance > 500) {
  // Log fraud event (append-only)
  // Trigger audit entry
  throw new ForbiddenException('GEO_FENCE_VIOLATION');
}

4. The Audit Chain (Cryptographic Integrity)

-- Each entry hashes: previous_hash + current_data (SHA-256)
CREATE TABLE audit_log (
  current_hash VARCHAR(64),
  previous_hash VARCHAR(64)
);

-- Trigger blocks UPDATE/DELETE (append-only)
CREATE TRIGGER audit_immutable BEFORE UPDATE OR DELETE ON audit_log
  FOR EACH ROW EXECUTE FUNCTION reject_audit_modifications();

5. The AI Inspector (Adversarial Auditing)

Prompt Strategy: Epistemic Stratification

ROLE: You are a hostile CQC Inspector.
RULES:
1. Assume the provider is hiding failures.
2. Flag "Missing Evidence".
3. Cite specific regulation breaches.
4. Provide step-by-step reasoning.

Output:

{
  "rating": "Inadequate",
  "reasoning": "Evidence demonstrates a serious failure...",
  "regulation": "Regulation 12",
  "reasoning_steps": [...],
  "confidence": 0.87
}

🚒 Production Deployment

# Build and run all services
docker compose -f docker-compose.prod.yml up -d

# Services launched:
# - postgres:15-alpine (RLS-enforced)
# - redis:alpine (BullMQ queue)
# - backend (NestJS on port 3000)
# - frontend (Next.js on port 3001)
# - worker (Python AI consumer)

# Health checks
curl http://localhost:3000/                         # Backend β†’ 200 OK
curl http://localhost:3001/                         # Frontend β†’ 200 OK
docker exec regintel-queue redis-cli ping           # Redis β†’ PONG
docker exec regintel-db pg_isready -U app_user      # PostgreSQL β†’ ready

πŸ“ˆ Performance Characteristics

Metric Value Notes
API Response Time <50ms Job queuing only (202 Accepted)
AI Processing Time 5-15 seconds Gemma-3-27B inference
Frontend Load Time <2 seconds Next.js SSR + code splitting
Database Latency <10ms RLS adds ~1ms overhead
RLS Enforcement 100% coverage All queries require tenant context
Geo Calculation <1ms Haversine in-memory
Hash Verification ~50ms/1000 entries SHA-256 sequential

🌟 Feature Highlights

v3.0: Dual-Hub Expansion πŸ†•

  • βœ… Immigration Hub with visa traffic light system
  • βœ… Compliance Radar with AI-powered monitoring
  • βœ… Ofsted Hub with EYFS compliance tracking
  • βœ… Board Reporting with unified metrics
  • βœ… Staff CRUD with atomic transactions
  • βœ… Frontend quality gates (Playwright + Vitest)
  • βœ… Dark mode support
  • βœ… WCAG AAA accessibility (14.8:1 contrast)
  • βœ… Comprehensive testing (40 tests total)

v2.3: Care Hub Foundation

  • βœ… CQC API integration
  • βœ… Mock inspections with AI
  • βœ… Improvement plans
  • βœ… Ground reports
  • βœ… Geo-fencing fraud detection

v2.2: Core Platform

  • βœ… Fail-closed multi-tenancy
  • βœ… Adversarial AI auditing
  • βœ… Hash-chain audit trails
  • βœ… Multi-channel notifications
  • βœ… Roster integration

πŸ“Š Code Statistics (v3.0)

Component Files Lines of Code Technology
Backend API 60+ 3,500 NestJS + TypeScript
Frontend 40+ 2,500 Next.js + React
AI Worker 1 316 Python + Gemini SDK
Tests (Backend) 8 400 Jest + Supertest
Tests (Frontend) 9 1,100 Playwright + Vitest
SQL Migrations 7 500 PostgreSQL + RLS
Documentation 15+ 1,500 Markdown
Infrastructure 5 184 Docker + CI/CD
Grand Total 140+ 10,000+ Multi-stack

πŸ“š Documentation

All documentation has been organized into the docs/ directory for easy navigation.

Core Documentation

Testing Documentation

Version Reports

Business Documents

  • Product Requirements PDFs and business strategy documents in docs/

Reference

Complete Index

See docs/README.md for a complete documentation index with all 45+ documents organized by category.

πŸŽ“ Key Learnings

1. RLS with Complex Joins

Issue: Prisma queries with nested relations can fail RLS checks. Solution: Separate queries - fetch IDs first, then related data:

const staffIds = await prisma.staffProfile.findMany({ select: { id: true } });
const profiles = await prisma.immigrationProfile.findMany({ 
  where: { staffId: { in: staffIds } } 
});

2. Global Tables Without tenant_id

Issue: Tables like regulatory_changes are global (no tenant_id). Solution: Use $queryRawUnsafe to bypass RLS for global data:

const changes = await prisma.$queryRawUnsafe<any[]>(`
  SELECT * FROM regulatory_changes WHERE detected_at >= $1
`, since);

3. Superuser RLS Bypass

Issue: PostgreSQL superusers bypass ALL RLS policies. Solution: Use non-superuser app_user role:

DATABASE_URL=postgresql://app_user:app_password@localhost:5432/regintel_v2

4. Frontend Input Contrast

Issue: Light text on light background = invisible typing. Solution: Global CSS with explicit color declarations:

input { background-color: #ffffff; color: #1e293b; }

5. Tenant Context in API Calls

Issue: 401 errors when x-tenant-id header missing. Solution: Global TenantContext with React hooks:

const { tenantId } = useTenant();
fetch('/api/...', { headers: { 'x-tenant-id': tenantId } });

πŸŽ‰ What's New in v3.0

Major Features

  1. Immigration Hub - Complete visa management system
  2. Compliance Radar - AI-powered regulatory monitoring
  3. Ofsted Hub - Early years compliance tracking
  4. Board Reporting - Executive dashboard
  5. Staff Module - Full CRUD with immigration profiles

Frontend Enhancements

  1. Tenant Context - Global state management
  2. Dark Mode - Full theme support
  3. WCAG AAA - 14.8:1 input contrast
  4. 10 Pages - Complete multi-hub navigation
  5. Quality Gates - Pre-commit hooks + CI/CD

Testing Infrastructure

  1. Playwright E2E - 22 tests covering 5 suites
  2. Vitest Unit - 18 component tests
  3. Visual Regression - Screenshot comparison
  4. Pre-commit Hooks - TypeScript + ESLint + Tests
  5. GitHub Actions - Automated quality gates

Bug Fixes

  1. βœ… Fixed 401 errors (missing tenant headers)
  2. βœ… Fixed 500 on board report (RLS queries)
  3. βœ… Fixed input contrast issues (global CSS)
  4. βœ… Fixed visa dashboard joins (separated queries)
  5. βœ… Fixed radar service (raw SQL for global data)

πŸ“„ License

MIT License - See LICENSE file for details

πŸ™ Acknowledgments

  • AI Models: Google Gemma-3-27B-IT (open-source), Gemini 1.5 Flash
  • Frameworks: NestJS, Next.js 14, Prisma, BullMQ, Playwright
  • Inspiration: UK compliance frameworks (CQC, Home Office, Ofsted)
  • Database: PostgreSQL Row-Level Security implementation

🀝 Contributing

This is a portfolio project demonstrating production-grade patterns:

  • Fail-closed multi-tenancy with database-level isolation
  • Adversarial AI prompting with structured reasoning
  • Dual-hub architecture with unified reporting
  • Cryptographic audit trails with hash-chain integrity
  • Comprehensive testing with quality gates
  • WCAG AAA accessible UI design

For questions or feedback, see the documentation files listed above.


Built with adversarial rigor πŸ” | Secured with fail-closed design πŸ”’ | Powered by Gemma-3-27B + Gemini 1.5 πŸ€– | 10,000+ LOC πŸ“Š

System Status: 🟒 OPERATIONAL | v3.0 Complete | 40 Tests Passing | Quality Gates Active | Production-Ready


Last Updated: December 10, 2025 | Version: 3.0.0 | Commit: f83f877

About

AI-powered compliance platform for UK care homes - CQC analysis, visa tracking, fraud detection, RLS multi-tenancy

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages