# aakash12312/mamscn architecture

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

- Interactive diagram: https://gitdiagram.com/aakash12312/mamscn
- Repository: https://github.com/aakash12312/mamscn

## Overview

This repository implements SNMP polling and streaming anomaly detection, with separate scripts for training detection and classification models. The main runtime path reads device inventory, polls SNMP metrics, publishes records to Kafka, then scores and classifies them before saving results to MySQL and CSV. Training scripts consume datasets and save model artifacts. The README is empty, so this map relies on the sampled source; simulator files and unsampled integrations are not linked where usage is unverified.

Main entry points: [`snmp_producer.py`](https://github.com/aakash12312/mamscn/blob/master/snmp_producer.py) (SNMP poller), [`consumer_writer_snmp.py`](https://github.com/aakash12312/mamscn/blob/master/consumer_writer_snmp.py) (Scoring consumer), [`isolation_forest_train.py`](https://github.com/aakash12312/mamscn/blob/master/isolation_forest_train.py) (Isolation training), [`classification.py`](https://github.com/aakash12312/mamscn/blob/master/classification.py) (Classifier training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Metric collection"]
  node_inventory["Device inventory<br/>[inventory.csv]"]
  node_poller["SNMP poller<br/>[snmp_producer.py]"]
  node_poll_log["Poll log"]
  node_kafka["Kafka topic"]
end

subgraph group_analysis["Anomaly analysis"]
  node_consumer["Scoring consumer"]
  node_model_artifacts["Model artifacts"]
end

subgraph group_training["Model training"]
  node_training_data["Training dataset<br/>[all_data &#40;3&#41;.csv]"]
  node_isolation_training["Isolation training"]
  node_classifier_training["Classifier training<br/>[classification.py]"]
  node_legacy_training["Random forest training<br/>[train_anomaly.py]"]
  node_legacy_model["Legacy model<br/>[random_forest.pkl]"]
end

subgraph group_outputs["Results and storage"]
  node_mysql[("MySQL metrics")]
  node_ai_csv["Scored CSV"]
end

node_operator(("Operator"))
node_snmp_devices(("SNMP devices"))

node_operator -->|"starts"| node_poller
node_poller -->|"reads"| node_inventory
node_poller -->|"polls"| node_snmp_devices
node_poller -->|"writes"| node_poll_log
node_poller -->|"publishes"| node_kafka
node_kafka -->|"delivers records"| node_consumer
node_consumer -->|"loads models"| node_model_artifacts
node_consumer -->|"writes metrics"| node_mysql
node_consumer -->|"writes scores"| node_ai_csv
node_operator -->|"starts"| node_isolation_training
node_operator -->|"starts"| node_classifier_training
node_isolation_training -->|"reads"| node_training_data
node_classifier_training -->|"reads"| node_training_data
node_isolation_training -->|"saves models"| node_model_artifacts
node_classifier_training -->|"saves models"| node_model_artifacts
node_operator -->|"starts"| node_legacy_training
node_legacy_training -->|"saves model"| node_legacy_model

click node_inventory "https://github.com/aakash12312/mamscn/blob/master/inventory.csv"
click node_poller "https://github.com/aakash12312/mamscn/blob/master/snmp_producer.py"
click node_poll_log "https://github.com/aakash12312/mamscn/blob/master/snmp_polled_data.csv"
click node_consumer "https://github.com/aakash12312/mamscn/blob/master/consumer_writer_snmp.py"
click node_training_data "https://github.com/aakash12312/mamscn/blob/master/datasets/all_data%20(3).csv"
click node_isolation_training "https://github.com/aakash12312/mamscn/blob/master/isolation_forest_train.py"
click node_classifier_training "https://github.com/aakash12312/mamscn/blob/master/classification.py"
click node_legacy_training "https://github.com/aakash12312/mamscn/blob/master/train_anomaly.py"
click node_model_artifacts "https://github.com/aakash12312/mamscn/tree/master/models"
click node_legacy_model "https://github.com/aakash12312/mamscn/blob/master/random_forest.pkl"
click node_ai_csv "https://github.com/aakash12312/mamscn/blob/master/snmp_consumed_ai.csv"

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_inventory,node_poller,node_poll_log,node_kafka toneBlue
class node_consumer,node_model_artifacts toneAmber
class node_training_data,node_isolation_training,node_classifier_training,node_legacy_training,node_legacy_model toneMint
class node_mysql,node_ai_csv toneRose
class node_operator,node_snmp_devices toneIndigo
```

## Components

### Metric collection

- [Device inventory](https://github.com/aakash12312/mamscn/blob/master/inventory.csv): `inventory.csv`
- [SNMP poller](https://github.com/aakash12312/mamscn/blob/master/snmp_producer.py): `snmp_producer.py`
- [Poll log](https://github.com/aakash12312/mamscn/blob/master/snmp_polled_data.csv): `snmp_polled_data.csv`
- **Kafka topic**

### Anomaly analysis

- [Scoring consumer](https://github.com/aakash12312/mamscn/blob/master/consumer_writer_snmp.py): `consumer_writer_snmp.py`
- [Model artifacts](https://github.com/aakash12312/mamscn/tree/master/models): `models`

### Model training

- [Training dataset](https://github.com/aakash12312/mamscn/blob/master/datasets/all_data%20(3).csv): `datasets/all_data (3).csv`
- [Isolation training](https://github.com/aakash12312/mamscn/blob/master/isolation_forest_train.py): `isolation_forest_train.py`
- [Classifier training](https://github.com/aakash12312/mamscn/blob/master/classification.py): `classification.py`
- [Random forest training](https://github.com/aakash12312/mamscn/blob/master/train_anomaly.py): `train_anomaly.py`
- [Legacy model](https://github.com/aakash12312/mamscn/blob/master/random_forest.pkl): `random_forest.pkl`

### Results and storage

- **MySQL metrics**
- [Scored CSV](https://github.com/aakash12312/mamscn/blob/master/snmp_consumed_ai.csv): `snmp_consumed_ai.csv`

### Other components

- **Operator**
- **SNMP devices**

## Connections

- Operator → SNMP poller: starts
- SNMP poller → Device inventory: reads (evidence: `snmp_producer.py`)
- SNMP poller → SNMP devices: polls (evidence: `snmp_producer.py`)
- SNMP poller → Poll log: writes (evidence: `snmp_producer.py`)
- SNMP poller → Kafka topic: publishes (evidence: `snmp_producer.py`)
- Kafka topic → Scoring consumer: delivers records (evidence: `consumer_writer_snmp.py`)
- Scoring consumer → Model artifacts: loads models (evidence: `consumer_writer_snmp.py`)
- Scoring consumer → MySQL metrics: writes metrics (evidence: `consumer_writer_snmp.py`)
- Scoring consumer → Scored CSV: writes scores (evidence: `consumer_writer_snmp.py`)
- Operator → Isolation training: starts
- Operator → Classifier training: starts
- Isolation training → Training dataset: reads (evidence: `isolation_forest_train.py`)
- Classifier training → Training dataset: reads (evidence: `classification.py`)
- Isolation training → Model artifacts: saves models (evidence: `isolation_forest_train.py`)
- Classifier training → Model artifacts: saves models (evidence: `classification.py`)
- Operator → Random forest training: starts
- Random forest training → Legacy model: saves model (evidence: `train_anomaly.py`)
