# thedatabunny/ciscobubblewrap architecture

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

- Interactive diagram: https://gitdiagram.com/thedatabunny/ciscobubblewrap
- Repository: https://github.com/thedatabunny/ciscobubblewrap

## Overview

##### Project type and purpose
- This is a standalone Python CLI utility (“Cisco Bubble Wrap”) for network administrators to back up running configurations from Cisco IOS-XE devices.
- It integrates with Cisco’s RESTCONF API, fetches device configurations (YANG JSON), converts them to CLI format, and writes both formats to disk.

##### File structure
- Top-level script: `save_cisco_config.py` (the entry point)
- Configuration/examples: `switches.txt.example` (device list template)
- Dependencies: `requirements.txt`
- Documentation: `README.md`, `CLAUDE.md`
- Version control ignore: `.gitignore`

##### README for architectural insights
- Core components described under “Architecture”
- RESTCONF Client
- JSON to CLI Converter
- Batch Processor
- Logging System
- Outputs are stored under a `configs/` directory (created at runtime).
- External dependencies: Cisco devices with RESTCONF enabled, Python requests.

##### Main components and their interactions
a. Components
- CLI Interface / Entry Point (save_cisco_config.py)
- Batch Processor (reads `switches.txt`, iterates devices)
- RESTCONF Client (handles HTTPS calls to devices)
- JSON-to-CLI Converter (transforms YANG JSON → CLI text)
- File System Storage (writes `/configs/{device}_running-config.json` and `.cli`)
- Logging System (file logger + console logger)
- External Cisco Devices (target systems with RESTCONF endpoint)
b. Relationships & Data Flow
2. CLI prompts for: device-list path, username, password
3. Batch Processor reads `switches.txt` → loops per device
4. For each device:
- Call RESTCONF Client → GET configuration (YANG JSON)
- Pass JSON to JSON-to-CLI Converter → produce CLI text
- Write both JSON and CLI outputs to disk under `configs/`
- Logging system logs each step (success/failure) to console + `restconf_script.log`
5. End of batch → summary output on console
c. Architectural patterns / design principles
- Single responsibility: each component has a focused role (network I/O, parsing, conversion, logging).
- Batch processing loop decouples network calls from user interaction.
- Conversion logic centralized in its own module (or class).
- Logging abstraction so both file and console sinks receive the same events.
d. Key technologies/frameworks
- Python 3.6+
- `requests` library for HTTPS/RESTCONF calls
- Python standard libraries: `json`, `argparse` (if used), `logging`, `os`

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    User["User"]:::external

    %% Internal Modules
    subgraph "Internal Modules"
        CLI["CLI Interface / Entry Point"]:::internal
        Batch["Batch Processor"]:::internal
        RESTCONF["RESTCONF Client"]:::internal
        Converter["JSON-to-CLI Converter"]:::internal
        Logging["Logging System\n(console + file)"]:::internal
    end

    %% External Systems
    subgraph "External Systems"
        Devices["Cisco Devices\n(RESTCONF Enabled)"]:::external
    end

    %% Storage
    subgraph "Storage & Outputs"
        Configs["File System Storage\n(configs/)"]:::storage
    end

    %% Documentation & Config
    subgraph "Project Files"
        Switches["Device List Template\n(switches.txt.example)"]:::docs
        Req["Dependencies Declaration\n(requirements.txt)"]:::docs
        Docs["Documentation\n(README.md, CLAUDE.md)"]:::docs
    end

    %% Data Flow
    User -->|"run script"| CLI
    CLI -->|"reads parameters"| Batch
    Batch -->|"reads device list"| Switches
    Batch -->|"iterate devices"| RESTCONF
    RESTCONF -->|"YANG JSON response"| Converter
    Converter -->|"CLI text"| Configs
    Converter -->|"JSON file"| Configs
    RESTCONF -->|"errors"| Logging
    Converter -->|"events"| Logging
    Configs -->|"write logs"| Logging
    Logging -->|"console + restconf_script.log"| User
    Batch -->|"summary"| User

    Devices -->|"HTTPS GET"| RESTCONF

    %% Click Events
    click CLI "https://github.com/thedatabunny/ciscobubblewrap/blob/main/save_cisco_config.py"
    click Batch "https://github.com/thedatabunny/ciscobubblewrap/blob/main/save_cisco_config.py"
    click RESTCONF "https://github.com/thedatabunny/ciscobubblewrap/blob/main/save_cisco_config.py"
    click Converter "https://github.com/thedatabunny/ciscobubblewrap/blob/main/save_cisco_config.py"
    click Logging "https://github.com/thedatabunny/ciscobubblewrap/blob/main/save_cisco_config.py"
    click Configs "https://github.com/thedatabunny/ciscobubblewrap/tree/main/configs/"
    click Switches "https://github.com/thedatabunny/ciscobubblewrap/blob/main/switches.txt.example"
    click Req "https://github.com/thedatabunny/ciscobubblewrap/blob/main/requirements.txt"
    click Docs "https://github.com/thedatabunny/ciscobubblewrap/blob/main/README.md"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#004085,color:#004085;
    classDef external fill:#d4edda,stroke:#155724,color:#155724;
    classDef storage fill:#fff3cd,stroke:#856404,color:#856404;
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
