# mohitsharma-2007/aegisai architecture

> Architecture diagram of the GitHub repository mohitsharma-2007/aegisai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohitsharma-2007/aegisai
- Repository: https://github.com/mohitsharma-2007/aegisai

## Overview

##### Project Type and Purpose
- This is a full-stack security simulation tool called AEGIS-AI.

##### High-Level File Structure Analysis
- Top-level “frontend/” – static web UI (HTML, CSS, JS), bundled via Vite (see .vite/, node_modules/).
- Top-level “backend/” – Python Flask monolith (app.py), script engine, AI-SCRIPT folder for per-model implementations, detection logic, downloaded example scripts.
- Config & tooling: package.json for frontend dependencies, various SCRIPT_*.md docs, VSCode settings.

##### Key Insights from README
- Frontend: console.html, dashboards, script management pages, uses AJAX/Fetch to call Flask API.
- Backend: a Flask API server (port 5050), loading attack scripts via BaseScript, calling external LLM services (OpenAI, Claude, Gemini), running detection algorithms, returning JSON results.
- Deployment: simple HTTP server for static files (port 8080) + Flask server.

##### Components
a. Frontend Layer
- Browser clients → static HTTP server (serving HTML/CSS/JS).
- UI modules: Console Interface, Dashboard, Script Management pages.
- Script-bridge and console-functions JS call REST endpoints.
b. Backend Layer
- Flask API Server (app.py)
- Script Manager / Loader
- Attack Simulation Modules:
- AI-SCRIPT (Claude, GPT, Gemini)
- Web/DDoS/Bot/Recon scripts under backend/scripts
- Detection Engine (ai_detection.py)
- External Services: OpenAI API, Anthropic Claude, Google Gemini
- Downloaded third-party scripts
c. Data Stores & Artifacts
- In-memory or file-based logs (honeypot_dashboard, logs.html)
- Static config (honeypots.json)
d. External Integrations
- Third-party LLM APIs
- Optional browser-launched static server

##### Relationships & Data Flow
1. User selects an attack in the browser UI
2. Frontend JS → HTTP POST to Flask endpoint (/run_attack, /test_detection, etc.)
3. Flask receives request → Script Manager loads target script
4. Attack Simulation module executes (locally or via external LLM API)
5. Detection Engine observes, simulates blocking, records events
6. Flask returns JSON results & logs
7. Frontend updates console/dashboard in real time
8. For dashboards, frontend polls logs endpoints or receives push updates

##### Architectural Patterns & Design Principles
- Monolithic backend exposing RESTful API
- Modular script architecture: plugin pattern (BaseScript subclasses)
- Separation of concerns: UI layer vs. API vs. script implementations vs. detection logic
- Extensibility: easily add new scripts in categorized directories

##### Technologies & Frameworks to Annotate
- Frontend: HTML5, CSS3, Vanilla JavaScript, Vite bundler
- Backend: Python 3.8+, Flask, custom script loader
- External APIs: OpenAI, Anthropic, Google Gemini
- Deployment: Python HTTP server, Windows batch script

##### Elements
- Component labels (e.g., “Console UI”, “Flask API Server”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FA["Static HTTP Server (port 8080)"]:::frontend
        CI["Console Interface"]:::frontend
        DB["Dashboard UI"]:::frontend
        HD["Honeypot Dashboard"]:::frontend
        SM["Script Management Page"]:::frontend
        CF["console-functions.js"]:::frontend
        SB["script-bridge.js"]:::frontend
        LS["local-scripts.js"]:::frontend
        ME["main.js"]:::frontend
        LV["Logs Viewer"]:::frontend
        HC["honeypots.json"]:::datastore
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        API["Flask API Server (app.py)"]:::backend
        SMgr["Script Manager/Loader"]:::backend
        DET["Detection Engine"]:::backend
        AS["AI-SCRIPT Modules"]:::backend
        SCRIPTS["Attack Scripts"]:::backend
        DLS["Downloaded Third-Party Scripts"]:::backend
        LOGFS["Logs Store"]:::datastore
    end

    %% AI-SCRIPT Plugin Folders
    subgraph "AI-SCRIPT Plugin Folders"
        direction TB
        Claude["Claude"]:::backend
        GPT["GPT"]:::backend
        Gemini["Gemini"]:::backend
    end
    AS --> Claude
    AS --> GPT
    AS --> Gemini

    %% External LLM Services
    subgraph "External LLM Services"
        direction TB
        OpenAI["OpenAI API"]:::external
        ClaudeSvc["Anthropic Claude"]:::external
        GeminiSvc["Google Gemini"]:::external
    end

    %% Data Flows
    CI -->|"POST /run_attack"| API
    DB -->|"GET /logs"| API
    HD -->|"GET /honeypot_logs"| API
    SM -->|"POST /scripts"| API

    API --> SMgr
    SMgr --> SCRIPTS
    SMgr --> AS
    SCRIPTS --> DET
    AS --> APICode["openai_api.py"]:::backend
    APICode --> OpenAI
    AS --> ClaudeSvc
    AS --> GeminiSvc
    DET --> LOGFS
    LOGFS --> DB
    LOGFS --> HD
    API -->|"JSON response"| CI
    API -->|"JSON response"| DB
    API -->|"JSON response"| HD
    API -->|"JSON response"| SM

    %% Click Events
    click FA "https://github.com/mohitsharma-2007/aegisai/tree/main/frontend/"
    click CI "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/console.html"
    click DB "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/dashboard.html"
    click HD "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/honeypot_dashboard.html"
    click SM "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/script_management.html"
    click CF "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/js/console-functions.js"
    click SB "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/js/script-bridge.js"
    click LS "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/js/local-scripts.js"
    click ME "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/main.js"
    click LV "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/logs.html"
    click HC "https://github.com/mohitsharma-2007/aegisai/blob/main/frontend/honeypots.json"
    click API "https://github.com/mohitsharma-2007/aegisai/blob/main/backend/app.py"
    click DET "https://github.com/mohitsharma-2007/aegisai/blob/main/backend/ai_detection.py"
    click SMgr "https://github.com/mohitsharma-2007/aegisai/blob/main/backend/app.py"
    click AS "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/AI-SCRIPT/"
    click Claude "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/AI-SCRIPT/Claude/"
    click GPT "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/AI-SCRIPT/GPT/"
    click Gemini "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/AI-SCRIPT/Gemini/"
    click SCRIPTS "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/scripts/"
    click DLS "https://github.com/mohitsharma-2007/aegisai/tree/main/backend/downloaded_scripts/"
    click APICode "https://github.com/mohitsharma-2007/aegisai/blob/main/backend/openai_api.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef datastore fill:#E6E6FA,stroke:#000,stroke-width:1px
```
