# andrea-pomarico/multi_agent_ai_dsa_power_systems architecture

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

- Interactive diagram: https://gitdiagram.com/andrea-pomarico/multi_agent_ai_dsa_power_systems
- Repository: https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems

## Overview

1. **Overall shape**
   - This repo is a **sequential multi-agent pipeline** for dynamic security assessment of power systems.
   - The main entrypoint, `Multi_Agent_AI_DSA_Power_Systems.py`, orchestrates a staged workflow: intake → simulation → analysis → plotting → LLM reporting → comparison → presentation/mitigation → report export.

2. **Primary external boundary: DIgSILENT PowerFactory**
   - The core non-Python dependency is **DIgSILENT PowerFactory**, accessed through `Agent_DIgSILENT.py`.
   - That module appears to encapsulate the PowerFactory automation boundary and the `SimulationConfig` model used to define fault cases and run RMS simulations.
   - The rest of the pipeline consumes exported simulation artifacts rather than talking to PowerFactory directly.

3. **Input/configuration boundary**
   - User scenarios enter the system in one of two ways:
     - A structured JSON config (`simulation_config.example.json` as the template).
     - Natural-language scenario descriptions processed by **Agent 0** in `agent_intake.py`.
   - This is the main transformation boundary from “engineering intent” to machine-executable simulation cases.

4. **Agent 0: Intake / scenario normalization**
   - `agent_intake.py` converts free-form descriptions into structured fault cases.
   - This stage feeds the rest of the pipeline by producing normalized scenario definitions, so downstream agents can operate deterministically.

5. **Agent 1: Simulation**
   - `agent_simulation.py` runs the fault/stability simulations in PowerFactory and exports results, likely as CSV time-series data.
   - This is the hard simulation boundary: everything after this stage works on files and computed outputs, not on the simulator itself.

6. **Agent 2: Analysis**
   - `agent_analysis.py` reads simulation outputs and computes stability KPIs from voltages, speeds, angles, and related signals.
   - This is the quantitative core of the pipeline: it converts raw time-series into engineering metrics and violation summaries that later agents must cite accurately.

7. **Agent 3: Plotting**
   - `agent_plot.py` turns analyzed results into PNG time-series and comparison graphics.
   - The plots are a derived visualization layer, used both for human review and likely for embedding into reports or presentations.

8. **LLM reporting subsystem**
   - `agent_llm_reporting.py` implements the narrative generation chain for **Agents 4–7**:
     - draft summary
     - fact-check/review
     - final polished report
     - cross-case comparison and risk assessment
   - The README explicitly describes a **draft → review → final** loop, which is important architecturally because it constrains the LLM with computed KPIs instead of allowing free-form reporting.

9. **Mitigation and recommendation layer**
   - `agent_mitigation.py` produces ranked mitigation actions.
   - This is a decision-support layer that consumes analysis/comparison results and outputs prioritized operational or planning actions.

10. **Presentation output**
    - `agent_presentation.py` generates a `.pptx` presentation.
    - This is a separate output channel from the textual report, aimed at executive or briefing use rather than detailed engineering documentation.

11. **Document and file output utilities**
    - `report_utils.py` provides persistence helpers for writing report artifacts to disk.
    - The README notes a deliberate choice to avoid `python-docx`; instead, Word reports are produced with stdlib `zipfile` and raw OOXML, which makes document generation a standalone utility boundary.

12. **LLM abstraction and prompt management**
    - `llm_client.py` is a provider-agnostic LLM wrapper, so the pipeline is not coupled to a single model vendor.
    - `prompt_loader.py` and `agent_prompts.csv` externalize system prompts, which keeps prompting data separate from orchestration code.

13. **Artifact flow between stages**
    - The main data path is:
      - config / scenario text
      - structured cases
      - simulation outputs
      - KPI analysis results
      - plots
      - LLM-generated narrative and review
      - comparative assessment
      - final documents/presentation/mitigation outputs
    - The architecture is file-artifact driven, with CSV/PNG/DOCX/PPTX acting as the main inter-agent interfaces.

