# atharv853/ai-based-document-malware-detection architecture

> Architecture diagram of the GitHub repository atharv853/ai-based-document-malware-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atharv853/ai-based-document-malware-detection
- Repository: https://github.com/atharv853/ai-based-document-malware-detection

## Overview

FEMDoc is a static attachment-risk triage application. Users authenticate, upload a supported document, and receive a format-specific risk verdict with behavioral evidence and an explanation; scan records feed history and analytics views. The map includes the documented format-aware model-training capability, though its dataset and training internals are not shown here. Backend call relationships are grounded in excerpts and the source index; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/services/api.js`](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/services/api.js) (API client), [`backend/routes/scan_routes.py`](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/scan_routes.py) (Scan routes), [`frontend/src/App.jsx`](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/App.jsx) (App and routing), [`backend/extractors/dispatcher.py`](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/dispatcher.py) (Format dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app_ui["App and routing<br/>[App.jsx]"]
  node_login_page["Login page<br/>[LoginPage.jsx]"]
  node_upload_page["Upload and results<br/>[UploadScanPage.jsx]"]
  node_history_page["Scan history<br/>[HistoryPage.jsx]"]
  node_dashboard_page["Analytics dashboard<br/>[DashboardPage.jsx]"]
  node_result_views["Result visualizations"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API and triage"]
  node_flask_app["Flask app and routing<br/>[app.py]"]
  node_auth_routes["Authentication routes<br/>[auth_routes.py]"]
  node_scan_routes["Scan routes<br/>[scan_routes.py]"]
  node_analytics_routes["Analytics routes"]
end

subgraph group_analysis["Document analysis"]
  node_extract_dispatch["Format dispatcher<br/>[dispatcher.py]"]
  node_extract_base["Static byte utilities<br/>[base_extractor.py]"]
  node_docx_extract["DOCX extraction<br/>[docx_extractor.py]"]
  node_xlsx_extract["XLSX extraction<br/>[xlsx_extractor.py]"]
  node_pdf_extract["PDF extraction<br/>[pdf_extractor.py]"]
  node_html_extract["HTML extraction<br/>[html_extractor.py]"]
  node_prediction["Prediction and triage"]
  node_explanation["Explainable indicators"]
end

subgraph group_persistence["Persistence and analytics"]
  node_history_service["History service<br/>[history_service.py]"]
  node_sqlite[("SQLite records<br/>[database.py]")]
end

subgraph group_models["Model lifecycle"]
  node_model_training["Format model training"]
  node_model_artifacts["Format model artifacts"]
end

node_user(("User"))

node_user -->|"uses"| node_app_ui
node_app_ui -->|"routes to"| node_login_page
node_app_ui -->|"routes to"| node_upload_page
node_app_ui -->|"routes to"| node_history_page
node_app_ui -->|"routes to"| node_dashboard_page
node_login_page -->|"authenticates via"| node_api_client
node_upload_page -->|"uploads via"| node_api_client
node_history_page -->|"loads scans via"| node_api_client
node_dashboard_page -->|"loads analytics via"| node_api_client
node_upload_page -->|"renders results with"| node_result_views
node_api_client -->|"posts login"| node_auth_routes
node_api_client -->|"calls scan endpoints"| node_scan_routes
node_api_client -->|"calls analytics"| node_analytics_routes
node_flask_app -->|"registers"| node_auth_routes
node_flask_app -->|"registers"| node_scan_routes
node_flask_app -->|"registers"| node_analytics_routes
node_auth_routes -->|"queries users"| node_sqlite
node_scan_routes -->|"extracts features"| node_extract_dispatch
node_scan_routes -->|"hashes upload"| node_extract_base
node_extract_dispatch -->|"dispatches DOCX"| node_docx_extract
node_extract_dispatch -->|"dispatches XLSX"| node_xlsx_extract
node_extract_dispatch -->|"dispatches PDF"| node_pdf_extract
node_extract_dispatch -->|"dispatches HTML"| node_html_extract
node_scan_routes -->|"requests verdict"| node_prediction
node_prediction -->|"generates explanation"| node_explanation
node_scan_routes -->|"saves and retrieves"| node_history_service
node_analytics_routes -->|"requests summary"| node_history_service
node_history_service -->|"reads and writes"| node_sqlite
node_flask_app -->|"initializes schema"| node_sqlite
node_prediction -->|"loads format models"| node_model_artifacts
node_model_training -.->|"produces artifacts"| node_model_artifacts

click node_app_ui "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/App.jsx"
click node_login_page "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/LoginPage.jsx"
click node_upload_page "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/UploadScanPage.jsx"
click node_history_page "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/HistoryPage.jsx"
click node_dashboard_page "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_result_views "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/components/ScanResultChart.jsx"
click node_api_client "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/services/api.js"
click node_flask_app "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/app.py"
click node_auth_routes "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/auth_routes.py"
click node_scan_routes "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/scan_routes.py"
click node_analytics_routes "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/analytics_routes.py"
click node_extract_dispatch "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/dispatcher.py"
click node_extract_base "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/base_extractor.py"
click node_docx_extract "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/docx_extractor.py"
click node_xlsx_extract "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/xlsx_extractor.py"
click node_pdf_extract "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/pdf_extractor.py"
click node_html_extract "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/html_extractor.py"
click node_prediction "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/prediction_service.py"
click node_explanation "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/explanation_service.py"
click node_history_service "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/history_service.py"
click node_sqlite "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/database.py"
click node_model_training "https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/models/train_format_models.py"
click node_model_artifacts "https://github.com/atharv853/ai-based-document-malware-detection/tree/main/backend/models"

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_app_ui,node_login_page,node_upload_page,node_history_page,node_dashboard_page,node_result_views,node_api_client,node_user toneBlue
class node_flask_app,node_auth_routes,node_scan_routes,node_analytics_routes toneAmber
class node_extract_dispatch,node_extract_base,node_docx_extract,node_xlsx_extract,node_pdf_extract,node_html_extract,node_prediction,node_explanation toneMint
class node_history_service,node_sqlite toneRose
class node_model_training,node_model_artifacts toneIndigo
```

