# risaryan9/project-seraph architecture

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

- Interactive diagram: https://gitdiagram.com/risaryan9/project-seraph
- Repository: https://github.com/risaryan9/project-seraph

## Overview

Seraph profiles concurrent ML workloads, attributes hardware metrics to execution phases, and sends samples through Kafka for storage and live viewing. Its FastAPI backend queries InfluxDB and exposes REST and WebSocket access, with additional optimizer analysis, process diagnostics, and Slack notifications. The graph preserves those documented capabilities; several API relationships are supported by the SOURCE INDEX rather than full excerpts, and the Kafka-to-WebSocket bridge details are not sampled.

Main entry points: [`mlviz/profiler/agent.py`](https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/agent.py) (Hardware Profiler), [`mlviz/api/routes.py`](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/routes.py) (Metrics and Analysis Routes), [`mlviz/api/main.py`](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/main.py) (FastAPI Backend), [`mlviz/api/influx.py`](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/influx.py) (Influx Query Helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workloads["Workload Simulation"]
  node_resnet["ResNet Workload<br/>[resnet_main.py]"]
  node_bert["BERT Workload<br/>[bert_main.py]"]
  node_pipeline["Data Pipeline<br/>[pipeline_main.py]"]
  node_runners["Workload Runners<br/>[runners.py]"]
  node_orchestrator["Local Orchestrator<br/>[orchestrator.py]"]
end

subgraph group_collection["Metric Collection"]
  node_agent["Hardware Profiler<br/>[agent.py]"]
  node_sample["Metric Sample<br/>[metrics.py]"]
end

subgraph group_streaming["Metric Streaming"]
  node_producer["Kafka Producer<br/>[kafka_producer.py]"]
  node_aggregator["Batch Aggregator<br/>[service.py]"]
  node_liveview["Terminal Live View<br/>[service.py]"]
end

subgraph group_storage["Time-Series Storage"]
  node_influx[("InfluxDB Metrics")]
end

subgraph group_api["API and Analysis"]
  node_api["FastAPI Backend<br/>[main.py]"]
  node_routes["Metrics and Analysis Routes<br/>[routes.py]"]
  node_influxhelper["Influx Query Helper<br/>[influx.py]"]
  node_bridge["Kafka WebSocket Bridge<br/>[kafka_bridge.py]"]
  node_diagnostics["Process Diagnostics"]
  node_optimizer["Optimizer Diagnostics"]
  node_slack["Slack Notifications<br/>[slack_notifier.py]"]
end

node_operator(("Workload Operator"))
node_broker["Kafka Broker"]
node_apiuser(("API Consumer"))

node_operator -->|"starts locally"| node_orchestrator
node_orchestrator -->|"spawns runners"| node_runners
node_runners -->|"collects metrics"| node_agent
node_resnet -->|"starts profiler"| node_agent
node_bert -->|"starts profiler"| node_agent
node_pipeline -->|"starts profiler"| node_agent
node_agent -->|"creates samples"| node_sample
node_agent -->|"sends samples"| node_producer
node_producer -->|"publishes metrics"| node_broker
node_broker -->|"streams metrics"| node_aggregator
node_aggregator -->|"batch writes"| node_influx
node_broker -->|"streams metrics"| node_liveview
node_apiuser -->|"queries or streams"| node_api
node_api -->|"registers routes"| node_routes
node_api -->|"connects database"| node_influxhelper
node_api -->|"starts consumer"| node_bridge
node_routes -->|"queries metrics"| node_influxhelper
node_influxhelper -->|"reads metrics"| node_influx
node_routes -->|"gets process context"| node_diagnostics
node_routes -->|"analyzes metrics"| node_optimizer
node_routes -->|"sends notifications"| node_slack
node_broker -.->|"feeds live stream"| node_bridge

click node_resnet "https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/resnet_main.py"
click node_bert "https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/bert_main.py"
click node_pipeline "https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/pipeline_main.py"
click node_runners "https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/runners.py"
click node_orchestrator "https://github.com/risaryan9/project-seraph/blob/master/orchestrator.py"
click node_agent "https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/agent.py"
click node_sample "https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/metrics.py"
click node_producer "https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/kafka_producer.py"
click node_aggregator "https://github.com/risaryan9/project-seraph/blob/master/mlviz/aggregator/service.py"
click node_liveview "https://github.com/risaryan9/project-seraph/blob/master/mlviz/live_view/service.py"
click node_api "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/main.py"
click node_routes "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/routes.py"
click node_influxhelper "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/influx.py"
click node_bridge "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/kafka_bridge.py"
click node_diagnostics "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/model_process_pids.py"
click node_optimizer "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/optimizer_diagnostics.py"
click node_slack "https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/slack_notifier.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_resnet,node_bert,node_pipeline,node_runners,node_orchestrator toneBlue
class node_agent,node_sample toneAmber
class node_producer,node_aggregator,node_liveview,node_apiuser toneMint
class node_influx toneRose
class node_api,node_routes,node_influxhelper,node_bridge,node_diagnostics,node_optimizer,node_slack,node_operator,node_broker toneIndigo
```

## Components

### Workload Simulation

- [ResNet Workload](https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/resnet_main.py): `mlviz/workloads/resnet_main.py`
- [BERT Workload](https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/bert_main.py): `mlviz/workloads/bert_main.py`
- [Data Pipeline](https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/pipeline_main.py): `mlviz/workloads/pipeline_main.py`
- [Workload Runners](https://github.com/risaryan9/project-seraph/blob/master/mlviz/workloads/runners.py): `mlviz/workloads/runners.py`
- [Local Orchestrator](https://github.com/risaryan9/project-seraph/blob/master/orchestrator.py): `orchestrator.py`

### Metric Collection

- [Hardware Profiler](https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/agent.py): `mlviz/profiler/agent.py`
- [Metric Sample](https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/metrics.py): `mlviz/profiler/metrics.py`

### Metric Streaming

- [Kafka Producer](https://github.com/risaryan9/project-seraph/blob/master/mlviz/profiler/kafka_producer.py): `mlviz/profiler/kafka_producer.py`
- [Batch Aggregator](https://github.com/risaryan9/project-seraph/blob/master/mlviz/aggregator/service.py): `mlviz/aggregator/service.py`
- [Terminal Live View](https://github.com/risaryan9/project-seraph/blob/master/mlviz/live_view/service.py): `mlviz/live_view/service.py`

### Time-Series Storage

- **InfluxDB Metrics**

### API and Analysis

- [FastAPI Backend](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/main.py): `mlviz/api/main.py`
- [Metrics and Analysis Routes](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/routes.py): `mlviz/api/routes.py`
- [Influx Query Helper](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/influx.py): `mlviz/api/influx.py`
- [Kafka WebSocket Bridge](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/kafka_bridge.py): `mlviz/api/kafka_bridge.py`
- [Process Diagnostics](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/model_process_pids.py): `mlviz/api/model_process_pids.py`
- [Optimizer Diagnostics](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/optimizer_diagnostics.py): `mlviz/api/optimizer_diagnostics.py`
- [Slack Notifications](https://github.com/risaryan9/project-seraph/blob/master/mlviz/api/slack_notifier.py): `mlviz/api/slack_notifier.py`

### Other components

- **Workload Operator**
- **Kafka Broker**
- **API Consumer**

## Connections

- Workload Operator → Local Orchestrator: starts locally (evidence: `README.md`)
- Local Orchestrator → Workload Runners: spawns runners (evidence: `orchestrator.py`)
- Workload Runners → Hardware Profiler: collects metrics (evidence: `mlviz/workloads/runners.py`)
- ResNet Workload → Hardware Profiler: starts profiler (evidence: `mlviz/workloads/resnet_main.py`)
- BERT Workload → Hardware Profiler: starts profiler (evidence: `mlviz/workloads/bert_main.py`)
- Data Pipeline → Hardware Profiler: starts profiler (evidence: `mlviz/workloads/pipeline_main.py`)
- Hardware Profiler → Metric Sample: creates samples (evidence: `mlviz/profiler/agent.py`)
- Hardware Profiler → Kafka Producer: sends samples (evidence: `mlviz/profiler/agent.py`)
- Kafka Producer → Kafka Broker: publishes metrics (evidence: `mlviz/profiler/kafka_producer.py`)
- Kafka Broker → Batch Aggregator: streams metrics (evidence: `README.md`)
- Batch Aggregator → InfluxDB Metrics: batch writes (evidence: `README.md`)
- Kafka Broker → Terminal Live View: streams metrics (evidence: `README.md`)
- API Consumer → FastAPI Backend: queries or streams (evidence: `README.md`)
- FastAPI Backend → Metrics and Analysis Routes: registers routes (evidence: `mlviz/api/main.py`)
- FastAPI Backend → Influx Query Helper: connects database (evidence: `mlviz/api/main.py`)
- FastAPI Backend → Kafka WebSocket Bridge: starts consumer (evidence: `mlviz/api/main.py`)
- Metrics and Analysis Routes → Influx Query Helper: queries metrics (evidence: `mlviz/api/routes.py`)
- Influx Query Helper → InfluxDB Metrics: reads metrics (evidence: `mlviz/api/influx.py`)
- Metrics and Analysis Routes → Process Diagnostics: gets process context (evidence: `mlviz/api/routes.py`)
- Metrics and Analysis Routes → Optimizer Diagnostics: analyzes metrics (evidence: `mlviz/api/routes.py`)
- Metrics and Analysis Routes → Slack Notifications: sends notifications (evidence: `mlviz/api/routes.py`)
- Kafka Broker → Kafka WebSocket Bridge: feeds live stream
