# jatin-vidhani17/securescan architecture

> Architecture diagram of the GitHub repository jatin-vidhani17/securescan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jatin-vidhani17/securescan
- Repository: https://github.com/jatin-vidhani17/securescan

## Overview

1. **System shape**
   SecureScan is a two-tier application: a **React + Tailwind frontend** in `frontend/` and a **Flask backend** in `backend/`. The backend exposes a scan API, runs the vulnerability checks, and returns structured results that the UI visualizes.

2. **User-facing workflow**
   The main flow is: user enters a target URL in the frontend → frontend sends a request to the backend `POST /api/scan` → backend validates the target and performs a scan → results are returned as JSON → frontend renders scores, findings, OWASP mappings, charts, logs, and export options.

3. **Frontend subsystem**
   `frontend/src/App.jsx` orchestrates the UI. The supporting components split the scan output into separate views:
   - `ScoreCard.jsx` for summary/severity
   - `VulnerabilityList.jsx` for findings
   - `Charts.jsx` for visual breakdowns
   - `OWASPTable.jsx` for OWASP-style categorization
   - `ScanLogs.jsx` for execution traces
   - `ReportExport.jsx` for exporting reports  
   `frontend/src/api.js` is the client boundary to the Flask API.

4. **Backend entry point and API layer**
   `backend/app.py` is the Flask entry point and HTTP boundary. It likely wires routes, middleware, response headers, rate limiting, and the scan endpoint. The README indicates the backend also adds secure response headers and rate limiting around scan requests.

5. **Scan orchestration**
   `backend/scanner.py` and `backend/core/engine.py` appear to be the central orchestration layer. This is where a target URL is validated, a crawl or request sequence is initiated, detectors are invoked, and a final result object is assembled. `backend/core/scoring.py` likely converts raw findings into a severity/score summary.

6. **Target validation and SSRF protections**
   `backend/security.py` is an important boundary before any outbound request is made. Based on the README, it enforces:
   - HTTP/HTTPS-only URLs
   - rejection of embedded credentials
   - blocking localhost/private/internal IP ranges
   - timeout and redirect constraints  
   This subsystem is the main guardrail preventing the scanner from being abused as an SSRF primitive.

7. **Crawler and request discovery**
   `backend/crawler/crawler.py` is the discovery layer. It likely fetches pages and extracts links/forms or other targets for deeper inspection. The README’s “next steps” mention crawler depth control, so the crawler is already a distinct module, but probably still simple and centrally invoked by the scan engine.

8. **Detection modules**
   `backend/detectors/` contains the vulnerability-specific checks:
   - `xss.py`
   - `sqli.py`
   - `sensitive_data.py`  
   These are independent analyzers that receive crawled pages, responses, or payload contexts and return findings. This modular structure means new checks can be added without changing the UI or API contract.

9. **OWASP and scoring layer**
   `backend/core/owasp_tests.py` and `backend/core/scoring.py` suggest a mapping from raw detector outputs into OWASP-style categories and a weighted severity model. The architecture likely separates “what was found” from “how serious it is,” which is useful for the frontend’s charts and summary cards.

10. **Reporting and persistence**
   `backend/reports/report.py` handles report generation/formatting for scan output. `backend/database.py` and the bundled `backend/securescan.db` indicate SQLite-backed persistence, though the README says scan history persistence is a next step; so the current repo likely has partial or experimental DB support. `backend/fix_db.py` suggests schema repair or migration utilities.

11. **Execution artifacts and diagnostics**
   `scan_logs.json` and `sample_scan_output.json` show that the project stores example scan traces/output for development or demo purposes. `view_db.py` and the test scripts (`test_crawler.py`, `test_crawler2.py`, `tmp_sql_test.py`) indicate local validation tooling around crawler behavior, SQL injection checks, and database inspection.

12. **Demo/test target**
   `vuln_app.py` appears to be a deliberately vulnerable sample application used as a scan target during development. Architecturally, this is a separate test fixture rather than a production subsystem.

