# iaohkut/doan_iap401 architecture

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

- Interactive diagram: https://gitdiagram.com/iaohkut/doan_iap401
- Repository: https://github.com/iaohkut/doan_iap401

## Overview

##### Project Type and Purpose
- The README shows that this tool is meant for vulnerability testing and managing security scans.
- The installation instructions (pip install requirements, starting with “python3 app.py”) and use of Wappalyzer suggest that the tool gathers data from various scans.
- The project integrates multiple security tools (found in the “tool” directory) like Corsy, XSStrike, commix, sqlmap, etc., along with CSV upload capabilities.
- It also includes an “OpenAI” module, likely to assist vulnerability detection or analysis using AI.

##### File Structure
- Application Entry Point: “app.py” at the root starts the Flask web server.
- Configuration and Session Handling: “config.py” for configurations, “flask_session” for maintaining client sessions.
- Web UI Layer: “templates” and “static” directories indicate a clear separation of front-end presentation (HTML, CSS, JavaScript including “auth.js”).
- Core Logic and Scanning: The “src” directory contains main scripts such as “scan.py”, “unauthen.py”, “payload” files (suggesting predefined exploit payloads or rules) and both request/response sample files.
- External Tools Integration: The “tool” directory includes popular open-source scanners (e.g., sqlmap, dirsearch) that the backend might invoke.
- Data Persistence: SQLite databases (e.g., “database.db”, “Grrrrr-maindatabase.db”) and “schema.sql” provide the data storage layer.
- Reporting and Uploads: “reports” logs the outputs of the scans, while “Upload” has CSV files representing possibly imported scan data or targets.

##### Main Components
a. Client / User Interface:
- Browser accessing the application UI.
- Components: HTML templates (login, dashboard, project details) and static assets (CSS, images).
b. Web Application Server (Flask):
- Entry point “app.py”.
- Controllers (Flask routes) link the UI to the backend business logic.
- Session management via “flask_session”.
c. Core Vulnerability Management Module:
- Scan logic from the “src” directory (scan, payload processing, unauthenticated tests).
- Integration with the “OpenAI” module for vulnerability analysis.
d. External Vulnerability Scanners:
- The “tool” directory includes modules such as Corsy, XSStrike, commix, sqlmap, etc.
- The application likely invokes these scanners via subprocesses or API calls.
e. Database / Storage Layer:
- SQLite databases used for storing user data, scan results, logs, and configurations.
- Schema definitions provided in “schema.sql”.
f. Data Import/Export and Reporting:
- “Upload” directory for input CSV data.
- “reports” directory storing scan result logs that might later be parsed and displayed in the UI.
g. Configuration and Deployment:
- “Procfile”, “requirements.txt”, “runtime.txt”, and “vercel.json” for deployment and environment settings.

##### Relationships and Interactions
- The User sends requests from the browser to the Flask web server.
- The controller routes in Flask (defined in app.py and within “src”) handle requests, managing user sessions and processing inputs.
- The backend then initiates scans by calling modules from the “src” directory or launching external scanners from the “tool” folder.
- As scans run, results are stored in the “database.db” and logged in “reports”.
- The OpenAI component may be called to further analyze vulnerabilities from scan data.
- Finally, the results are rendered back to the user via the templates.

##### Architectural Patterns and Principles
- MVC Pattern: The separation of views (templates, static), controllers (Flask routes in app.py), and models (database, schema.sql) is evident.
- Modular Integration: External tools and AI components are modularized in separate directories for clear dependency management.
- Extensibility: The presence of an “Upload” module (for CSVs) and reports allows for easy extension by adding new data sources or scan types.

