# ika-rwth-aachen/ros2-pkg-create architecture

> Architecture diagram of the GitHub repository ika-rwth-aachen/ros2-pkg-create, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ika-rwth-aachen/ros2-pkg-create
- Repository: https://github.com/ika-rwth-aachen/ros2-pkg-create

## Overview

##### Project Type and Purpose
- This project is an interactive Command Line Interface (CLI) tool that generates ROS 2 packages using customizable templates. It essentially replaces the native “ros2 pkg create” command with additional capabilities and interactive features.
- The tool supports different kinds of ROS 2 packages – C++ packages, Python packages, and interface packages – and tailors the generated code according to user-provided options (like including lifecycle nodes, launch files, and CI integration).

##### Main Components
- CLI Interface:
– Entry point script (located in ros2-pkg-create/src/ros2_pkg_create/__main__.py) that parses command-line options and triggers the package generation process.
– Argument parsing and interactive questionnaire logic.
- Template Manager:
– Responsible for handling the various templates stored in the “templates” directory. There are three major sub-categories for C++, Python, and Interfaces, where Jinja templates with conditional blocks are used.
– Uses tools like copier (as indicated by the presence of copier.yml) to render the templates.
- Package Generator:
– Converts user input into a complete ROS 2 package structure.
– Manages file creation, populates files with processed templates, and organizes the package structure (as seen in the “samples” directory for examples of generated packages).
- Configuration & Metadata Manager:
– Reads and uses configuration files such as the pyproject.toml and copier.yml at top-level and within subdirectories to determine project-specific settings.
- CI/CD Integration:
– Contains workflows under the “.github/workflows” directory, which clearly shows that automated testing, publishing, and checks are part of the design.
– May also support generating packages with Docker-ROS CI integration (as seen by options like “--has-docker-ros”).

##### Relationships and Data Flow
- The user interacts with the CLI which:
– Collects parameters (like package name, node options, feature toggles).
– These parameters are then fed to the Template Manager.
- Template Manager takes the selected template components (located in templates/ros2_cpp_pkg, templates/ros2_python_pkg, and templates/ros2_interfaces_pkg) and applies user inputs (using Jinja for conditional rendering).
- The Package Generator creates a structured directory with configuration files, source folders, and sample launch files – similar to the examples inside the “samples” directory.

##### Architectural Patterns and Technologies
- The design revolves around separation of concerns:
– CLI interface for input and command processing.
– Template processing engine for dynamic file generation.
– File system I/O for generating the final package structure.
- The project uses Jinja-style templating (note the .jinja suffixes) and copier configuration for dynamic content.
- GitHub Actions are used for automation, evidenced by the YAML files in the .github/workflows.
- The overall structure is modular – the tool supports multiple package templates and allows plugging in additional features (like Docker integration, advanced ROS node types such as lifecycle nodes, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% External user initiating the process
    User["User"]:::external

    %% Core System Components
    subgraph "Core System"
        CLI["CLI Entry Point\n(Handles interactive questionnaire)"]:::cli
       
        subgraph "Template Manager"
            TMP["Template Manager\n(Renders Jinja templates)"]:::template
            TMP_CPP["C++ Templates"]:::template
            TMP_PY["Python Templates"]:::template
            TMP_INT["Interface Templates"]:::template
        end

        PKG["Package Generator\n(Generates ROS2 package structure)"]:::pkg

        subgraph "Configuration & Metadata Manager"
            PYCONFIG["pyproject.toml"]:::config
            COPIER["copier.yml"]:::config
        end
    end

    %% External Systems
    subgraph "External Systems"
        CI["CI/CD Integration\n(GitHub Actions workflows)"]:::external
    end

    %% Relationships and Data Flow
    User -->|"commandInput"| CLI
    CLI -->|"parsedArgs"| TMP
    TMP -->|"templateRendering"| PKG

    %% Configuration flows into Template Manager and Package Generator
    PYCONFIG -.->|"configSettings"| TMP
    COPIER -.->|"templateConfig"| TMP
    PYCONFIG -.->|"projectSettings"| PKG
    COPIER -.->|"projectTemplates"| PKG

    %% CI/CD integration triggers build and feedback loops
    PKG -->|"buildTrigger"| CI
    CI -->|"automationFeedback"| PKG

    %% Additional relation: Template Manager details breakdown (internal grouping)
    TMP -->|"includes"| TMP_CPP
    TMP -->|"includes"| TMP_PY
    TMP -->|"includes"| TMP_INT

    %% Click Events
    click CLI "https://github.com/ika-rwth-aachen/ros2-pkg-create/blob/main/ros2-pkg-create/src/ros2_pkg_create/__main__.py"
    click TMP "https://github.com/ika-rwth-aachen/ros2-pkg-create/tree/main/ros2-pkg-create/src/ros2_pkg_create/templates"
    click PKG "https://github.com/ika-rwth-aachen/ros2-pkg-create/tree/main/samples"
    click PYCONFIG "https://github.com/ika-rwth-aachen/ros2-pkg-create/blob/main/ros2-pkg-create/pyproject.toml"
    click COPIER "https://github.com/ika-rwth-aachen/ros2-pkg-create/blob/main/copier.yml"
    click CI "https://github.com/ika-rwth-aachen/ros2-pkg-create/tree/main/.github/workflows"

    %% Styles
    classDef cli fill:#f9c,stroke:#333,stroke-width:2px;
    classDef template fill:#cff,stroke:#333,stroke-width:2px;
    classDef pkg fill:#cfc,stroke:#333,stroke-width:2px;
    classDef config fill:#fcf,stroke:#333,stroke-width:2px;
    classDef external fill:#ffc,stroke:#333,stroke-width:2px;
```
