# shreekamesh/input-security-layer architecture

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

- Interactive diagram: https://gitdiagram.com/shreekamesh/input-security-layer
- Repository: https://github.com/shreekamesh/input-security-layer

## Overview

Security Gateway is a Flask SOC application: incoming requests are intercepted and analyzed, threats are scored and either blocked or remediated, and each outcome is logged for operational review. The dashboard and JSON endpoints expose threat history, lifecycle stages, and system-health metrics; a demo route seeds sample events. Image analysis includes binary-signature checks and hypothesis-based handling of entropy signals. The graph reflects the shown gateway, analysis, persistence, and UI code plus README-documented capabilities; unsampled template and route internals are not inferred.

Main entry points: [`app.py`](https://github.com/shreekamesh/input-security-layer/blob/main/app.py) (Security Gateway), [`src/ai_decision.py`](https://github.com/shreekamesh/input-security-layer/blob/main/src/ai_decision.py) (Decision Engine), [`src/db.py`](https://github.com/shreekamesh/input-security-layer/blob/main/src/db.py) (Threat Log Store), [`src/scanner.py`](https://github.com/shreekamesh/input-security-layer/blob/main/src/scanner.py) (Input Scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Request Ingress"]
  node_gateway["Security Gateway<br/>[app.py]"]
  node_config["Threat Configuration<br/>[config.py]"]
end

subgraph group_analysis["Threat Analysis"]
  node_decision["Decision Engine<br/>[ai_decision.py]"]
  node_scanner["Input Scanner<br/>[scanner.py]"]
  node_hypotheses["Image Hypotheses<br/>[scanner.py]"]
  node_remediation["Input Remediation<br/>[fixer.py]"]
end

subgraph group_records["SOC Records"]
  node_event_logger["Event Logger<br/>[db.py]"]
  node_log_store[("Threat Log Store<br/>[db.py]")]
end

subgraph group_operations["SOC Operations"]
  node_dashboard_route["Dashboard Route<br/>[app.py]"]
  node_logs_api["Threat Logs API<br/>[app.py]"]
  node_health_api["System Health API<br/>[app.py]"]
  node_demo_route["Demo Event Seeder<br/>[app.py]"]
  node_timeline["Lifecycle View<br/>[app.py]"]
end

subgraph group_interface["User Interface"]
  node_dashboard["SOC Dashboard<br/>[dashboard.html]"]
  node_login_ui["Login Interface<br/>[index.html]"]
  node_browser_script["Form Interaction<br/>[script.js]"]
  node_demo_ui["Demo Interface<br/>[demo.html]"]
end

node_user(("Request User"))

node_user -->|"submits request"| node_gateway
node_browser_script -->|"posts form"| node_gateway
node_gateway -->|"processes input"| node_decision
node_decision -->|"scans input"| node_scanner
node_decision -->|"checks threshold"| node_config
node_scanner -->|"uses patterns"| node_config
node_scanner -->|"tests images"| node_hypotheses
node_decision -->|"fixes input"| node_remediation
node_decision -->|"logs outcome"| node_event_logger
node_gateway -->|"initializes store"| node_event_logger
node_event_logger -->|"writes events"| node_log_store
node_gateway -->|"reads logs"| node_log_store
node_gateway -->|"seeds demo events"| node_log_store
node_user -->|"opens dashboard"| node_dashboard_route
node_dashboard_route -->|"renders view"| node_dashboard
node_dashboard_route -->|"derives stages"| node_timeline
node_timeline -->|"supplies stages"| node_dashboard
node_user -->|"requests logs"| node_logs_api
node_logs_api -->|"reads records"| node_log_store
node_user -->|"requests health"| node_health_api
node_health_api -->|"queries metrics"| node_log_store
node_user -->|"requests demo"| node_demo_route
node_demo_route -->|"renders demo"| node_demo_ui
node_demo_ui -.->|"submits demo"| node_demo_route
node_gateway -->|"renders login"| node_login_ui
node_login_ui -.->|"uses interaction"| node_browser_script

click node_gateway "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_config "https://github.com/shreekamesh/input-security-layer/blob/main/config.py"
click node_decision "https://github.com/shreekamesh/input-security-layer/blob/main/src/ai_decision.py"
click node_scanner "https://github.com/shreekamesh/input-security-layer/blob/main/src/scanner.py"
click node_hypotheses "https://github.com/shreekamesh/input-security-layer/blob/main/src/scanner.py"
click node_remediation "https://github.com/shreekamesh/input-security-layer/blob/main/src/fixer.py"
click node_event_logger "https://github.com/shreekamesh/input-security-layer/blob/main/src/db.py"
click node_log_store "https://github.com/shreekamesh/input-security-layer/blob/main/src/db.py"
click node_dashboard_route "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_logs_api "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_health_api "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_demo_route "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_timeline "https://github.com/shreekamesh/input-security-layer/blob/main/app.py"
click node_dashboard "https://github.com/shreekamesh/input-security-layer/blob/main/templates/dashboard.html"
click node_login_ui "https://github.com/shreekamesh/input-security-layer/blob/main/templates/index.html"
click node_browser_script "https://github.com/shreekamesh/input-security-layer/blob/main/static/script.js"
click node_demo_ui "https://github.com/shreekamesh/input-security-layer/blob/main/templates/demo.html"

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_gateway,node_config,node_user toneBlue
class node_decision,node_scanner,node_hypotheses,node_remediation toneAmber
class node_event_logger,node_log_store toneMint
class node_dashboard_route,node_logs_api,node_health_api,node_demo_route,node_timeline toneRose
class node_dashboard,node_login_ui,node_browser_script,node_demo_ui toneIndigo
```

## Components

### Request Ingress

- [Security Gateway](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`
- [Threat Configuration](https://github.com/shreekamesh/input-security-layer/blob/main/config.py): `config.py`

### Threat Analysis

- [Decision Engine](https://github.com/shreekamesh/input-security-layer/blob/main/src/ai_decision.py): `src/ai_decision.py`
- [Input Scanner](https://github.com/shreekamesh/input-security-layer/blob/main/src/scanner.py): `src/scanner.py`
- [Image Hypotheses](https://github.com/shreekamesh/input-security-layer/blob/main/src/scanner.py): `src/scanner.py`
- [Input Remediation](https://github.com/shreekamesh/input-security-layer/blob/main/src/fixer.py): `src/fixer.py`

### SOC Records

- [Event Logger](https://github.com/shreekamesh/input-security-layer/blob/main/src/db.py): `src/db.py`
- [Threat Log Store](https://github.com/shreekamesh/input-security-layer/blob/main/src/db.py): `src/db.py`

### SOC Operations

- [Dashboard Route](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`
- [Threat Logs API](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`
- [System Health API](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`
- [Demo Event Seeder](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`
- [Lifecycle View](https://github.com/shreekamesh/input-security-layer/blob/main/app.py): `app.py`

### User Interface

- [SOC Dashboard](https://github.com/shreekamesh/input-security-layer/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Login Interface](https://github.com/shreekamesh/input-security-layer/blob/main/templates/index.html): `templates/index.html`
- [Form Interaction](https://github.com/shreekamesh/input-security-layer/blob/main/static/script.js): `static/script.js`
- [Demo Interface](https://github.com/shreekamesh/input-security-layer/blob/main/templates/demo.html): `templates/demo.html`

### Other components

- **Request User**

## Connections

- Request User → Security Gateway: submits request (evidence: `README.md`)
- Form Interaction → Security Gateway: posts form (evidence: `static/script.js`)
- Security Gateway → Decision Engine: processes input (evidence: `app.py`)
- Decision Engine → Input Scanner: scans input (evidence: `src/ai_decision.py`)
- Decision Engine → Threat Configuration: checks threshold (evidence: `src/ai_decision.py`)
- Input Scanner → Threat Configuration: uses patterns (evidence: `src/scanner.py`)
- Input Scanner → Image Hypotheses: tests images (evidence: `src/scanner.py`)
- Decision Engine → Input Remediation: fixes input (evidence: `src/ai_decision.py`)
- Decision Engine → Event Logger: logs outcome (evidence: `src/ai_decision.py`)
- Security Gateway → Event Logger: initializes store (evidence: `app.py`)
- Event Logger → Threat Log Store: writes events (evidence: `src/db.py`)
- Security Gateway → Threat Log Store: reads logs (evidence: `app.py`)
- Security Gateway → Threat Log Store: seeds demo events (evidence: `app.py`)
- Request User → Dashboard Route: opens dashboard (evidence: `README.md`)
- Dashboard Route → SOC Dashboard: renders view (evidence: `README.md`)
- Dashboard Route → Lifecycle View: derives stages (evidence: `app.py`)
- Lifecycle View → SOC Dashboard: supplies stages (evidence: `app.py`)
- Request User → Threat Logs API: requests logs (evidence: `README.md`)
- Threat Logs API → Threat Log Store: reads records (evidence: `app.py`)
- Request User → System Health API: requests health (evidence: `README.md`)
- System Health API → Threat Log Store: queries metrics (evidence: `app.py`)
- Request User → Demo Event Seeder: requests demo (evidence: `README.md`)
- Demo Event Seeder → Demo Interface: renders demo (evidence: `app.py`)
- Demo Interface → Demo Event Seeder: submits demo
- Security Gateway → Login Interface: renders login (evidence: `app.py`)
- Login Interface → Form Interaction: uses interaction
