# joemooney/pacgate architecture

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

- Interactive diagram: https://gitdiagram.com/joemooney/pacgate
- Repository: https://github.com/joemooney/pacgate

## Overview

PacGate compiles YAML packet-filter rules into hardware and software implementations, with simulation and verification outputs derived from the same specification. Its principal workflow is rules input → configuration loading → CLI-directed simulation or code generation → generated artifacts and verification. The README documents additional import, PCAP, and analysis capabilities; their exact internal wiring is not established by the sampled excerpts, so those branches are shown without speculative links. The simulator-app wiring is supported by its backend and UI excerpts.

Main entry points: [`src/main.rs`](https://github.com/joemooney/pacgate/blob/main/src/main.rs) (PacGate CLI), [`verification/driver.py`](https://github.com/joemooney/pacgate/blob/main/verification/driver.py) (Verification Driver), [`verification/coverage_driven.py`](https://github.com/joemooney/pacgate/blob/main/verification/coverage_driven.py) (Coverage-Directed Tests), [`src/loader.rs`](https://github.com/joemooney/pacgate/blob/main/src/loader.rs) (Rule Loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Rule Compiler"]
  node_cli["PacGate CLI<br/>[main.rs]"]
  node_loader["Rule Loader<br/>[loader.rs]"]
  node_config["Filter Model<br/>[model.rs]"]
end

subgraph group_outputs["Generated Targets"]
  node_hardware["Verilog Generator<br/>[verilog_gen.rs]"]
  node_software["Rust Generator<br/>[rust_gen.rs]"]
  node_p4["P4 Generator<br/>[p4_gen.rs]"]
end

subgraph group_verification["Verification"]
  node_formal["Formal Generator<br/>[formal_gen.rs]"]
  node_cocotb["Cocotb Generator<br/>[cocotb_gen.rs]"]
  node_verification_driver["Verification Driver<br/>[driver.py]"]
  node_packet_factory["Packet Factory<br/>[packet.py]"]
  node_coverage["Coverage Collector<br/>[coverage.py]"]
  node_coverage_directed["Coverage-Directed Tests<br/>[coverage_driven.py]"]
end

subgraph group_analysis["Packet Analysis"]
  node_pcap_import["PCAP Reader<br/>[pcap.rs]"]
  node_pcap_analysis["PCAP Analyzer<br/>[pcap_analyze.rs]"]
  node_pcap_generation["PCAP Generator<br/>[pcap_gen.rs]"]
  node_rule_imports["Rule Importers<br/>[acl_import.rs]"]
end

subgraph group_simulator["Simulation Tools"]
  node_simulator_engine["Rule Simulator<br/>[simulator.rs]"]
  node_simulator_cli["Simulator CLI<br/>[main.rs]"]
  node_web_ui["Simulator Web UI<br/>[app.js]"]
  node_web_backend["Simulator Backend<br/>[server.py]"]
end

node_rules_user(("Rule Author"))

node_rules_user -->|"provides rules"| node_cli
node_cli -->|"loads rules"| node_loader
node_loader -->|"builds config"| node_config
node_cli -->|"generates RTL"| node_hardware
node_cli -->|"generates filter"| node_software
node_cli -->|"generates P4"| node_p4
node_cli -->|"generates assertions"| node_formal
node_cli -->|"generates tests"| node_cocotb
node_cli -->|"simulates packets"| node_simulator_engine
node_verification_driver -->|"builds frames"| node_packet_factory
node_verification_driver -->|"collects coverage"| node_coverage
node_coverage_directed -->|"reads gaps"| node_coverage
node_coverage_directed -->|"generates frames"| node_packet_factory
node_web_ui -->|"calls API"| node_web_backend
node_web_backend -->|"runs simulation"| node_simulator_cli
node_simulator_cli -->|"evaluates rules"| node_simulator_engine

click node_cli "https://github.com/joemooney/pacgate/blob/main/src/main.rs"
click node_loader "https://github.com/joemooney/pacgate/blob/main/src/loader.rs"
click node_config "https://github.com/joemooney/pacgate/blob/main/src/model.rs"
click node_hardware "https://github.com/joemooney/pacgate/blob/main/src/verilog_gen.rs"
click node_software "https://github.com/joemooney/pacgate/blob/main/src/rust_gen.rs"
click node_p4 "https://github.com/joemooney/pacgate/blob/main/src/p4_gen.rs"
click node_formal "https://github.com/joemooney/pacgate/blob/main/src/formal_gen.rs"
click node_cocotb "https://github.com/joemooney/pacgate/blob/main/src/cocotb_gen.rs"
click node_verification_driver "https://github.com/joemooney/pacgate/blob/main/verification/driver.py"
click node_packet_factory "https://github.com/joemooney/pacgate/blob/main/verification/packet.py"
click node_coverage "https://github.com/joemooney/pacgate/blob/main/verification/coverage.py"
click node_coverage_directed "https://github.com/joemooney/pacgate/blob/main/verification/coverage_driven.py"
click node_pcap_import "https://github.com/joemooney/pacgate/blob/main/src/pcap.rs"
click node_pcap_analysis "https://github.com/joemooney/pacgate/blob/main/src/pcap_analyze.rs"
click node_pcap_generation "https://github.com/joemooney/pacgate/blob/main/src/pcap_gen.rs"
click node_rule_imports "https://github.com/joemooney/pacgate/blob/main/src/acl_import.rs"
click node_simulator_engine "https://github.com/joemooney/pacgate/blob/main/src/simulator.rs"
click node_simulator_cli "https://github.com/joemooney/pacgate/blob/main/src/main.rs"
click node_web_ui "https://github.com/joemooney/pacgate/blob/main/simulator-app/web/app.js"
click node_web_backend "https://github.com/joemooney/pacgate/blob/main/simulator-app/server.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_cli,node_loader,node_config toneBlue
class node_hardware,node_software,node_p4 toneAmber
class node_formal,node_cocotb,node_verification_driver,node_packet_factory,node_coverage,node_coverage_directed toneMint
class node_pcap_import,node_pcap_analysis,node_pcap_generation,node_rule_imports toneRose
class node_simulator_engine,node_simulator_cli,node_web_ui,node_web_backend,node_rules_user toneIndigo
```

## Components

### Rule Compiler

- [PacGate CLI](https://github.com/joemooney/pacgate/blob/main/src/main.rs): `src/main.rs`
- [Rule Loader](https://github.com/joemooney/pacgate/blob/main/src/loader.rs): `src/loader.rs`
- [Filter Model](https://github.com/joemooney/pacgate/blob/main/src/model.rs): `src/model.rs`

### Generated Targets

- [Verilog Generator](https://github.com/joemooney/pacgate/blob/main/src/verilog_gen.rs): `src/verilog_gen.rs`
- [Rust Generator](https://github.com/joemooney/pacgate/blob/main/src/rust_gen.rs): `src/rust_gen.rs`
- [P4 Generator](https://github.com/joemooney/pacgate/blob/main/src/p4_gen.rs): `src/p4_gen.rs`

### Verification

- [Formal Generator](https://github.com/joemooney/pacgate/blob/main/src/formal_gen.rs): `src/formal_gen.rs`
- [Cocotb Generator](https://github.com/joemooney/pacgate/blob/main/src/cocotb_gen.rs): `src/cocotb_gen.rs`
- [Verification Driver](https://github.com/joemooney/pacgate/blob/main/verification/driver.py): `verification/driver.py`
- [Packet Factory](https://github.com/joemooney/pacgate/blob/main/verification/packet.py): `verification/packet.py`
- [Coverage Collector](https://github.com/joemooney/pacgate/blob/main/verification/coverage.py): `verification/coverage.py`
- [Coverage-Directed Tests](https://github.com/joemooney/pacgate/blob/main/verification/coverage_driven.py): `verification/coverage_driven.py`

### Packet Analysis

- [PCAP Reader](https://github.com/joemooney/pacgate/blob/main/src/pcap.rs): `src/pcap.rs`
- [PCAP Analyzer](https://github.com/joemooney/pacgate/blob/main/src/pcap_analyze.rs): `src/pcap_analyze.rs`
- [PCAP Generator](https://github.com/joemooney/pacgate/blob/main/src/pcap_gen.rs): `src/pcap_gen.rs`
- [Rule Importers](https://github.com/joemooney/pacgate/blob/main/src/acl_import.rs): `src/acl_import.rs`

### Simulation Tools

- [Rule Simulator](https://github.com/joemooney/pacgate/blob/main/src/simulator.rs): `src/simulator.rs`
- [Simulator CLI](https://github.com/joemooney/pacgate/blob/main/src/main.rs): `src/main.rs`
- [Simulator Web UI](https://github.com/joemooney/pacgate/blob/main/simulator-app/web/app.js): `simulator-app/web/app.js`
- [Simulator Backend](https://github.com/joemooney/pacgate/blob/main/simulator-app/server.py): `simulator-app/server.py`

### Other components

- **Rule Author**

## Connections

- Rule Author → PacGate CLI: provides rules
- PacGate CLI → Rule Loader: loads rules
- Rule Loader → Filter Model: builds config
- PacGate CLI → Verilog Generator: generates RTL
- PacGate CLI → Rust Generator: generates filter
- PacGate CLI → P4 Generator: generates P4
- PacGate CLI → Formal Generator: generates assertions
- PacGate CLI → Cocotb Generator: generates tests
- PacGate CLI → Rule Simulator: simulates packets
- Verification Driver → Packet Factory: builds frames
- Verification Driver → Coverage Collector: collects coverage
- Coverage-Directed Tests → Coverage Collector: reads gaps
- Coverage-Directed Tests → Packet Factory: generates frames
- Simulator Web UI → Simulator Backend: calls API
- Simulator Backend → Simulator CLI: runs simulation
- Simulator CLI → Rule Simulator: evaluates rules
