# rfypych/wvfe architecture

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

- Interactive diagram: https://gitdiagram.com/rfypych/wvfe
- Repository: https://github.com/rfypych/wvfe

## Overview

##### Project type and purpose
- WVFE is a full-stack, monorepo web application combining a React.js frontend with a Flask/Python backend and a MySQL database.
- Its purpose is to automate discovery and demonstration of common web vulnerabilities (sensitive files, SQLi, XSS) via a user-driven scan dashboard.

##### File structure
- Top-level “frontend” directory holds a React SPA:
- public/index.html
- src/App.js, pages/{Login,Register,Dashboard,ScanDetail}
- Top-level “backend” directory holds a Flask API:
- app.py (entry point)
- scanners/ (modular vulnerability scanners: crawler, sensitive_file_scanner, sqli_scanner, xss_scanner)
- templates/index.html (optional server-side page)
- .env.example, requirements.txt, tests/
- No separate microservices—everything lives in one Flask process.
- Tests cover each scanner module and auth/scan endpoints.

##### README for additional insights
- Backend → Flask on port 5001; database auto-created on first run.
- Frontend → React dev server on port 3000.
- MySQL backend managed via environment variables.
- Emphasis on user authentication, web crawling, modular vulnerability detection.

##### Main components and relationships
a. User Interface (React SPA)
– Components: LoginPage, RegisterPage, DashboardPage, ScanDetailPage
– Connects to Flask API over HTTP(S).
b. API Layer (Flask app.py)
– Endpoints: /auth/register, /auth/login, /scans/start, /scans/{id}/report, etc.
– Orchestrates scan tasks by invoking scanner modules.
c. Scanner Modules (in-memory workers)
– Web Crawler: discovers links/forms on target.
– Sensitive File Scanner: probes for .env, .git/config, etc.
– SQLi & XSS Scanners: test parameters for vulnerabilities.
d. Database (MySQL)
– Tables: users, scans, findings.
– Accessed via an ORM or raw queries inside Flask.
e. External Service
– Target Web Application: arbitrary external site under test.

##### Architectural patterns and design principles
- Monolithic backend with modular scanner plugins (Plugin Pattern).
- Clear separation of concerns: UI ↔ API ↔ Scanning logic ↔ Persistence.
- Stateless API end points; database-backed state; scanner modules process per request.
- MVC-like division in Flask (views in app.py, scanner “models” in scanners directory).

- Environment configuration by an ancillary note: “Flask reads .env → DB_HOST, SECRET_KEY.”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        IndexJS["Index (frontend/src/index.js)"]:::frontend
        AppJS["App (frontend/src/App.js)"]:::frontend
        LoginPage["LoginPage (frontend/src/pages/LoginPage.js)"]:::frontend
        RegisterPage["RegisterPage (frontend/src/pages/RegisterPage.js)"]:::frontend
        DashboardPage["DashboardPage (frontend/src/pages/DashboardPage.js)"]:::frontend
        ScanDetailPage["ScanDetailPage (frontend/src/pages/ScanDetailPage.js)"]:::frontend

        IndexJS -->|"loads"| AppJS
        AppJS -->|"routes to"| LoginPage
        AppJS -->|"routes to"| RegisterPage
        AppJS -->|"routes to"| DashboardPage
        AppJS -->|"routes to"| ScanDetailPage
    end

    %% Backend Layer
    subgraph "Backend (Flask API)" 
        direction TB
        API["Flask API (app.py)"]:::backend
        ENVNOTE["Reads .env → DB_HOST, SECRET_KEY"]:::note
        API -->|".env config"| ENVNOTE
    end

    %% Scanner Modules
    subgraph "Scanner Modules"
        direction TB
        Crawler["Crawler Module"]:::scanner
        SensitiveFile["Sensitive File Scanner"]:::scanner
        SQLi["SQL Injection Scanner"]:::scanner
        XSS["XSS Scanner"]:::scanner
    end

    %% Persistence Layer
    subgraph "Persistence (MySQL Database)"
        direction TB
        DB["MySQL Database\n(users, scans, findings)"]:::db
    end

    %% External Target
    External["External Target\n(Arbitrary Web App)"]:::external

    %% Connections
    AppJS -->|"HTTP(S) Requests"| API
    API -->|"SQL Queries"| DB
    API -.->|"invokes"| Crawler
    API -.->|"invokes"| SensitiveFile
    API -.->|"invokes"| SQLi
    API -.->|"invokes"| XSS

    Crawler -.->|"HTTP Crawl"| External
    SensitiveFile -.->|"HTTP Probes"| External
    SQLi -.->|"Injection Tests"| External
    XSS -.->|"Injection Tests"| External

    External -->|"HTTP Responses"| Crawler
    External -->|"HTTP Responses"| SensitiveFile
    External -->|"HTTP Responses"| SQLi
    External -->|"HTTP Responses"| XSS

    %% Click Events
    click IndexJS "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/index.js"
    click AppJS "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/App.js"
    click LoginPage "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/pages/LoginPage.js"
    click RegisterPage "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/pages/RegisterPage.js"
    click DashboardPage "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/pages/DashboardPage.js"
    click ScanDetailPage "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/frontend/src/pages/ScanDetailPage.js"
    click API "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/app.py"
    click Crawler "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/scanners/crawler.py"
    click SensitiveFile "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/scanners/sensitive_file_scanner.py"
    click SQLi "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/scanners/sqli_scanner.py"
    click XSS "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/scanners/xss_scanner.py"
    click ENVNOTE "https://github.com/rfypych/wvfe/blob/refactor/monorepo-structure/backend/.env.example"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef scanner fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef note fill:#d1ecf1,stroke:#0c5460,color:#0c5460,stroke-dasharray: 5 5
```
