# devtalent2030/securiscan architecture

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

- Interactive diagram: https://gitdiagram.com/devtalent2030/securiscan
- Repository: https://github.com/devtalent2030/securiscan

## Overview

##### Project Type and Purpose
- This is a full-stack, containerized web security vulnerability scanner (“SecuriScan”) that crawls and tests websites against the OWASP Top 10.
- It consists of a React/TypeScript Next.js frontend, a Flask/Python backend API, modular security‐testing utilities (SQLi, XSS, CSRF, etc.), persistence (e.g. PostgreSQL), and container/orchestration for deployment (Docker Compose, AWS/Vercel).

##### File Structure
- Top level:
- backend/ – Flask app, `app/` holds main `app.py`, route definitions and a `utils/` folder for each vulnerability scanner module.
- securiscan-frontend/ – Next.js v13+ app directory, with `app/` pages (dashboard routes per vulnerability), `components/` reusable reports/UI, API service (`api/scan.ts`).
- docker-compose.yml – multi‐service orchestration.
- docs/ – architecture, API specs, setup guides.
- Patterns:
- Modular backend (one module per OWASP test)
- Component‐based frontend (per‐test dashboard routes & report components)
- Containerized microservices style (frontend + backend as separate services)
- Standard API‐driven separation (REST endpoints called by React Query in frontend).

##### README for Insights
- Tech stack: Flask, BeautifulSoup, Scapy, Nmap, CloudWatch, Next.js, Tailwind, Chart.js, React Query, Docker, AWS/Vercel, JWT, PostgreSQL, AWS Secrets Manager.
- Key features: automated crawling, AI‐driven payloads, real‐time dashboards, RBAC.

