# ctrlseun/flysec architecture

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

- Interactive diagram: https://gitdiagram.com/ctrlseun/flysec
- Repository: https://github.com/ctrlseun/flysec

## Overview

FLYSEC is an experimental research pipeline for testing connectome-based network anomaly detection, not a deployed service. Its central workflow prepares UNSW-NB15 flows, temporally stimulates a simulated FlyBrain connectome, extracts neural-activity features, and evaluates anomaly classifiers. The repository also contains earlier encoding/readout prototypes, feature and threshold analyses, and a conventional Random Forest comparison. The source excerpts show individual script behavior, but not all artifact handoffs; those links are marked unverified where appropriate.

Main entry points: [`src/flybrain_experiment4.py`](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment4.py) (Temporal evaluation), [`src/flybrain_experiment.py`](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment.py) (Initial experiment), [`src/flybrain_experiment2.py`](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment2.py) (Population encoding), [`src/flybrain_encoder.py`](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_encoder.py) (Basic encoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_encoding["Encoding Experiments"]
  node_exp1["Initial experiment"]
  node_exp2["Population encoding"]
  node_encoder["Basic encoder"]
  node_readout["Activity readout"]
  node_temporal["Temporal encoder"]
  node_exp4["Temporal evaluation"]
end

subgraph group_classification["Classification"]
  node_classifier["Logistic readout"]
  node_temporal_classifier["Temporal classifier"]
  node_baseline["Conventional baseline<br/>[baseline.py]"]
  node_final["Final comparison"]
end

subgraph group_analysis["Analysis"]
  node_threshold["Threshold evaluation"]
  node_feature_analysis["Feature analysis"]
  node_selection["Feature selection"]
end

node_researcher(("Researcher"))
node_unsw["UNSW-NB15 flows"]
node_flybrain["FlyBrain simulator"]

node_researcher -.->|"runs evaluation"| node_exp4
node_unsw -->|"provides flows"| node_exp4
node_exp4 -->|"stimulates and steps"| node_flybrain
node_exp4 -.->|"writes features"| node_classifier
node_classifier -.->|"supplies scores"| node_threshold
node_exp4 -->|"supplies features"| node_feature_analysis
node_exp4 -.->|"supplies features"| node_selection
node_exp4 -.->|"supplies features"| node_final
node_unsw -->|"provides flows"| node_exp1
node_exp1 -->|"stimulates and steps"| node_flybrain
node_unsw -->|"provides flows"| node_exp2
node_exp2 -->|"stimulates and steps"| node_flybrain
node_unsw -->|"provides flows"| node_encoder
node_encoder -->|"stimulates and steps"| node_flybrain
node_unsw -->|"provides flows"| node_readout
node_readout -->|"stimulates and steps"| node_flybrain
node_unsw -->|"provides flows"| node_temporal
node_temporal -->|"stimulates and steps"| node_flybrain
node_researcher -.->|"runs comparison"| node_baseline
node_researcher -.->|"runs classifier"| node_temporal_classifier
node_researcher -.->|"runs comparison"| node_final

click node_exp1 "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment.py"
click node_exp2 "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment2.py"
click node_encoder "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_encoder.py"
click node_readout "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_readout.py"
click node_temporal "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_temporal_encoder.py"
click node_exp4 "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment4.py"
click node_classifier "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment4_classifier.py"
click node_temporal_classifier "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_temporal_classifier.py"
click node_baseline "https://github.com/ctrlseun/flysec/blob/main/src/baseline.py"
click node_threshold "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment5_threshold.py"
click node_feature_analysis "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment6_analysis.py"
click node_selection "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment7_selection.py"
click node_final "https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment8_final.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_exp1,node_exp2,node_encoder,node_readout,node_temporal,node_exp4 toneBlue
class node_classifier,node_temporal_classifier,node_baseline,node_final toneAmber
class node_threshold,node_feature_analysis,node_selection toneMint
class node_researcher,node_unsw,node_flybrain toneIndigo
```

## Components

### Encoding Experiments

- [Initial experiment](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment.py): `src/flybrain_experiment.py`
- [Population encoding](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment2.py): `src/flybrain_experiment2.py`
- [Basic encoder](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_encoder.py): `src/flybrain_encoder.py`
- [Activity readout](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_readout.py): `src/flybrain_readout.py`
- [Temporal encoder](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_temporal_encoder.py): `src/flybrain_temporal_encoder.py`
- [Temporal evaluation](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment4.py): `src/flybrain_experiment4.py`

### Classification

- [Logistic readout](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment4_classifier.py): `src/flybrain_experiment4_classifier.py`
- [Temporal classifier](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_temporal_classifier.py): `src/flybrain_temporal_classifier.py`
- [Conventional baseline](https://github.com/ctrlseun/flysec/blob/main/src/baseline.py): `src/baseline.py`
- [Final comparison](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment8_final.py): `src/flybrain_experiment8_final.py`

### Analysis

- [Threshold evaluation](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment5_threshold.py): `src/flybrain_experiment5_threshold.py`
- [Feature analysis](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment6_analysis.py): `src/flybrain_experiment6_analysis.py`
- [Feature selection](https://github.com/ctrlseun/flysec/blob/main/src/flybrain_experiment7_selection.py): `src/flybrain_experiment7_selection.py`

### Other components

- **Researcher**
- **UNSW-NB15 flows**
- **FlyBrain simulator**

## Connections

- Researcher → Temporal evaluation: runs evaluation
- UNSW-NB15 flows → Temporal evaluation: provides flows (evidence: `src/flybrain_experiment4.py`)
- Temporal evaluation → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_experiment4.py`)
- Temporal evaluation → Logistic readout: writes features
- Logistic readout → Threshold evaluation: supplies scores
- Temporal evaluation → Feature analysis: supplies features (evidence: `src/flybrain_experiment6_analysis.py`)
- Temporal evaluation → Feature selection: supplies features
- Temporal evaluation → Final comparison: supplies features
- UNSW-NB15 flows → Initial experiment: provides flows (evidence: `src/flybrain_experiment.py`)
- Initial experiment → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_experiment.py`)
- UNSW-NB15 flows → Population encoding: provides flows (evidence: `src/flybrain_experiment2.py`)
- Population encoding → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_experiment2.py`)
- UNSW-NB15 flows → Basic encoder: provides flows (evidence: `src/flybrain_encoder.py`)
- Basic encoder → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_encoder.py`)
- UNSW-NB15 flows → Activity readout: provides flows (evidence: `src/flybrain_readout.py`)
- Activity readout → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_readout.py`)
- UNSW-NB15 flows → Temporal encoder: provides flows (evidence: `src/flybrain_temporal_encoder.py`)
- Temporal encoder → FlyBrain simulator: stimulates and steps (evidence: `src/flybrain_temporal_encoder.py`)
- Researcher → Conventional baseline: runs comparison
- Researcher → Temporal classifier: runs classifier
- Researcher → Final comparison: runs comparison
