# krithikshyaam/cyberastryx architecture

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

- Interactive diagram: https://gitdiagram.com/krithikshyaam/cyberastryx
- Repository: https://github.com/krithikshyaam/cyberastryx

## Overview

Cyberastryx trains and serves a locally run spam classifier, with Gmail automation plus a website and Chrome extension for scanning and verdicts. The main workflow is incoming mail through n8n to the API and model, then a spam decision; users can also analyze mail or scan an inbox in the website. Separate branches cover account administration, feedback and retraining, model training, monitoring, and optional link/image checks. The README documents integrations not present in this file tree; edges to those services reflect that documentation, not inspected workflow source.

Main entry points: [`spam_detection/api_server.py`](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/api_server.py) (REST API), [`web/src/App.tsx`](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/App.tsx) (Website), [`web/src/lib/api.ts`](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/api.ts) (Web API client), [`spam_detection/src/trainer.py`](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/trainer.py) (Model trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_automation["Mail automation"]
  node_n8n["n8n workflow"]
end

subgraph group_inference["Detection service"]
  node_api["REST API<br/>[api_server.py]"]
  node_predictor["Spam predictor<br/>[predict.py]"]
  node_linkcheck["Link/image checks"]
  node_accounts["Accounts and auth<br/>[auth.py]"]
  node_keys["API keys<br/>[key_store.py]"]
  node_accountdb[("Account database")]
  node_monitoring["Usage monitoring<br/>[monitoring.py]"]
end

subgraph group_training["Model lifecycle"]
  node_feedback["Feedback and retraining<br/>[feedback_loop.py]"]
  node_dataset["Dataset pipeline"]
  node_loader["Data loading<br/>[data_loader.py]"]
  node_trainer["Model trainer<br/>[trainer.py]"]
  node_models["BiLSTM and BERT<br/>[baseline_model.py]"]
  node_config["Model configuration<br/>[config.py]"]
end

subgraph group_web["Web application"]
  node_website["Website<br/>[App.tsx]"]
  node_authpage["Sign-in screens<br/>[AuthPage.tsx]"]
  node_userdash["User dashboard<br/>[UserDashboard.tsx]"]
  node_admindash["Admin dashboard<br/>[AdminDashboard.tsx]"]
  node_apiclient["Web API client<br/>[api.ts]"]
  node_verdict["Verdict rules<br/>[verdict.ts]"]
  node_accountclient["Account state<br/>[account.ts]"]
  node_settings["Client settings<br/>[settings.ts]"]
  node_history["Scan history<br/>[history.ts]"]
end

subgraph group_extension["Browser extension"]
  node_extension["Chrome extension<br/>[content.js]"]
end

node_gmail[("Gmail")]
node_user(("Website user"))
node_admin(("Administrator"))
node_browser(("Extension user"))

node_gmail -->|"triggers on mail"| node_n8n
node_n8n -->|"labels and archives"| node_gmail
node_n8n -->|"requests scoring"| node_api
node_website -->|"scans inbox"| node_n8n
node_website -->|"uses API"| node_api
node_extension -->|"requests verdicts"| node_api
node_api -->|"runs inference"| node_predictor
node_api -->|"uses checks"| node_linkcheck
node_api -->|"routes auth"| node_accounts
node_api -->|"uses keys"| node_keys
node_api -->|"records feedback"| node_feedback
node_api -->|"records usage"| node_monitoring
node_accounts -->|"reads and writes"| node_accountdb
node_feedback -->|"loads training data"| node_loader
node_feedback -->|"starts retraining"| node_trainer
node_dataset -.->|"prepares data"| node_loader
node_trainer -->|"loads data"| node_loader
node_trainer -->|"builds classifiers"| node_models
node_trainer -->|"uses settings"| node_config
node_predictor -->|"loads BiLSTM"| node_models
node_predictor -->|"uses model paths"| node_config
node_user -->|"uses"| node_website
node_admin -->|"administers"| node_website
node_browser -->|"configures and views"| node_extension
node_website -->|"renders"| node_authpage
node_website -->|"renders"| node_userdash
node_website -->|"renders"| node_admindash
node_authpage -->|"calls auth API"| node_apiclient
node_userdash -->|"requests scans"| node_apiclient
node_admindash -->|"loads admin data"| node_apiclient
node_apiclient -->|"uses session"| node_accountclient
node_apiclient -->|"reads settings"| node_settings
node_userdash -->|"stores scan history"| node_history
node_userdash -->|"interprets results"| node_verdict

click node_api "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/api_server.py"
click node_predictor "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/predict.py"
click node_linkcheck "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/link_image_checker.py"
click node_accounts "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/auth.py"
click node_keys "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/key_store.py"
click node_feedback "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/feedback_loop.py"
click node_monitoring "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/monitoring.py"
click node_dataset "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/dataset_pipeline.py"
click node_loader "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/data_loader.py"
click node_trainer "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/trainer.py"
click node_models "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/models/baseline_model.py"
click node_config "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/config.py"
click node_website "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/App.tsx"
click node_authpage "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/auth/AuthPage.tsx"
click node_userdash "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/user/UserDashboard.tsx"
click node_admindash "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/admin/AdminDashboard.tsx"
click node_apiclient "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/api.ts"
click node_verdict "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/verdict.ts"
click node_accountclient "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/account.ts"
click node_settings "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/settings.ts"
click node_history "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/history.ts"
click node_extension "https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/extension/content.js"

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_n8n,node_user,node_browser toneBlue
class node_api,node_predictor,node_linkcheck,node_accounts,node_keys,node_accountdb,node_monitoring,node_gmail toneAmber
class node_feedback,node_dataset,node_loader,node_trainer,node_models,node_config toneMint
class node_website,node_authpage,node_userdash,node_admindash,node_apiclient,node_verdict,node_accountclient,node_settings,node_history toneRose
class node_extension,node_admin toneIndigo
```

## Components

### Mail automation

- **n8n workflow**

### Detection service

- [REST API](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/api_server.py): `spam_detection/api_server.py`
- [Spam predictor](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/predict.py): `spam_detection/src/predict.py`
- [Link/image checks](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/link_image_checker.py): `spam_detection/link_image_checker.py`
- [Accounts and auth](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/auth.py): `spam_detection/auth.py`
- [API keys](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/key_store.py): `spam_detection/key_store.py`
- **Account database**
- [Usage monitoring](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/monitoring.py): `spam_detection/monitoring.py`

### Model lifecycle

- [Feedback and retraining](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/feedback_loop.py): `spam_detection/feedback_loop.py`
- [Dataset pipeline](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/dataset_pipeline.py): `spam_detection/dataset_pipeline.py`
- [Data loading](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/data_loader.py): `spam_detection/src/data_loader.py`
- [Model trainer](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/trainer.py): `spam_detection/src/trainer.py`
- [BiLSTM and BERT](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/models/baseline_model.py): `spam_detection/src/models/baseline_model.py`
- [Model configuration](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/spam_detection/src/config.py): `spam_detection/src/config.py`

### Web application

- [Website](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/App.tsx): `web/src/App.tsx`
- [Sign-in screens](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/auth/AuthPage.tsx): `web/src/components/auth/AuthPage.tsx`
- [User dashboard](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/user/UserDashboard.tsx): `web/src/components/user/UserDashboard.tsx`
- [Admin dashboard](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/components/admin/AdminDashboard.tsx): `web/src/components/admin/AdminDashboard.tsx`
- [Web API client](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/api.ts): `web/src/lib/api.ts`
- [Verdict rules](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/verdict.ts): `web/src/lib/verdict.ts`
- [Account state](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/account.ts): `web/src/lib/account.ts`
- [Client settings](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/settings.ts): `web/src/lib/settings.ts`
- [Scan history](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/web/src/lib/history.ts): `web/src/lib/history.ts`

### Browser extension

- [Chrome extension](https://github.com/krithikshyaam/cyberastryx/blob/feat/react-site/extension/content.js): `extension/content.js`

### Other components

- **Gmail**
- **Website user**
- **Administrator**
- **Extension user**

## Connections

- Gmail → n8n workflow: triggers on mail (evidence: `README.md`)
- n8n workflow → Gmail: labels and archives (evidence: `README.md`)
- n8n workflow → REST API: requests scoring (evidence: `README.md`)
- Website → n8n workflow: scans inbox (evidence: `README.md`)
- Website → REST API: uses API (evidence: `README.md`)
- Chrome extension → REST API: requests verdicts (evidence: `README.md`)
- REST API → Spam predictor: runs inference (evidence: `spam_detection/api_server.py`)
- REST API → Link/image checks: uses checks (evidence: `spam_detection/api_server.py`)
- REST API → Accounts and auth: routes auth (evidence: `spam_detection/api_server.py`)
- REST API → API keys: uses keys (evidence: `spam_detection/api_server.py`)
- REST API → Feedback and retraining: records feedback (evidence: `spam_detection/api_server.py`)
- REST API → Usage monitoring: records usage (evidence: `spam_detection/api_server.py`)
- Accounts and auth → Account database: reads and writes (evidence: `spam_detection/auth.py`)
- Feedback and retraining → Data loading: loads training data (evidence: `spam_detection/feedback_loop.py`)
- Feedback and retraining → Model trainer: starts retraining (evidence: `spam_detection/feedback_loop.py`)
- Dataset pipeline → Data loading: prepares data
- Model trainer → Data loading: loads data (evidence: `spam_detection/src/trainer.py`)
- Model trainer → BiLSTM and BERT: builds classifiers (evidence: `spam_detection/src/trainer.py`)
- Model trainer → Model configuration: uses settings (evidence: `spam_detection/src/trainer.py`)
- Spam predictor → BiLSTM and BERT: loads BiLSTM (evidence: `spam_detection/src/predict.py`)
- Spam predictor → Model configuration: uses model paths (evidence: `spam_detection/src/predict.py`)
- Website user → Website: uses (evidence: `README.md`)
- Administrator → Website: administers (evidence: `README.md`)
- Extension user → Chrome extension: configures and views (evidence: `README.md`)
- Website → Sign-in screens: renders (evidence: `web/src/App.tsx`)
- Website → User dashboard: renders (evidence: `web/src/App.tsx`)
- Website → Admin dashboard: renders (evidence: `web/src/App.tsx`)
- Sign-in screens → Web API client: calls auth API (evidence: `web/src/components/auth/AuthPage.tsx`)
- User dashboard → Web API client: requests scans (evidence: `web/src/components/user/UserDashboard.tsx`)
- Admin dashboard → Web API client: loads admin data (evidence: `web/src/components/admin/AdminDashboard.tsx`)
- Web API client → Account state: uses session (evidence: `web/src/lib/api.ts`)
- Web API client → Client settings: reads settings (evidence: `web/src/lib/api.ts`)
- User dashboard → Scan history: stores scan history (evidence: `web/src/components/user/UserDashboard.tsx`)
- User dashboard → Verdict rules: interprets results (evidence: `web/src/components/user/UserDashboard.tsx`)
