# keitap/github-asana-request-review-action architecture

> Architecture diagram of the GitHub repository keitap/github-asana-request-review-action, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/keitap/github-asana-request-review-action
- Repository: https://github.com/keitap/github-asana-request-review-action

## Overview

##### Project Type and Purpose
- This is a GitHub Action written in Go.
- Its purpose is to listen for pull request review events on GitHub (i.e., when a reviewer is assigned) and then automatically create an Asana review subtask for the corresponding Asana task mentioned in the pull request description.

##### Key Components Identified from the File Structure
- Command & Entry Point:
- The “cmd” directory holds main.go (and its tests), which acts as the entry point for the action execution.
- Core Logic and Handlers:
- Files like account.go, asana.go, github.go, and handler.go indicate modules for handling interactions with account data, Asana’s API, GitHub events, and other core logic.
- Configuration:
- The configuration is managed via config.go. There are also sample configuration files in the “testdata” directory (e.g., config_v1.0.yml, config_v1.1.yml), showing how the action can be configured.
- Testing and CI:
- Numerous test files (e.g., *_test.go for each module) and GitHub workflows (in .github/workflows) indicate CI integration. Linting and testing workflows help ensure quality.

##### External and Internal System Interactions
- GitHub:
- The action is triggered by pull request and review events on GitHub. It listens for events such as "pull_request_review-requested" or related ones.
- Asana:
- GitHub Actions Environment:
- The project includes an action.yml file that defines how this action integrates into a GitHub Actions workflow.
- Configuration:
- The configuration module loads settings (provided via config files or environment variables) that determine details like Asana task IDs, API keys, etc.

##### Architectural Patterns & Design Principles
- Modularity:
- The system is separated into clearly modular components for handling various responsibilities (GitHub event parsing, Asana API calls, configuration, etc.), which is a good separation-of-concerns practice.
- Testability:
- With numerous tests provided, the project emphasizes well-tested modules.
- CI/CD Integration:
- The use of GitHub Workflows, Dockerfile, and Makefile show that deployment and quality assurance are automated.

a. Main Entry & Event Listener:
- GitHub Action runner (triggered by GitHub events) leading into the “cmd/main.go” component.
b. Event Processing & Handlers:
- Separate modules:
- GitHub Event Handler (from github.go & handler.go) for parsing event payloads.
- Configuration Loader (config.go) for retrieving user settings.
c. Business Logic:
- Modules such as account.go, asana.go encapsulate core functions (e.g., authenticate, build subtask details, and call Asana API).
d. External Services:
- GitHub: Outbound or inbound event triggers.
- Asana: An external API integrated via asana.go.
e. Testing & CI:
- Optionally, annotate that tests (~ *_test.go files) validate each component independently; GitHub workflows trigger tests and linting.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Trigger
    A["GitHub Events"]:::external

    %% Entry Point
    B["cmd/main.go (Entry Point)"]:::internal

    %% Configuration Loader and Sample Configs
    C["config.go (Config Loader)"]:::internal
    D["testdata/config_v1.0.yml (Sample Config)"]:::config
    E["testdata/config_v1.1.yml (Sample Config)"]:::config

    %% GitHub Event Handling Modules
    F["github.go (GitHub Handler)"]:::internal
    G["handler.go (Handler)"]:::internal

    %% Business Logic Modules
    H["account.go (Account Management)"]:::internal
    I["asana.go (Asana API Module)"]:::internal

    %% External Service: Asana API
    J["Asana API"]:::external

    %% CI/CD Components
    K["action.yml (GitHub Action)"]:::ci
    L[".github/workflows (CI Workflows)"]:::ci

    %% Flow Connections
    A -->|"triggers"| B
    B -->|"loads"| C
    C -->|"provides config to"| D
    C -->|"provides config to"| E
    C -->|"initializes"| F
    F -->|"delegates processing to"| G
    G -->|"calls business logic in"| H
    G -->|"calls business logic in"| I
    H -->|"uses settings from"| C
    I -->|"uses settings from"| C
    I -->|"invokes"| J

    %% CI/CD integration (side note)
    K ---|"defines action"| B
    L ---|"triggers tests & linting"| B

    %% Styling classes
    classDef internal fill:#ccf5cc,stroke:#0b610b,stroke-width:2px;
    classDef external fill:#ffe6ff,stroke:#cc0066,stroke-width:2px;
    classDef ci fill:#e6f7ff,stroke:#3399ff,stroke-width:2px;
    classDef config fill:#ffffcc,stroke:#ffcc00,stroke-width:2px;

    %% Click Events
    click B "https://github.com/keitap/github-asana-request-review-action/blob/main/cmd/main.go"
    click C "https://github.com/keitap/github-asana-request-review-action/blob/main/config.go"
    click D "https://github.com/keitap/github-asana-request-review-action/blob/main/testdata/config_v1.0.yml"
    click E "https://github.com/keitap/github-asana-request-review-action/blob/main/testdata/config_v1.1.yml"
    click F "https://github.com/keitap/github-asana-request-review-action/blob/main/github.go"
    click G "https://github.com/keitap/github-asana-request-review-action/blob/main/handler.go"
    click H "https://github.com/keitap/github-asana-request-review-action/blob/main/account.go"
    click I "https://github.com/keitap/github-asana-request-review-action/blob/main/asana.go"
    click K "https://github.com/keitap/github-asana-request-review-action/blob/main/action.yml"
    click L "https://github.com/keitap/github-asana-request-review-action/tree/main/.github/workflows"
```