##### Additional Detailed Elements
- How CSV Uploads feed into the scan module, possibly invoking scan tasks.
- Session management as a detail within the web server component, linking user authentication (see “auth.js” and login templates).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    CB["Client Browser"]:::client

    %% Client / User Interface
    subgraph "Client / User Interface"
        UI1["HTML Templates"]:::ui
        UI2["Static Assets"]:::ui
        UI3["auth.js"]:::ui
    end

    %% Web Application Server (Flask)
    subgraph "Web Application Server"
        WS1["Flask Entry Point"]:::backend
        WS2["Configuration (config.py)"]:::backend
        WS3["Session Management (flask_session)"]:::backend
    end

    %% Vulnerability Management Module
    subgraph "Vulnerability Management Module"
        VM1["Scan Logic"]:::vuln
        VM2["OpenAI Integration"]:::vuln
    end

    %% External Vulnerability Scanners
    subgraph "External Vulnerability Scanners"
        ES1["Scanner Tools"]:::external
    end

    %% Database & Storage
    subgraph "Database & Storage"
        DB1["SQLite Databases"]:::database
        DB2["Schema Definition"]:::database
    end

    %% Data Import/Export & Reporting
    subgraph "Data Import/Export & Reporting"
        DE1["CSV Uploads"]:::reporting
        DE2["Scan Reports/Logs"]:::reporting
    end

    %% Deployment & Configuration
    subgraph "Deployment & Configuration"
        DC1["Procfile"]:::deployment
        DC2["requirements.txt"]:::deployment
        DC3["runtime.txt"]:::deployment
        DC4["vercel.json"]:::deployment
    end

    %% Connections
    CB -->|"HTTP_Request"| WS1
    WS1 -->|"renders"| UI1
    WS1 -->|"manages"| WS3
    WS1 -->|"triggers_scan"| VM1
    DE1 -->|"uploads_data"| VM1
    VM1 -->|"calls_for_analysis"| VM2
    VM1 -->|"invokes"| ES1
    VM1 -->|"stores_results"| DB1
    VM1 -->|"logs_results"| DE2
    DB2 -->|"defines_schema"| DB1
    DC1 -->|"configures"| WS1
    DC2 -->|"configures"| WS1
    DC3 -->|"configures"| WS1
    DC4 -->|"configures"| WS1

    %% Class definitions for colors
    classDef client fill:#FFE6AA,stroke:#333,stroke-width:2px;
    classDef ui fill:#D0E6A5,stroke:#333,stroke-width:2px;
    classDef backend fill:#A2D2FF,stroke:#333,stroke-width:2px;
    classDef vuln fill:#FFB7B2,stroke:#333,stroke-width:2px;
    classDef external fill:#F3D250,stroke:#333,stroke-width:2px;
    classDef database fill:#F3A0A2,stroke:#333,stroke-width:2px;
    classDef reporting fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef deployment fill:#D3B0E0,stroke:#333,stroke-width:2px;

    %% Click Events
    click UI1 "https://github.com/iaohkut/doan_iap401/tree/main//templates"
    click UI2 "https://github.com/iaohkut/doan_iap401/tree/main//static"
    click UI3 "https://github.com/iaohkut/doan_iap401/blob/main//auth.js"
    click WS1 "https://github.com/iaohkut/doan_iap401/blob/main//app.py"
    click WS2 "https://github.com/iaohkut/doan_iap401/blob/main//config.py"
    click WS3 "https://github.com/iaohkut/doan_iap401/tree/main//flask_session"
    click VM1 "https://github.com/iaohkut/doan_iap401/tree/main//src"
    click VM2 "https://github.com/iaohkut/doan_iap401/tree/main//OpenAI"
    click ES1 "https://github.com/iaohkut/doan_iap401/tree/main//tool"
    click DB1 "https://github.com/iaohkut/doan_iap401/blob/main//database.db"
    click DB2 "https://github.com/iaohkut/doan_iap401/blob/main//schema.sql"
    click DE1 "https://github.com/iaohkut/doan_iap401/tree/main//Upload"
    click DE2 "https://github.com/iaohkut/doan_iap401/tree/main//reports"
    click DC1 "https://github.com/iaohkut/doan_iap401/tree/main//Procfile"
    click DC2 "https://github.com/iaohkut/doan_iap401/blob/main//requirements.txt"
    click DC3 "https://github.com/iaohkut/doan_iap401/blob/main//runtime.txt"
    click DC4 "https://github.com/iaohkut/doan_iap401/blob/main//vercel.json"
```