13. **Runtime and deployment boundaries**
   The backend runs on Flask/Python, while the frontend is built with Vite/React/Tailwind. Communication is purely HTTP/JSON between browser and API. There is no evidence of a message queue or microservice split; the scanner executes synchronously within the Flask process.

14. **Key diagram boundaries to show**
   For an architecture diagram, the most important boundaries are:
   - Browser/UI vs Flask API
   - API vs security gatekeeper
   - Scanner orchestration vs detector modules
   - Scanner vs external target website
   - Scanner vs SQLite/reporting artifacts  
   The external target site is the only intentional third-party dependency in the scan path, and it is tightly constrained by the security controls above.

Main entry points: [`backend/core/engine.py`](https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/engine.py) (Scan Engine), [`frontend/src/App.jsx`](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/App.jsx) (Scan UI), [`backend/scanner.py`](https://github.com/jatin-vidhani17/securescan/blob/main/backend/scanner.py) (Scan API), [`frontend/src/api.js`](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/api.js) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_ui["Scan UI<br/>React app<br/>[App.jsx]"]
  node_api_client["API Client<br/>HTTP client<br/>[api.js]"]
  node_score_card["Score Card<br/>summary view<br/>[ScoreCard.jsx]"]
  node_vuln_list["Findings List<br/>results view"]
  node_charts["Charts<br/>visualization<br/>[Charts.jsx]"]
  node_owasp_table["OWASP Table<br/>categorization view<br/>[OWASPTable.jsx]"]
  node_scan_logs["Scan Logs<br/>trace view<br/>[ScanLogs.jsx]"]
  node_report_export["Export Report<br/>export view<br/>[ReportExport.jsx]"]
end

subgraph group_backend["Backend"]
  node_flask_app["Flask API<br/>HTTP boundary<br/>[app.py]"]
  node_scan_api["Scan API<br/>route layer<br/>[scanner.py]"]
  node_security_gate["Security Gate<br/>validation<br/>[security.py]"]
  node_engine["Scan Engine<br/>orchestrator<br/>[engine.py]"]
  node_crawler["Crawler<br/>discovery<br/>[crawler.py]"]
  node_xss["XSS Detector<br/>[xss.py]"]
  node_sqli["SQLi Detector<br/>[sqli.py]"]
  node_sensitive_data["Data Leak Detector<br/>[sensitive_data.py]"]
  node_owasp_tests["OWASP Mapping<br/>classification<br/>[owasp_tests.py]"]
  node_scoring["Scoring<br/>severity model<br/>[scoring.py]"]
  node_reporting["Reporting<br/>formatter<br/>[report.py]"]
  node_database[("SQLite Store<br/>persistence<br/>[database.py]")]
end

subgraph group_artifacts["Artifacts"]
  node_sample_output["Sample Output<br/>artifact"]
  node_scan_logs_file["Log Sample<br/>artifact<br/>[scan_logs.json]"]
  node_vuln_app["Demo Target<br/>test fixture<br/>[vuln_app.py]"]
end

node_ui -->|"submit target"| node_api_client
node_api_client -->|"HTTP JSON"| node_flask_app
node_flask_app -->|"dispatch"| node_scan_api
node_scan_api -->|"validate"| node_security_gate
node_security_gate -->|"allow scan"| node_engine
node_engine -->|"discover"| node_crawler
node_engine -->|"run check"| node_xss
node_engine -->|"run check"| node_sqli
node_engine -->|"run check"| node_sensitive_data
node_engine -->|"classify"| node_owasp_tests
node_engine -->|"score"| node_scoring
node_engine -->|"format"| node_reporting
node_engine -->|"persist"| node_database
node_engine -.->|"emit example"| node_sample_output
node_engine -.->|"emit trace"| node_scan_logs_file
node_scan_api -->|"return results"| node_ui
node_ui -->|"render"| node_score_card
node_ui -->|"render"| node_vuln_list
node_ui -->|"render"| node_charts
node_ui -->|"render"| node_owasp_table
node_ui -->|"render"| node_scan_logs
node_ui -->|"render"| node_report_export
node_crawler -->|"scan target"| node_vuln_app

click node_ui "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/api.js"
click node_score_card "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ScoreCard.jsx"
click node_vuln_list "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/VulnerabilityList.jsx"
click node_charts "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/Charts.jsx"
click node_owasp_table "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/OWASPTable.jsx"
click node_scan_logs "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ScanLogs.jsx"
click node_report_export "https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ReportExport.jsx"
click node_flask_app "https://github.com/jatin-vidhani17/securescan/blob/main/backend/app.py"
click node_scan_api "https://github.com/jatin-vidhani17/securescan/blob/main/backend/scanner.py"
click node_security_gate "https://github.com/jatin-vidhani17/securescan/blob/main/backend/security.py"
click node_engine "https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/engine.py"
click node_crawler "https://github.com/jatin-vidhani17/securescan/blob/main/backend/crawler/crawler.py"
click node_xss "https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/xss.py"
click node_sqli "https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/sqli.py"
click node_sensitive_data "https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/sensitive_data.py"
click node_owasp_tests "https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/owasp_tests.py"
click node_scoring "https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/scoring.py"
click node_reporting "https://github.com/jatin-vidhani17/securescan/blob/main/backend/reports/report.py"
click node_database "https://github.com/jatin-vidhani17/securescan/blob/main/backend/database.py"
click node_sample_output "https://github.com/jatin-vidhani17/securescan/blob/main/sample_scan_output.json"
click node_scan_logs_file "https://github.com/jatin-vidhani17/securescan/blob/main/scan_logs.json"
click node_vuln_app "https://github.com/jatin-vidhani17/securescan/blob/main/vuln_app.py"

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_ui,node_api_client,node_score_card,node_vuln_list,node_charts,node_owasp_table,node_scan_logs,node_report_export toneBlue
class node_flask_app,node_scan_api,node_security_gate,node_engine,node_crawler,node_xss,node_sqli,node_sensitive_data,node_owasp_tests,node_scoring,node_reporting,node_database toneAmber
class node_sample_output,node_scan_logs_file,node_vuln_app toneMint
```

## Components

### Frontend

React UI and browser-side API client

- [Scan UI](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/App.jsx): React app · Main browser interface that orchestrates the scan experience · `frontend/src/App.jsx`
- [API Client](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/api.js): HTTP client · Browser-side boundary for calling the backend scan API · `frontend/src/api.js`
- [Score Card](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ScoreCard.jsx): summary view · Shows overall severity and scan score · `frontend/src/components/ScoreCard.jsx`
- [Findings List](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/VulnerabilityList.jsx): results view · Renders detected vulnerabilities and details · `frontend/src/components/VulnerabilityList.jsx`
- [Charts](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/Charts.jsx): visualization · Displays severity and category breakdowns · `frontend/src/components/Charts.jsx`
- [OWASP Table](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/OWASPTable.jsx): categorization view · Maps findings into OWASP-style categories · `frontend/src/components/OWASPTable.jsx`
- [Scan Logs](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ScanLogs.jsx): trace view · Shows execution trace and progress messages · `frontend/src/components/ScanLogs.jsx`
- [Export Report](https://github.com/jatin-vidhani17/securescan/blob/main/frontend/src/components/ReportExport.jsx): export view · Handles report download and export actions · `frontend/src/components/ReportExport.jsx`

### Backend

Flask app, scan pipeline, and persistence

- [Flask API](https://github.com/jatin-vidhani17/securescan/blob/main/backend/app.py): HTTP boundary · Backend entry point exposing scan routes and response controls · `backend/app.py`
- [Scan API](https://github.com/jatin-vidhani17/securescan/blob/main/backend/scanner.py): route layer · Accepts scan requests and returns structured results · `backend/scanner.py`
- [Security Gate](https://github.com/jatin-vidhani17/securescan/blob/main/backend/security.py): validation · Validates targets and blocks unsafe outbound requests · `backend/security.py`
- [Scan Engine](https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/engine.py): orchestrator · Coordinates crawl, detection, scoring, and result assembly · `backend/core/engine.py`
- [Crawler](https://github.com/jatin-vidhani17/securescan/blob/main/backend/crawler/crawler.py): discovery · Discovers links, forms, and targets for deeper inspection · `backend/crawler/crawler.py`
- [XSS Detector](https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/xss.py): detector · Checks pages and responses for cross-site scripting issues · `backend/detectors/xss.py`
- [SQLi Detector](https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/sqli.py): detector · Checks inputs and responses for injection signals · `backend/detectors/sqli.py`
- [Data Leak Detector](https://github.com/jatin-vidhani17/securescan/blob/main/backend/detectors/sensitive_data.py): detector · Finds exposed secrets or sensitive content · `backend/detectors/sensitive_data.py`
- [OWASP Mapping](https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/owasp_tests.py): classification · Maps raw findings into OWASP-style categories · `backend/core/owasp_tests.py`
- [Scoring](https://github.com/jatin-vidhani17/securescan/blob/main/backend/core/scoring.py): severity model · Converts findings into a weighted score and severity summary · `backend/core/scoring.py`
- [Reporting](https://github.com/jatin-vidhani17/securescan/blob/main/backend/reports/report.py): formatter · Formats scan results into report output · `backend/reports/report.py`
- [SQLite Store](https://github.com/jatin-vidhani17/securescan/blob/main/backend/database.py): persistence · Stores scan history and related records · `backend/database.py`

### Artifacts

Example outputs, local tools, and demo target

- [Sample Output](https://github.com/jatin-vidhani17/securescan/blob/main/sample_scan_output.json): artifact · Example scan result payload for development and demos · `sample_scan_output.json`
- [Log Sample](https://github.com/jatin-vidhani17/securescan/blob/main/scan_logs.json): artifact · Example scan trace output · `scan_logs.json`
- [Demo Target](https://github.com/jatin-vidhani17/securescan/blob/main/vuln_app.py): test fixture · Deliberately vulnerable app used as a scan target · `vuln_app.py`

## Connections

- Scan UI → API Client: submit target · User input is sent to the backend scan API
- API Client → Flask API: HTTP JSON · Frontend communicates with the Flask backend over JSON requests
- Flask API → Scan API: dispatch · The app routes scan requests into the scan entrypoint
- Scan API → Security Gate: validate · Targets are checked before any outbound request is made
- Security Gate → Scan Engine: allow scan · Safe targets proceed into orchestration
- Scan Engine → Crawler: discover · The engine uses the crawler to find pages and inputs
- Scan Engine → XSS Detector: run check · Runs the XSS detector on discovered content
- Scan Engine → SQLi Detector: run check · Runs the SQL injection detector on discovered content
- Scan Engine → Data Leak Detector: run check · Runs the sensitive data detector on responses and pages
- Scan Engine → OWASP Mapping: classify · Raw findings are mapped into OWASP-style buckets
- Scan Engine → Scoring: score · Findings are converted into a severity score
- Scan Engine → Reporting: format · Results are packaged for export and presentation
- Scan Engine → SQLite Store: persist · Scan data can be stored in SQLite
- Scan Engine → Sample Output: emit example · Representative result payload for demos and development
- Scan Engine → Log Sample: emit trace · Example execution logs mirror the scanner output
- Scan API → Scan UI: return results · Structured JSON results flow back to the frontend
- Scan UI → Score Card: render · The app renders the summary score card
- Scan UI → Findings List: render · The app renders detected findings
- Scan UI → Charts: render · The app renders severity and category charts
- Scan UI → OWASP Table: render · The app renders OWASP categorization
- Scan UI → Scan Logs: render · The app renders scan progress and logs
- Scan UI → Export Report: render · The app exposes report export actions
- Crawler → Demo Target: scan target · The crawler can exercise the demo vulnerable application
