# ivankuchin/ftd-acl-optimizer architecture

> Architecture diagram of the GitHub repository ivankuchin/ftd-acl-optimizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivankuchin/ftd-acl-optimizer
- Repository: https://github.com/ivankuchin/ftd-acl-optimizer

## Overview

##### Project type and purpose
- This is a standalone, open-source CLI tool written in Rust (“FTD Access Control Rule Optimizer”).
- It parses the output of Cisco FTD’s `show access-control-config`, builds an in-memory model of ACL rules, applies subnet and port optimizations (shadow, overlap, adjacency), and produces a report on rule entry counts before and after optimizations.

##### File structure
- Top-level Rust project (Cargo.toml, Cargo.lock), with CI/CD workflows under `.github`.
- `src/main.rs` wires everything together.
- `src/args.rs` + `src/cli/` handle the command-line interface and options.
- `src/acp/reader.rs` ingests raw CLI text into data structures under `src/acp/rule/`.
- Rule sub-modules:
- `network_object` and `protocol_object` describe and group IP ranges, subnets, ports.
- Optimizer logic lives in files suffixed `_optimized.rs`.
- Utilities, grouping and intermediate representations spread across `src/acp/rule/network_object/utilities.rs` and similar protocol-object helpers.

##### README for additional insights
- The README explains the calculation of ACE (Access Control Entries) and the three optimization types: shadow, overlap, adjacency.
- Use case: run via `ftd-acl-optimizer analyze -f collected_output.txt`.
- No external services or databases—pure in-memory processing and console/file output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External user and output
    User(("User")):::external
    Output(("Report Output")):::external

    %% CLI Layer
    subgraph "CLI Layer"
        args["args.rs"]:::cli
        cli_mod["cli/mod.rs"]:::cli
        cli_util["cli/utils.rs"]:::cli
    end

    %% Parser Layer
    subgraph "Parser"
        reader["reader.rs"]:::parser
        acp_mod["acp/mod.rs"]:::parser
    end

    %% Domain Model
    subgraph "Domain Model"
        subgraph "Network Objects"
            net_mod["network_object/mod.rs"]:::domain
            net_item["network_object_item.rs"]:::domain
            net_util["utilities.rs"]:::domain
            net_group["group/*"]:::domain
        end
        subgraph "Protocol Objects"
            proto_mod["protocol_object/mod.rs"]:::domain
            proto_item["protocol_object_item.rs"]:::domain
            proto_desc["description.rs"]:::domain
            proto_group["group/*"]:::domain
        end
    end

    %% Optimization Engine
    subgraph "Optimization Engine"
        opt_net["network_object_optimized.rs"]:::opt
        opt_prefix["prefix_list_item_optimized.rs"]:::opt
        opt_proto["protocol_list_optimized.rs"]:::opt
    end

    %% Reporter
    subgraph "Reporter"
        rep_main["main.rs"]:::reporter
        rep_example["rule_report"]:::reporter
    end

    %% Configuration / CI
    subgraph "Configuration / CI"
        cargo_toml["Cargo.toml"]:::config
        workflow1[".github/workflows/build.yml"]:::config
        workflow2[".github/workflows/rust-ci.yml"]:::config
        workflow3[".github/workflows/release-drafter.yml"]:::config
        actions[".github/actions/*"]:::config
    end

    %% Data Flow
    User -->|invokes CLI| args
    args --> cli_mod
    cli_mod --> cli_util
    cli_util -->|parsed flags| reader
    reader --> acp_mod
    acp_mod -->|builds domain model| net_mod
    net_mod --> net_item
    net_mod --> net_util
    net_mod --> net_group
    acp_mod --> proto_mod
    proto_mod --> proto_item
    proto_mod --> proto_desc
    proto_mod --> proto_group
    net_group & proto_group & net_item & proto_item -->|rule set| opt_net
    opt_net --> opt_prefix
    opt_prefix --> opt_proto
    opt_proto -->|optimized model| rep_main
    rep_main --> rep_example
    rep_example --> Output

    %% Config dependencies
    cargo_toml -.-> args
    workflow1 -.-> args
    workflow2 -.-> rep_main
    workflow3 -.-> rep_main
    actions -.-> reader

    %% Click Events
    click args "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/args.rs"
    click cli_mod "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/cli/mod.rs"
    click cli_util "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/cli/utils.rs"
    click reader "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/reader.rs"
    click acp_mod "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/mod.rs"
    click net_mod "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/network_object/mod.rs"
    click net_item "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/network_object/network_object_item.rs"
    click net_util "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/network_object/utilities.rs"
    click net_group "https://github.com/ivankuchin/ftd-acl-optimizer/tree/master/src/acp/rule/network_object/group/"
    click proto_mod "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/protocol_object/mod.rs"
    click proto_item "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/protocol_object/protocol_object_item.rs"
    click proto_desc "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/protocol_object/description.rs"
    click proto_group "https://github.com/ivankuchin/ftd-acl-optimizer/tree/master/src/acp/rule/protocol_object/group/"
    click opt_net "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/network_object/network_object_optimized.rs"
    click opt_prefix "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/network_object/prefix_list_item_optimized.rs"
    click opt_proto "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/acp/rule/protocol_object/protocol_list_optimized.rs"
    click rep_main "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/src/main.rs"
    click rep_example "https://github.com/ivankuchin/ftd-acl-optimizer/tree/master/examples/rule_report"
    click cargo_toml "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/Cargo.toml"
    click workflow1 "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/.github/workflows/build.yml"
    click workflow2 "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/.github/workflows/rust-ci.yml"
    click workflow3 "https://github.com/ivankuchin/ftd-acl-optimizer/blob/master/.github/workflows/release-drafter.yml"
    click actions "https://github.com/ivankuchin/ftd-acl-optimizer/tree/master/.github/actions/"

    %% Styles
    classDef cli fill:#a8f0c6,stroke:#333,stroke-width:1px
    classDef parser fill:#c6d8ff,stroke:#333,stroke-width:1px
    classDef domain fill:#d0e6f7,stroke:#333,stroke-width:1px
    classDef opt fill:#e4c1f9,stroke:#333,stroke-width:1px
    classDef reporter fill:#cccccc,stroke:#333,stroke-width:1px
    classDef config fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef external fill:#fff2cc,stroke:#333,stroke-width:1px
```
