# bornbe/dacn architecture

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

- Interactive diagram: https://gitdiagram.com/bornbe/dacn
- Repository: https://github.com/bornbe/dacn

## Overview

DACN is an authorized-scope web vulnerability scanner with a Flask API/dashboard and CLI. The main workflow is to authenticate, register and verify a target, create a scan, run crawling and supported checks, persist findings and progress, then inspect, compare, and export results. Separate branches cover user administration and audit logs. The graph uses README capabilities and source-index references; where implementation excerpts were unavailable, it avoids asserting uncertain call relationships.

Main entry points: [`core/engine/scan_engine.py`](https://github.com/bornbe/dacn/blob/main/core/engine/scan_engine.py) (Scan orchestrator), [`controllers/scan_controller.py`](https://github.com/bornbe/dacn/blob/main/controllers/scan_controller.py) (Scan API), [`app.py`](https://github.com/bornbe/dacn/blob/main/app.py) (Flask application), [`services/scan_service.py`](https://github.com/bornbe/dacn/blob/main/services/scan_service.py) (Scan lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_dashboard["Web dashboard<br/>[app.js]"]
  node_cli["CLI scanner<br/>[scanner.py]"]
  node_api["Flask application<br/>[app.py]"]
end

subgraph group_access["Access and targets"]
  node_auth_routes["Authentication routes<br/>[auth_controller.py]"]
  node_auth_middleware["JWT and RBAC<br/>[auth_middleware.py]"]
  node_auth_service["Authentication service<br/>[auth_service.py]"]
  node_target_routes["Target routes"]
  node_target_service["Target verification<br/>[target_service.py]"]
  node_scan_routes["Scan API<br/>[scan_controller.py]"]
  node_admin["Admin management"]
end

subgraph group_scanning["Scan execution"]
  node_scan_service["Scan lifecycle<br/>[scan_service.py]"]
  node_scan_tasks["Scan worker tasks<br/>[scan_tasks.py]"]
  node_engine["Scan orchestrator<br/>[scan_engine.py]"]
  node_crawler["BFS crawler<br/>[bfs_crawler.py]"]
  node_url_parser["URL parsing<br/>[url_parser.py]"]
  node_form_parser["Form endpoints<br/>[form_parser.py]"]
  node_scanner_registry["Vulnerability scanners<br/>[__init__.py]"]
  node_result_manager["Finding deduplication<br/>[result_manager.py]"]
end

subgraph group_security["Safety controls"]
  node_target_validator["Target validation"]
  node_scope_policy["Scope policy<br/>[scope_policy.py]"]
  node_safe_http["Safe HTTP client"]
end

subgraph group_persistence["Results and operations"]
  node_database[("SQLAlchemy database<br/>[base.py]")]
  node_scan_models["Targets and scan jobs<br/>[scan_job.py]"]
  node_findings["Vulnerability findings<br/>[vulnerability.py]"]
  node_report_routes["Report API"]
  node_report_service["Report export<br/>[report_service.py]"]
  node_audit["Audit logging<br/>[audit_service.py]"]
end

node_tester(("Tester or admin"))
node_target_site(("Authorized target"))

node_tester -->|"uses"| node_dashboard
node_tester -->|"runs"| node_cli
node_tester -->|"calls"| node_api
node_dashboard -->|"calls API"| node_api
node_api -->|"routes"| node_auth_routes
node_api -->|"routes"| node_scan_routes
node_api -->|"routes"| node_target_routes
node_api -->|"routes"| node_report_routes
node_auth_routes -->|"authenticates"| node_auth_service
node_auth_routes -->|"protects routes"| node_auth_middleware
node_scan_routes -->|"protects routes"| node_auth_middleware
node_target_routes -->|"protects routes"| node_auth_middleware
node_scan_routes -->|"checks authorization"| node_target_service
node_scan_routes -->|"creates scans"| node_scan_service
node_scan_routes -->|"dispatches work"| node_scan_tasks
node_target_service -->|"validates target"| node_target_validator
node_target_service -->|"checks scope"| node_scope_policy
node_target_service -->|"verifies ownership"| node_safe_http
node_scan_service -->|"runs scan"| node_engine
node_scan_tasks -->|"executes scan"| node_scan_service
node_engine -->|"crawls target"| node_crawler
node_engine -->|"parses endpoints"| node_form_parser
node_engine -->|"validates target"| node_target_validator
node_engine -->|"dispatches checks"| node_scanner_registry
node_engine -->|"deduplicates findings"| node_result_manager
node_form_parser -->|"normalizes URLs"| node_url_parser
node_crawler -.->|"fetches pages"| node_target_site
node_scanner_registry -.->|"tests endpoints"| node_target_site
node_target_validator -->|"enforces policy"| node_scope_policy
node_safe_http -->|"validates requests"| node_target_validator
node_result_manager -->|"stores findings"| node_findings
node_engine -->|"updates scan"| node_scan_models
node_scan_service -->|"manages lifecycle"| node_scan_models
node_report_routes -->|"exports report"| node_report_service
node_report_routes -->|"loads scan"| node_scan_service
node_tester -->|"requests export"| node_report_routes
node_tester -->|"compares scans"| node_scan_routes
node_auth_routes -->|"records events"| node_audit
node_scan_routes -->|"records events"| node_audit
node_target_routes -->|"records events"| node_audit
node_admin -->|"checks roles"| node_auth_middleware
node_admin -->|"queries logs"| node_audit
node_admin -->|"manages users"| node_tester

click node_dashboard "https://github.com/bornbe/dacn/blob/main/static/js/app.js"
click node_cli "https://github.com/bornbe/dacn/blob/main/scanner.py"
click node_api "https://github.com/bornbe/dacn/blob/main/app.py"
click node_auth_routes "https://github.com/bornbe/dacn/blob/main/controllers/auth_controller.py"
click node_auth_middleware "https://github.com/bornbe/dacn/blob/main/middleware/auth_middleware.py"
click node_auth_service "https://github.com/bornbe/dacn/blob/main/services/auth_service.py"
click node_target_routes "https://github.com/bornbe/dacn/blob/main/controllers/target_controller.py"
click node_target_service "https://github.com/bornbe/dacn/blob/main/services/target_service.py"
click node_scan_routes "https://github.com/bornbe/dacn/blob/main/controllers/scan_controller.py"
click node_scan_service "https://github.com/bornbe/dacn/blob/main/services/scan_service.py"
click node_scan_tasks "https://github.com/bornbe/dacn/blob/main/tasks/scan_tasks.py"
click node_engine "https://github.com/bornbe/dacn/blob/main/core/engine/scan_engine.py"
click node_crawler "https://github.com/bornbe/dacn/blob/main/core/crawler/bfs_crawler.py"
click node_url_parser "https://github.com/bornbe/dacn/blob/main/core/crawler/url_parser.py"
click node_form_parser "https://github.com/bornbe/dacn/blob/main/core/crawler/form_parser.py"
click node_scanner_registry "https://github.com/bornbe/dacn/blob/main/core/scanners/__init__.py"
click node_result_manager "https://github.com/bornbe/dacn/blob/main/core/engine/result_manager.py"
click node_target_validator "https://github.com/bornbe/dacn/blob/main/core/security/target_validator.py"
click node_scope_policy "https://github.com/bornbe/dacn/blob/main/core/security/scope_policy.py"
click node_safe_http "https://github.com/bornbe/dacn/blob/main/core/utils/safe_http_client.py"
click node_database "https://github.com/bornbe/dacn/blob/main/models/base.py"
click node_scan_models "https://github.com/bornbe/dacn/blob/main/models/scan_job.py"
click node_findings "https://github.com/bornbe/dacn/blob/main/models/vulnerability.py"
click node_report_routes "https://github.com/bornbe/dacn/blob/main/controllers/report_controller.py"
click node_report_service "https://github.com/bornbe/dacn/blob/main/services/report_service.py"
click node_audit "https://github.com/bornbe/dacn/blob/main/services/audit_service.py"
click node_admin "https://github.com/bornbe/dacn/blob/main/controllers/admin_controller.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_dashboard,node_cli,node_api toneBlue
class node_auth_routes,node_auth_middleware,node_auth_service,node_target_routes,node_target_service,node_scan_routes,node_admin toneAmber
class node_scan_service,node_scan_tasks,node_engine,node_crawler,node_url_parser,node_form_parser,node_scanner_registry,node_result_manager toneMint
class node_target_validator,node_scope_policy,node_safe_http toneRose
class node_database,node_scan_models,node_findings,node_report_routes,node_report_service,node_audit,node_tester,node_target_site toneIndigo
```

## Components

### User interfaces

- [Web dashboard](https://github.com/bornbe/dacn/blob/main/static/js/app.js): `static/js/app.js`
- [CLI scanner](https://github.com/bornbe/dacn/blob/main/scanner.py): `scanner.py`
- [Flask application](https://github.com/bornbe/dacn/blob/main/app.py): `app.py`

### Access and targets

- [Authentication routes](https://github.com/bornbe/dacn/blob/main/controllers/auth_controller.py): `controllers/auth_controller.py`
- [JWT and RBAC](https://github.com/bornbe/dacn/blob/main/middleware/auth_middleware.py): `middleware/auth_middleware.py`
- [Authentication service](https://github.com/bornbe/dacn/blob/main/services/auth_service.py): `services/auth_service.py`
- [Target routes](https://github.com/bornbe/dacn/blob/main/controllers/target_controller.py): `controllers/target_controller.py`
- [Target verification](https://github.com/bornbe/dacn/blob/main/services/target_service.py): `services/target_service.py`
- [Scan API](https://github.com/bornbe/dacn/blob/main/controllers/scan_controller.py): `controllers/scan_controller.py`
- [Admin management](https://github.com/bornbe/dacn/blob/main/controllers/admin_controller.py): `controllers/admin_controller.py`

### Scan execution

- [Scan lifecycle](https://github.com/bornbe/dacn/blob/main/services/scan_service.py): `services/scan_service.py`
- [Scan worker tasks](https://github.com/bornbe/dacn/blob/main/tasks/scan_tasks.py): `tasks/scan_tasks.py`
- [Scan orchestrator](https://github.com/bornbe/dacn/blob/main/core/engine/scan_engine.py): `core/engine/scan_engine.py`
- [BFS crawler](https://github.com/bornbe/dacn/blob/main/core/crawler/bfs_crawler.py): `core/crawler/bfs_crawler.py`
- [URL parsing](https://github.com/bornbe/dacn/blob/main/core/crawler/url_parser.py): `core/crawler/url_parser.py`
- [Form endpoints](https://github.com/bornbe/dacn/blob/main/core/crawler/form_parser.py): `core/crawler/form_parser.py`
- [Vulnerability scanners](https://github.com/bornbe/dacn/blob/main/core/scanners/__init__.py): `core/scanners/__init__.py`
- [Finding deduplication](https://github.com/bornbe/dacn/blob/main/core/engine/result_manager.py): `core/engine/result_manager.py`

### Safety controls

- [Target validation](https://github.com/bornbe/dacn/blob/main/core/security/target_validator.py): `core/security/target_validator.py`
- [Scope policy](https://github.com/bornbe/dacn/blob/main/core/security/scope_policy.py): `core/security/scope_policy.py`
- [Safe HTTP client](https://github.com/bornbe/dacn/blob/main/core/utils/safe_http_client.py): `core/utils/safe_http_client.py`

### Results and operations

- [SQLAlchemy database](https://github.com/bornbe/dacn/blob/main/models/base.py): `models/base.py`
- [Targets and scan jobs](https://github.com/bornbe/dacn/blob/main/models/scan_job.py): `models/scan_job.py`
- [Vulnerability findings](https://github.com/bornbe/dacn/blob/main/models/vulnerability.py): `models/vulnerability.py`
- [Report API](https://github.com/bornbe/dacn/blob/main/controllers/report_controller.py): `controllers/report_controller.py`
- [Report export](https://github.com/bornbe/dacn/blob/main/services/report_service.py): `services/report_service.py`
- [Audit logging](https://github.com/bornbe/dacn/blob/main/services/audit_service.py): `services/audit_service.py`

### Other components

- **Tester or admin**
- **Authorized target**

## Connections

- Tester or admin → Web dashboard: uses
- Tester or admin → CLI scanner: runs
- Tester or admin → Flask application: calls
- Web dashboard → Flask application: calls API
- Flask application → Authentication routes: routes (evidence: `app.py`)
- Flask application → Scan API: routes (evidence: `app.py`)
- Flask application → Target routes: routes (evidence: `app.py`)
- Flask application → Report API: routes (evidence: `app.py`)
- Authentication routes → Authentication service: authenticates (evidence: `controllers/auth_controller.py`)
- Authentication routes → JWT and RBAC: protects routes (evidence: `controllers/auth_controller.py`)
- Scan API → JWT and RBAC: protects routes (evidence: `controllers/scan_controller.py`)
- Target routes → JWT and RBAC: protects routes (evidence: `controllers/target_controller.py`)
- Scan API → Target verification: checks authorization (evidence: `controllers/scan_controller.py`)
- Scan API → Scan lifecycle: creates scans (evidence: `controllers/scan_controller.py`)
- Scan API → Scan worker tasks: dispatches work (evidence: `controllers/scan_controller.py`)
- Target verification → Target validation: validates target (evidence: `services/target_service.py`)
- Target verification → Scope policy: checks scope (evidence: `services/target_service.py`)
- Target verification → Safe HTTP client: verifies ownership (evidence: `services/target_service.py`)
- Scan lifecycle → Scan orchestrator: runs scan (evidence: `services/scan_service.py`)
- Scan worker tasks → Scan lifecycle: executes scan (evidence: `tasks/scan_tasks.py`)
- Scan orchestrator → BFS crawler: crawls target (evidence: `core/engine/scan_engine.py`)
- Scan orchestrator → Form endpoints: parses endpoints (evidence: `core/engine/scan_engine.py`)
- Scan orchestrator → Target validation: validates target (evidence: `core/engine/scan_engine.py`)
- Scan orchestrator → Vulnerability scanners: dispatches checks (evidence: `core/engine/scan_engine.py`)
- Scan orchestrator → Finding deduplication: deduplicates findings (evidence: `core/engine/scan_engine.py`)
- Form endpoints → URL parsing: normalizes URLs (evidence: `core/crawler/form_parser.py`)
- BFS crawler → Authorized target: fetches pages
- Vulnerability scanners → Authorized target: tests endpoints
- Target validation → Scope policy: enforces policy (evidence: `core/security/scope_policy.py`)
- Safe HTTP client → Target validation: validates requests (evidence: `core/utils/safe_http_client.py`)
- Finding deduplication → Vulnerability findings: stores findings (evidence: `core/engine/result_manager.py`)
- Scan orchestrator → Targets and scan jobs: updates scan (evidence: `core/engine/scan_engine.py`)
- Scan lifecycle → Targets and scan jobs: manages lifecycle (evidence: `services/scan_service.py`)
- Report API → Report export: exports report (evidence: `controllers/report_controller.py`)
- Report API → Scan lifecycle: loads scan (evidence: `controllers/report_controller.py`)
- Tester or admin → Report API: requests export
- Tester or admin → Scan API: compares scans
- Authentication routes → Audit logging: records events (evidence: `controllers/auth_controller.py`)
- Scan API → Audit logging: records events (evidence: `controllers/scan_controller.py`)
- Target routes → Audit logging: records events (evidence: `controllers/target_controller.py`)
- Admin management → JWT and RBAC: checks roles (evidence: `controllers/admin_controller.py`)
- Admin management → Audit logging: queries logs (evidence: `controllers/admin_controller.py`)
- Admin management → Tester or admin: manages users
