# manoj-gif-b/healthsecure_ai architecture

> Architecture diagram of the GitHub repository manoj-gif-b/healthsecure_ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manoj-gif-b/healthsecure_ai
- Repository: https://github.com/manoj-gif-b/healthsecure_ai

## Overview

HealthSecureAI screens healthcare documents for prompt injection, combines explainable rules with an offline text classifier, and allows, reviews, or blocks downstream AI processing. The Streamlit app implements this workflow directly; a separate FastAPI backend exposes a similar analysis and logs API. Both paths produce risk explanations and event records. The README was empty, so this map relies on the supplied source excerpts and index; the optional real-model integration is documented but unimplemented.

Main entry points: [`HealthSecureAI/backend/main.py`](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/main.py) (FastAPI analysis), [`HealthSecureAI/app.py`](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/app.py) (Streamlit workflow), [`HealthSecureAI/backend/logger.py`](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/logger.py) (Event logger), [`HealthSecureAI/backend/security_engine.py`](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/security_engine.py) (Threat rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_streamlit["Streamlit workflow<br/>[app.py]"]
end

subgraph group_analysis["Risk Analysis"]
  node_rules["Threat rules<br/>[security_engine.py]"]
  node_classifier["Risk classifier<br/>[classifier.py]"]
end

subgraph group_processing["Safe Processing"]
  node_ai["AI handler<br/>[ai_handler.py]"]
  node_logger["Event logger<br/>[logger.py]"]
  node_logfile[("JSON event log")]
end

subgraph group_service["API Service"]
  node_api["FastAPI analysis<br/>[main.py]"]
  node_schemas["API schemas<br/>[models.py]"]
end

node_user(("Document user"))

node_user -->|"submits document"| node_streamlit
node_streamlit -->|"scans text"| node_rules
node_streamlit -->|"estimates risk"| node_classifier
node_streamlit -->|"forwards allowed text"| node_ai
node_streamlit -->|"records event"| node_logger
node_streamlit -->|"reads recent events"| node_logger
node_logger -->|"reads and appends"| node_logfile
node_user -->|"posts analysis"| node_api
node_api -->|"scans text"| node_rules
node_api -->|"estimates risk"| node_classifier
node_api -->|"forwards allowed text"| node_ai
node_api -->|"records event"| node_logger
node_api -->|"reads log entries"| node_logger
node_api -->|"validates and shapes"| node_schemas

click node_streamlit "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/app.py"
click node_rules "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/security_engine.py"
click node_classifier "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/classifier.py"
click node_ai "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/ai_handler.py"
click node_logger "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/logger.py"
click node_api "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/main.py"
click node_schemas "https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/models.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_streamlit,node_user toneBlue
class node_rules,node_classifier toneAmber
class node_ai,node_logger,node_logfile toneMint
class node_api,node_schemas toneRose
```

## Components

### User Interface

- [Streamlit workflow](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/app.py): `HealthSecureAI/app.py`

### Risk Analysis

- [Threat rules](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/security_engine.py): `HealthSecureAI/backend/security_engine.py`
- [Risk classifier](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/classifier.py): `HealthSecureAI/backend/classifier.py`

### Safe Processing

- [AI handler](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/ai_handler.py): `HealthSecureAI/backend/ai_handler.py`
- [Event logger](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/logger.py): `HealthSecureAI/backend/logger.py`
- **JSON event log**

### API Service

- [FastAPI analysis](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/main.py): `HealthSecureAI/backend/main.py`
- [API schemas](https://github.com/manoj-gif-b/healthsecure_ai/blob/main/HealthSecureAI/backend/models.py): `HealthSecureAI/backend/models.py`

### Other components

- **Document user**

## Connections

- Document user → Streamlit workflow: submits document (evidence: `HealthSecureAI/app.py`)
- Streamlit workflow → Threat rules: scans text (evidence: `HealthSecureAI/app.py`)
- Streamlit workflow → Risk classifier: estimates risk (evidence: `HealthSecureAI/app.py`)
- Streamlit workflow → AI handler: forwards allowed text (evidence: `HealthSecureAI/app.py`)
- Streamlit workflow → Event logger: records event (evidence: `HealthSecureAI/app.py`)
- Streamlit workflow → Event logger: reads recent events (evidence: `HealthSecureAI/app.py`)
- Event logger → JSON event log: reads and appends (evidence: `HealthSecureAI/backend/logger.py`)
- Document user → FastAPI analysis: posts analysis (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → Threat rules: scans text (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → Risk classifier: estimates risk (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → AI handler: forwards allowed text (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → Event logger: records event (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → Event logger: reads log entries (evidence: `HealthSecureAI/backend/main.py`)
- FastAPI analysis → API schemas: validates and shapes (evidence: `HealthSecureAI/backend/main.py`)