## Components

### Web application

- [App and routing](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login page](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Upload and results](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/UploadScanPage.jsx): `frontend/src/pages/UploadScanPage.jsx`
- [Scan history](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/HistoryPage.jsx): `frontend/src/pages/HistoryPage.jsx`
- [Analytics dashboard](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Result visualizations](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/components/ScanResultChart.jsx): `frontend/src/components/ScanResultChart.jsx`
- [API client](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and triage

- [Flask app and routing](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/app.py): `backend/app.py`
- [Authentication routes](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/auth_routes.py): `backend/routes/auth_routes.py`
- [Scan routes](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/scan_routes.py): `backend/routes/scan_routes.py`
- [Analytics routes](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/routes/analytics_routes.py): `backend/routes/analytics_routes.py`

### Document analysis

- [Format dispatcher](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/dispatcher.py): `backend/extractors/dispatcher.py`
- [Static byte utilities](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/base_extractor.py): `backend/extractors/base_extractor.py`
- [DOCX extraction](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/docx_extractor.py): `backend/extractors/docx_extractor.py`
- [XLSX extraction](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/xlsx_extractor.py): `backend/extractors/xlsx_extractor.py`
- [PDF extraction](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/pdf_extractor.py): `backend/extractors/pdf_extractor.py`
- [HTML extraction](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/extractors/html_extractor.py): `backend/extractors/html_extractor.py`
- [Prediction and triage](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/prediction_service.py): `backend/services/prediction_service.py`
- [Explainable indicators](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/explanation_service.py): `backend/services/explanation_service.py`

### Persistence and analytics

- [History service](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/services/history_service.py): `backend/services/history_service.py`
- [SQLite records](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/database.py): `backend/database.py`

### Model lifecycle

- [Format model training](https://github.com/atharv853/ai-based-document-malware-detection/blob/main/backend/models/train_format_models.py): `backend/models/train_format_models.py`
- [Format model artifacts](https://github.com/atharv853/ai-based-document-malware-detection/tree/main/backend/models): `backend/models`

### Other components

- **User**

## Connections

- User → App and routing: uses (evidence: `frontend/src/App.jsx`)
- App and routing → Login page: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → Upload and results: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → Scan history: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → Analytics dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Login page → API client: authenticates via (evidence: `frontend/src/pages/LoginPage.jsx`)
- Upload and results → API client: uploads via (evidence: `frontend/src/pages/UploadScanPage.jsx`)
- Scan history → API client: loads scans via (evidence: `frontend/src/pages/HistoryPage.jsx`)
- Analytics dashboard → API client: loads analytics via (evidence: `frontend/src/pages/DashboardPage.jsx`)
- Upload and results → Result visualizations: renders results with (evidence: `frontend/src/pages/UploadScanPage.jsx`)
- API client → Authentication routes: posts login (evidence: `frontend/src/services/api.js`)
- API client → Scan routes: calls scan endpoints (evidence: `frontend/src/services/api.js`)
- API client → Analytics routes: calls analytics (evidence: `frontend/src/services/api.js`)
- Flask app and routing → Authentication routes: registers (evidence: `backend/app.py`)
- Flask app and routing → Scan routes: registers (evidence: `backend/app.py`)
- Flask app and routing → Analytics routes: registers (evidence: `backend/app.py`)
- Authentication routes → SQLite records: queries users (evidence: `backend/routes/auth_routes.py`)
- Scan routes → Format dispatcher: extracts features (evidence: `backend/routes/scan_routes.py`)
- Scan routes → Static byte utilities: hashes upload (evidence: `backend/routes/scan_routes.py`)
- Format dispatcher → DOCX extraction: dispatches DOCX (evidence: `backend/extractors/dispatcher.py`)
- Format dispatcher → XLSX extraction: dispatches XLSX (evidence: `backend/extractors/dispatcher.py`)
- Format dispatcher → PDF extraction: dispatches PDF (evidence: `backend/extractors/dispatcher.py`)
- Format dispatcher → HTML extraction: dispatches HTML (evidence: `backend/extractors/dispatcher.py`)
- Scan routes → Prediction and triage: requests verdict (evidence: `backend/routes/scan_routes.py`)
- Prediction and triage → Explainable indicators: generates explanation (evidence: `backend/services/prediction_service.py`)
- Scan routes → History service: saves and retrieves (evidence: `backend/routes/scan_routes.py`)
- Analytics routes → History service: requests summary (evidence: `backend/routes/analytics_routes.py`)
- History service → SQLite records: reads and writes (evidence: `backend/services/history_service.py`)
- Flask app and routing → SQLite records: initializes schema (evidence: `backend/app.py`)
- Prediction and triage → Format model artifacts: loads format models (evidence: `backend/services/prediction_service.py`)
- Format model training → Format model artifacts: produces artifacts (evidence: `README.md`)