a. Main Components
- Frontend Service (Next.js)
- Backend API Service (Flask)
- Vulnerability Scanner Modules (utils: SQLi, XSS, CSRF, SSRF, etc.)
- Website Crawler (BeautifulSoup/Requests)
- External Tools (Nmap, Scapy)
- Persistence Layer (PostgreSQL)
- Authentication & Secret Store (JWT, AWS Secrets Manager)
- Logging & Monitoring (Python Logging → CloudWatch)
- Orchestration Layer (Docker Compose, AWS EC2 / Vercel)
b. Relationships & Data Flows
1. User → Next.js frontend UI (React Query triggers)
2. Frontend → REST API endpoints (`/crawl`, `/check_sql`, etc.) over HTTPS
3. API Service
– orchestrates crawler module → collects URLs
– dispatches each scanner module (SQLi, XSS, etc.)
– invokes external tools (Nmap/Scapy) for deeper analysis
– persists results in PostgreSQL
– writes logs/metrics to CloudWatch
4. API → returns structured JSON or PDF/HTML reports
5. Frontend → renders real-time dashboards (Chart.js) & report components
c. Architectural Patterns & Principles
- Separation of concerns: distinct UI, API, scanner modules
- Modular plugin-style scanning utilities
- Stateless API + persistent data store
- Containerized deployment for portability & scaling
- Use of CI/CD (Docker Compose + AWS/Vercel)
- Secure configuration: HTTPS, JWT, RBAC, Secrets Manager
d. Key Technologies
- Frontend: Next.js (React+TS), React Query, Tailwind CSS, Material UI, Chart.js
- Backend: Flask, BeautifulSoup, Requests, Scapy, Nmap, Python Logging
- Infrastructure: Docker, Docker Compose, AWS EC2/S3/Secrets Manager, Vercel, PostgreSQL

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Docker Compose"
        direction TB
        subgraph "Frontend Service"
            direction TB
            NextJS["Next.js UI"]:::microservice
            click NextJS "https://github.com/devtalent2030/securiscan/tree/main/securiscan-frontend/"
            Layout["App Entry & Layout"]:::microservice
            click Layout "https://github.com/devtalent2030/securiscan/blob/main/securiscan-frontend/app/layout.tsx"
            Page["App Page Entry"]:::microservice
            click Page "https://github.com/devtalent2030/securiscan/blob/main/securiscan-frontend/app/page.tsx"
            ReactQuery["API Service (React Query)"]:::microservice
            click ReactQuery "https://github.com/devtalent2030/securiscan/blob/main/securiscan-frontend/app/api/scan.ts"
            subgraph "Dashboard Routes"
                direction TB
                Dashboard["Per-Vulnerability Routes"]:::microservice
                click Dashboard "https://github.com/devtalent2030/securiscan/tree/main/securiscan-frontend/app/dashboard/"
            end
            subgraph "UI Components"
                direction TB
                Components["Report & UI Components"]:::microservice
                click Components "https://github.com/devtalent2030/securiscan/tree/main/securiscan-frontend/app/components/"
                click Components "https://github.com/devtalent2030/securiscan/tree/main/securiscan-frontend/components/"
            end
        end
        subgraph "Backend Service"
            direction TB
            FlaskAPI["Flask API"]:::microservice
            click FlaskAPI "https://github.com/devtalent2030/securiscan/blob/main/backend/app/app.py"
            Dockerfile["Dockerfile & .dockerignore"]:::microservice
            click Dockerfile "https://github.com/devtalent2030/securiscan/tree/main/backend/Dockerfile"
            click Dockerfile "https://github.com/devtalent2030/securiscan/blob/main/backend/.dockerignore"
            subgraph "Scanner Modules"
                direction TB
                SQLi["SQL Injection"]:::modules
                click SQLi "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/sql_injection.py"
                NoSQL["NoSQL Injection"]:::modules
                click NoSQL "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/nosql_injection.py"
                XSS["XSS"]:::modules
                click XSS "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/xss.py"
                CSRF["CSRF"]:::modules
                click CSRF "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/csrf.py"
                SSRF["SSRF"]:::modules
                click SSRF "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/ssrf.py"
                CMDI["Command Injection"]:::modules
                click CMDI "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/command_injection.py"
                DirEnum["Directory Enumeration"]:::modules
                click DirEnum "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/directory_enum.py"
                DepScan["Dependency Scanner"]:::modules
                click DepScan "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/dependency_scanner.py"
                CryptoFail["Crypto Failures"]:::modules
                click CryptoFail "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/crypto_failures.py"
                BrokenAC["Broken Access Control"]:::modules
                click BrokenAC "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/broken_access.py"
                SecMisconfig["Security Misconfiguration"]:::modules
                click SecMisconfig "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/security_misconfig.py"
                AuthFail["Authentication Failures"]:::modules
                click AuthFail "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/auth_failures.py"
            end
            Crawler["Website Crawler"]:::modules
            click Crawler "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/crawler.py"
            DBUtil["DB Integration"]:::modules
            click DBUtil "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/database.py"
            Logging["Logging & Monitoring"]:::modules
            click Logging "https://github.com/devtalent2030/securiscan/blob/main/backend/app/utils/logging_monitor.py"
        end
    end

    User["User"] 
    SecretsManager["AWS Secrets Manager"]:::external
    JWT["JWT Auth & RBAC"]:::external
    Nmap["Nmap"]:::external
    Scapy["Scapy"]:::external
    DB["PostgreSQL"]:::storage
    CloudWatch["CloudWatch"]:::external

    User -->|uses| NextJS
    NextJS -->|renders UI & triggers| ReactQuery
    ReactQuery -->|HTTPS requests| FlaskAPI
    FlaskAPI -->|collects URLs| Crawler
    Crawler -->|feeds URLs| SQLi
    Crawler -->|feeds URLs| NoSQL
    Crawler -->|feeds URLs| XSS
    Crawler -->|feeds URLs| CSRF
    Crawler -->|feeds URLs| SSRF
    Crawler -->|feeds URLs| CMDI
    Crawler -->|feeds URLs| DirEnum
    Crawler -->|feeds URLs| DepScan
    Crawler -->|feeds URLs| CryptoFail
    Crawler -->|feeds URLs| BrokenAC
    Crawler -->|feeds URLs| SecMisconfig
    Crawler -->|feeds URLs| AuthFail
    FlaskAPI -->|invokes| Nmap
    FlaskAPI -->|invokes| Scapy
    FlaskAPI -->|persists results| DB
    FlaskAPI -->|logs metrics| Logging
    FlaskAPI -->|auth via JWT & AWS SM| SecretsManager
    Logging -->|sends logs| CloudWatch
    DBUtil -->|connects to| DB
    FlaskAPI -->|uses| DBUtil
    SecretsManager -->|provides secrets| FlaskAPI
    ReactQuery -->|receives JSON/PDF| NextJS

    subgraph "Documentation"
        direction TB
        ArchDoc["Architecture Docs"]:::external
        click ArchDoc "https://github.com/devtalent2030/securiscan/blob/main/docs/architecture.md"
        APIDoc["API Specs"]:::external
        click APIDoc "https://github.com/devtalent2030/securiscan/blob/main/docs/api-specifications.md"
        SetupDoc["Setup Guide"]:::external
        click SetupDoc "https://github.com/devtalent2030/securiscan/blob/main/docs/setup.md"
    end

    classDef microservice fill:#D6E9FE,stroke:#000,stroke-width:1px
    classDef modules fill:#DFFFE0,stroke:#000,stroke-width:1px
    classDef storage fill:#FFE0B3,stroke:#000,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#000,stroke-width:1px
```