14. **What to show in an architecture diagram**
    - Draw one clear external system box for **PowerFactory**.
    - Show the Python pipeline as a set of ordered agents with two key branches after analysis:
      - visualization/reporting
      - comparison/mitigation/presentation
    - Emphasize that the LLM is **not** the source of truth; it is constrained by simulation-derived KPIs and used for interpretation, review, and polished narration.

Main entry points: [`agent_analysis.py`](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_analysis.py) (Analysis), [`agent_llm_reporting.py`](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_llm_reporting.py) (LLM report), [`agent_simulation.py`](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_simulation.py) (Simulation), [`Multi_Agent_AI_DSA_Power_Systems.py`](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Multi_Agent_AI_DSA_Power_Systems.py) (Orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_external["External system"]
  node_pf[("PowerFactory<br/>simulator<br/>[Agent_DIgSILENT.py]")]
end

subgraph group_pipeline["Python pipeline"]
  node_main["Orchestrator<br/>entrypoint"]
  node_intake["Intake<br/>agent<br/>[agent_intake.py]"]
  node_dig["PowerFactory API<br/>automation boundary<br/>[Agent_DIgSILENT.py]"]
  node_sim["Simulation<br/>agent"]
  node_analysis["Analysis<br/>agent<br/>[agent_analysis.py]"]
  node_plot["Plots<br/>agent<br/>[agent_plot.py]"]
  node_report["LLM report<br/>llm pipeline"]
  node_mitigation["Mitigation<br/>decision support"]
  node_presentation["Presentation<br/>output agent"]
  node_utils["Report utils<br/>artifact writer<br/>[report_utils.py]"]
  node_llm["LLM client<br/>abstraction<br/>[llm_client.py]"]
  node_prompts["Prompt loader<br/>config loader<br/>[prompt_loader.py]"]
end

subgraph group_artifacts["Inputs and prompts"]
  node_sim_cfg["Scenario config<br/>input template"]
  node_prompt_csv["Prompts<br/>prompt data<br/>[agent_prompts.csv]"]
end

node_main -->|"scenario in"| node_intake
node_main -->|"template"| node_sim_cfg
node_intake -->|"cases"| node_sim
node_sim_cfg -->|"config"| node_sim
node_sim -->|"run via"| node_dig
node_dig -->|"execute"| node_pf
node_sim -->|"outputs"| node_analysis
node_analysis -->|"metrics"| node_plot
node_analysis -->|"facts"| node_report
node_plot -->|"figures"| node_report
node_analysis -->|"findings"| node_mitigation
node_analysis -->|"briefing data"| node_presentation
node_report -->|"export"| node_utils
node_presentation -->|"export"| node_utils
node_prompts -->|"prompting"| node_report
node_prompt_csv -->|"load"| node_prompts
node_llm -->|"model access"| node_report

click node_main "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Multi_Agent_AI_DSA_Power_Systems.py"
click node_intake "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_intake.py"
click node_sim_cfg "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/simulation_config.example.json"
click node_pf "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Agent_DIgSILENT.py"
click node_dig "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Agent_DIgSILENT.py"
click node_sim "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_simulation.py"
click node_analysis "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_analysis.py"
click node_plot "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_plot.py"
click node_report "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_llm_reporting.py"
click node_mitigation "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_mitigation.py"
click node_presentation "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_presentation.py"
click node_utils "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/report_utils.py"
click node_llm "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/llm_client.py"
click node_prompts "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/prompt_loader.py"
click node_prompt_csv "https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_prompts.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_pf toneBlue
class node_main,node_intake,node_dig,node_sim,node_analysis,node_plot,node_report,node_mitigation,node_presentation,node_utils,node_llm,node_prompts toneAmber
class node_sim_cfg,node_prompt_csv toneMint
```

## Components

### External system

Non-Python simulation boundary.

- [PowerFactory](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Agent_DIgSILENT.py): simulator · External DIgSILENT PowerFactory environment for RMS fault simulation. · `Agent_DIgSILENT.py`

### Python pipeline

Sequential agent workflow for assessment and reporting.

- [Orchestrator](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Multi_Agent_AI_DSA_Power_Systems.py): entrypoint · Main script coordinating the staged multi-agent workflow. · `Multi_Agent_AI_DSA_Power_Systems.py`
- [Intake](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_intake.py): agent · Normalizes free-form scenarios into structured fault cases. · `agent_intake.py`
- [PowerFactory API](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/Agent_DIgSILENT.py): automation boundary · Python wrapper around PowerFactory access and simulation configuration. · `Agent_DIgSILENT.py`
- [Simulation](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_simulation.py): agent · Runs fault and stability cases and exports simulation outputs. · `agent_simulation.py`
- [Analysis](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_analysis.py): agent · Computes stability KPIs and violation summaries from time-series outputs. · `agent_analysis.py`
- [Plots](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_plot.py): agent · Generates comparison charts and time-series visualizations. · `agent_plot.py`
- [LLM report](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_llm_reporting.py): llm pipeline · Draft, review, final, and comparison narrative generation constrained by computed KPIs. · `agent_llm_reporting.py`
- [Mitigation](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_mitigation.py): decision support · Ranks operational or planning mitigation actions from analysis results. · `agent_mitigation.py`
- [Presentation](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_presentation.py): output agent · Builds a PPTX briefing from the assessed cases and findings. · `agent_presentation.py`
- [Report utils](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/report_utils.py): artifact writer · Persists report artifacts and handles document export helpers. · `report_utils.py`
- [LLM client](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/llm_client.py): abstraction · Provider-agnostic wrapper for model access used by reporting stages. · `llm_client.py`
- [Prompt loader](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/prompt_loader.py): config loader · Loads externalized prompts for the reporting chain. · `prompt_loader.py`

### Inputs and prompts

Structured config and prompt assets consumed by the pipeline.

- [Scenario config](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/simulation_config.example.json): input template · Example structured simulation configuration used as a starting point. · `simulation_config.example.json`
- [Prompts](https://github.com/andrea-pomarico/multi_agent_ai_dsa_power_systems/blob/main/agent_prompts.csv): prompt data · CSV prompt definitions for the LLM agents. · `agent_prompts.csv`

## Connections

- Orchestrator → Intake: scenario in · Start from natural-language or structured scenario inputs.
- Orchestrator → Scenario config: template · Structured configuration seed for simulations.
- Intake → Simulation: cases · Normalized fault cases become executable simulation inputs.
- Scenario config → Simulation: config · Simulation parameters and case definitions are supplied to the runner.
- Simulation → PowerFactory API: run via · Simulation stage delegates PowerFactory automation to the boundary wrapper.
- PowerFactory API → PowerFactory: execute · Wrapper controls the external PowerFactory environment.
- Simulation → Analysis: outputs · Exported time-series and case results feed KPI analysis.
- Analysis → Plots: metrics · Computed KPIs drive visual comparisons and plots.
- Analysis → LLM report: facts · Quantitative results constrain narrative generation and review.
- Plots → LLM report: figures · Plots can be embedded or referenced in reporting.
- Analysis → Mitigation: findings · Violation summaries and metrics inform mitigation ranking.
- Analysis → Presentation: briefing data · Presentation layer consumes analyzed outcomes and summaries.
- LLM report → Report utils: export · Narrative artifacts are persisted through report utilities.
- Presentation → Report utils: export · PPTX output uses the shared artifact-writing helpers.
- Prompt loader → LLM report: prompting · Reporting stages are driven by externalized prompt definitions.
- Prompts → Prompt loader: load · Prompt loader reads the CSV prompt bank.
- LLM client → LLM report: model access · LLM client provides vendor-agnostic generation and review calls.
