# kea-mindz/cyberbully architecture

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

- Interactive diagram: https://gitdiagram.com/kea-mindz/cyberbully
- Repository: https://github.com/kea-mindz/cyberbully

## Overview

Cyberbully is a Python package and CLI for transformer-based cyberbullying detection. Users submit text through the Python API, CLI, interactive console, or batch-file interface; the detector locates model assets, cleans and tokenizes input, runs binary and intent-category inference, and returns predictions and diagnostics. The README also documents nuance-aware classification and adversarial-text handling, reflected in the multi-task model and preprocessing components. The excerpts show these runtime calls and model-loading behavior; broader claims about distribution or training are not mapped as runtime components.

Main entry points: [`src/cyberbully/detector.py`](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/detector.py) (Detection engine), [`src/cyberbully/cli.py`](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/cli.py) (CLI and batch input), [`src/cyberbully/downloader.py`](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/downloader.py) (Model downloader), [`src/cyberbully/__init__.py`](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/__init__.py) (Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_python_api["Python API<br/>[__init__.py]"]
  node_cli["CLI and batch input<br/>[cli.py]"]
end

subgraph group_inference["Inference pipeline"]
  node_detector["Detection engine<br/>[detector.py]"]
  node_cleaner["Text preprocessing<br/>[preprocessing.py]"]
  node_tokenizer["Hugging Face tokenizer"]
  node_classifier["Multi-task classifier<br/>[model.py]"]
end

subgraph group_assets["Model assets and cache"]
  node_model_assets["Checkpoint and configs"]
  node_downloader["Model downloader<br/>[downloader.py]"]
  node_cache[("Local model cache")]
end

node_user(("Developer or moderator"))
node_drive["Google Drive"]

node_user -->|"submits text"| node_python_api
node_user -->|"submits text or file"| node_cli
node_python_api -->|"delegates prediction"| node_detector
node_cli -->|"runs inference"| node_detector
node_cli -->|"requests download"| node_downloader
node_detector -->|"resolves missing model"| node_downloader
node_detector -->|"cleans text"| node_cleaner
node_detector -->|"tokenizes batches"| node_tokenizer
node_detector -->|"runs inference"| node_classifier
node_detector -->|"loads weights and config"| node_model_assets
node_detector -->|"loads tokenizer assets"| node_model_assets
node_downloader -->|"writes downloaded assets"| node_cache
node_downloader -->|"downloads model files"| node_drive
node_classifier -->|"returns logits"| node_detector
node_detector -->|"returns predictions"| node_python_api
node_detector -->|"returns predictions"| node_cli
node_model_assets -->|"provides tokenizer files"| node_tokenizer

click node_python_api "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/__init__.py"
click node_cli "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/cli.py"
click node_detector "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/detector.py"
click node_cleaner "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/preprocessing.py"
click node_classifier "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/model.py"
click node_model_assets "https://github.com/kea-mindz/cyberbully/tree/main/models/cyberbully_v0.1_run"
click node_downloader "https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/downloader.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_python_api,node_cli toneBlue
class node_detector,node_cleaner,node_tokenizer,node_classifier toneAmber
class node_model_assets,node_downloader,node_cache toneMint
class node_user,node_drive toneIndigo
```

## Components

### User interfaces

- [Python API](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/__init__.py): `src/cyberbully/__init__.py`
- [CLI and batch input](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/cli.py): `src/cyberbully/cli.py`

### Inference pipeline

- [Detection engine](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/detector.py): `src/cyberbully/detector.py`
- [Text preprocessing](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/preprocessing.py): `src/cyberbully/preprocessing.py`
- **Hugging Face tokenizer**
- [Multi-task classifier](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/model.py): `src/cyberbully/model.py`

### Model assets and cache

- [Checkpoint and configs](https://github.com/kea-mindz/cyberbully/tree/main/models/cyberbully_v0.1_run): `models/cyberbully_v0.1_run`
- [Model downloader](https://github.com/kea-mindz/cyberbully/blob/main/src/cyberbully/downloader.py): `src/cyberbully/downloader.py`
- **Local model cache**

### Other components

- **Developer or moderator**
- **Google Drive**

## Connections

- Developer or moderator → Python API: submits text (evidence: `README.md`)
- Developer or moderator → CLI and batch input: submits text or file (evidence: `README.md`)
- Python API → Detection engine: delegates prediction (evidence: `src/cyberbully/__init__.py`)
- CLI and batch input → Detection engine: runs inference (evidence: `src/cyberbully/cli.py`)
- CLI and batch input → Model downloader: requests download (evidence: `src/cyberbully/cli.py`)
- Detection engine → Model downloader: resolves missing model (evidence: `src/cyberbully/detector.py`)
- Detection engine → Text preprocessing: cleans text (evidence: `src/cyberbully/detector.py`)
- Detection engine → Hugging Face tokenizer: tokenizes batches (evidence: `src/cyberbully/detector.py`)
- Detection engine → Multi-task classifier: runs inference (evidence: `src/cyberbully/detector.py`)
- Detection engine → Checkpoint and configs: loads weights and config (evidence: `src/cyberbully/detector.py`)
- Detection engine → Checkpoint and configs: loads tokenizer assets (evidence: `src/cyberbully/detector.py`)
- Model downloader → Local model cache: writes downloaded assets (evidence: `src/cyberbully/downloader.py`)
- Model downloader → Google Drive: downloads model files (evidence: `src/cyberbully/downloader.py`)
- Multi-task classifier → Detection engine: returns logits (evidence: `src/cyberbully/detector.py`)
- Detection engine → Python API: returns predictions (evidence: `src/cyberbully/__init__.py`)
- Detection engine → CLI and batch input: returns predictions (evidence: `src/cyberbully/cli.py`)
- Checkpoint and configs → Hugging Face tokenizer: provides tokenizer files
