# dinakar-s/aimed-compliance architecture

> Architecture diagram of the GitHub repository dinakar-s/aimed-compliance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dinakar-s/aimed-compliance
- Repository: https://github.com/dinakar-s/aimed-compliance

## Overview

##### Project Type and Purpose
- The project is a full-stack web application focused on the healthcare domain. It evaluates AI-generated responses for accuracy, compliance (HIPAA, GDPR, ethical standards), bias, and security issues.
- The README clearly outlines several modules like a Medical Chatbot, AI Model Comparison, Compliance Checker, Bias Detector, and Security Module. Although it relies on external AI API calls (via OpenRouter.ai), most logic is handled in the frontend.
- The purpose is to empower healthcare institutions with a tool that “ensures AI safety” before deployment by providing multi-faceted testing and reporting functionality.

##### File Structure
- There is a mix of top-level files (App.jsx, api.js, index.html, etc.) and a well-organized source structure under the “src” directory.
- “src/components”, “src/pages”, and “src/utils” indicate that the application is built in a modular way:
- Components: Reusable UI elements for various parts like Chat, Navbar, Controls, HospitalFinder, etc.
- Pages: Specific application pages such as Home, Chatbot, ComplianceChecker, AIModelComparison, etc.
- Utils and Data: Contain helper modules for bias detection, compliance checking, security evaluation, and local datasets (CSV and JSON) that drive the comparisons and analysis.
- The “assistants” directory in “src” houses integrations with different AI providers (deepseekai, googleai, openai), suggesting a plug-and-play approach to handling AI service calls.
- Configuration files like vite.config.js, package.json, and .env exist, which support building and deployment using modern tooling (React, Vite).

##### Main Components
a. Frontend User Interface
- React Components & Pages: Covering layout, navigation (Navbar, Header, Footer), and individual functionality (Chat, HospitalFinder, AI Comparison).
- Styling: Managed via modules (module.css files) and global CSS.
- Data Interaction: Pages trigger various functionalities such as chat processing and report generation.

b. API Communication Module
- API files (api.js in root, src/api/aiModels.js) that wrap calls to external services. These encapsulate interactions with the LLM-based backend (OpenRouter.ai).

c. AI Service Integrations
- “src/assistants” folder holds helper scripts to interact with multiple AI models/providers (Google AI, DeepSeek, OpenAI). This layer represents the modular integration point with external AI engines.

d. Data Management & Utility Modules
- “src/data” and “src/utils” contain training data, evaluation logic, and scripts for compliance, bias, and security checks.
- CSV and JSON data (e.g., train.csv, medical-qna.json) are fed into evaluation processes.

e. PDF Report Generation Module
- Utilizes libraries like jsPDF (as noted in the README) for creating audit reports based on evaluation results.

f. External Services & Deployment
- The external AI service (OpenRouter.ai) is a key dependency.
- Deployment on Vercel shows how the frontend is hosted, with GitHub as source control.

##### Relationships and Interactions
- End-user interactions begin at the UI (via browser) – e.g., the user submits a query through the Medical Chatbot.
- The UI sends a request through internal API modules which handle routing and aggregation of responses from the various AI service integrations.
- These API modules process the response through internal utilities (complianceChecker, biasDetection, securityCheck) before rendering the final output.
- For features like PDF Export or AI Model Comparison, the data flows from the evaluation modules, is formatted appropriately, and then passed to the rendering or export component.
- There’s also a clear separation between authenticated modules (ClerkAuth and related components) and public accessible pages, indicating a security-layer integration.

- “User Interface (React components & pages)” for the front-end layer.
- “API Communication Module” for files such as api.js and modules under /src/api.
- “AI Integration Assistants” representing the multiple AI providers.
- “Evaluation & Utility Modules” capturing compliance, security, bias detection utilities.
- “Data Store” as a generic component for training data and configuration files.
- “External Services” block for OpenRouter.ai and deployment (Vercel).
- From UI → API Communication → AI Assistant modules → Evaluation/Utility modules → UI Response.
- Notes where necessary, like “Compliance Checks (HIPAA, GDPR)” in the evaluation module, or “PDF Report Generation” indicating the use of jsPDF.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level User
    USER("User (Browser)"):::external

    %% Frontend User Interface Subgraph
    subgraph "Frontend User Interface"
        UI1("React App"):::ui
        UI2("Components"):::ui
        UI3("Pages"):::ui
    end

    %% Authentication & Security Layer Subgraph
    subgraph "Authentication & Security Layer"
        AUTH1("ClerkAuth"):::auth
        AUTH2("Auth Components"):::auth
    end

    %% API Communication Module Subgraph
    subgraph "API Communication Module"
        API1("api.js"):::api
        API2("AI Models API"):::api
    end

    %% AI Service Integrations Subgraph
    subgraph "AI Service Integrations"
        AI1("DeepSeek AI"):::ai
        AI2("Google AI"):::ai
        AI3("Open AI"):::ai
    end

    %% Evaluation & Utility Modules Subgraph
    subgraph "Evaluation & Utility Modules"
        UTIL1("Data Store"):::util
        UTIL2("Utilities"):::util
        UTIL3("PDF Report Generation"):::util
    end

    %% External Services Subgraph
    subgraph "External Services"
        EXT1("OpenRouter.ai"):::external
        EXT2("Vercel"):::external
    end

    %% Data Flow Connections
    USER -->|"initiates"| UI1
    UI1 -->|"sends request"| API1
    API1 -->|"routes request"| API2
    API2 -->|"calls"| AI1
    API2 -->|"calls"| AI2
    API2 -->|"calls"| AI3
    API2 -->|"external call"| EXT1
    AI1 -->|"response flows"| UTIL2
    AI2 -->|"response flows"| UTIL2
    AI3 -->|"response flows"| UTIL2
    UTIL1 -->|"provides data"| UTIL2
    UTIL2 -->|"formats report"| UTIL3
    UTIL2 -->|"sends results"| UI1
    UI1 -->|"hosted on"| EXT2

    %% Authentication Flow
    UI1 -.->|"auth check"| AUTH1
    AUTH1 -->|"validates via"| AUTH2
    AUTH2 -->|"grants access to"| UI1

    %% Click Events
    click UI1 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/App.jsx"
    click UI2 "https://github.com/dinakar-s/aimed-compliance/tree/main/src/components"
    click UI3 "https://github.com/dinakar-s/aimed-compliance/tree/main/src/pages"
    click API1 "https://github.com/dinakar-s/aimed-compliance/blob/main/api.js"
    click API2 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/api/aiModels.js"
    click AI1 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/assistants/deepseekai.js"
    click AI2 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/assistants/googleai.js"
    click AI3 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/assistants/openai.js"
    click UTIL1 "https://github.com/dinakar-s/aimed-compliance/tree/main/src/data"
    click UTIL2 "https://github.com/dinakar-s/aimed-compliance/tree/main/src/utils"
    click UTIL3 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/utils/reportGenerator.js"
    click AUTH1 "https://github.com/dinakar-s/aimed-compliance/blob/main/src/clerkAuth.jsx"
    click AUTH2 "https://github.com/dinakar-s/aimed-compliance/tree/main/src/components/Authentication"

    %% Styles
    classDef ui fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef api fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef ai fill:#FFCC80,stroke:#000,stroke-width:1px;
    classDef util fill:#FFB74D,stroke:#000,stroke-width:1px;
    classDef auth fill:#CE93D8,stroke:#000,stroke-width:1px;
    classDef external fill:#EF9A9A,stroke:#000,stroke-width:1px;
```
