# mskutin/gsc architecture

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

- Interactive diagram: https://gitdiagram.com/mskutin/gsc
- Repository: https://github.com/mskutin/gsc

## Overview

##### Main Components

a. Client Components:
- CLI Interface (cmd package)
- Command Handlers (get.go, root.go)
- GitHub Client Package (pkg/github)

b. External Components:
- GitHub API (external service)

c. Data Flow Components:
- Input/Output Formatters (CSV/TSV)

##### Architecture Pattern
The project follows a typical CLI application architecture with clear separation of concerns:
- Command Layer (cmd/)
- Core Business Logic (pkg/)
- External Client Integration (pkg/github/)

**[User Input] → [CLI Interface (cmd/*)] → [GitHub Client (pkg/github)] → [GitHub API]**
- ↓
- [Formatters (CSV/TSV)] → [Output]

##### Specific Elements

- Rectangle: CLI Interface (entry point)
- Hexagon: GitHub Client Package
- Cloud: GitHub API
- Parallelogram: Formatters

##### Additional Details

Important aspects:
- Authentication flow (GITHUB_TOKEN, GITHUB_USERNAME)
- Rate limiting consideration (60 req/h for anonymous, more for authenticated)
- Supported output formats (CSV/TSV)
- Docker container boundary (if showing deployment view)

##### Layered View

**┌─ Presentation Layer ─┐**
- CLI Interface    │
- ┤
- Business Layer    │
- GitHub Client     │
- ┤
- Integration Layer  │
- GitHub API       │
- ┘

##### Key Points to Emphasize

- The simplicity of the architecture (single-purpose tool)
- Clear separation between CLI handling and GitHub API interaction
- Extensible formatter system
- Docker container support
- Cross-platform compatibility

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Presentation Layer"
        CLI["CLI Interface"]
        CMD["Command Handlers"]
        ENV[("Environment Variables")]
    end

    subgraph "Business Layer"
        GC["GitHub Client"]
        FMT["Formatters (CSV/TSV)"]
    end

    subgraph "Integration Layer"
        API(("GitHub API"))
    end

    subgraph "Infrastructure"
        DOCKER["Docker Container"]
        CICD["CI/CD Pipeline"]
    end

    %% Relationships
    CLI --> CMD
    CMD --> GC
    GC -.-> API
    GC --> FMT
    ENV --> GC
    FMT --> OUT[("Output Files")]
    
    %% Infrastructure connections
    DOCKER -.-> CLI
    CICD -.-> DOCKER

    %% Click events
    click CLI "https://github.com/mskutin/gsc/blob/master/main.go"
    click CMD "https://github.com/mskutin/gsc/blob/master/cmd/root.go"
    click GC "https://github.com/mskutin/gsc/blob/master/pkg/github/client.go"
    click DOCKER "https://github.com/mskutin/gsc/tree/master/build/package/cli/Dockerfile"
    click CICD "https://github.com/mskutin/gsc/blob/master/.github/workflows/ci.yml"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef external fill:#c2e0c6,stroke:#333,stroke-width:2px
    classDef infra fill:#d4c5f9,stroke:#333,stroke-width:2px
    classDef env fill:#ddd,stroke:#333,stroke-width:2px
    classDef output fill:#fff5b1,stroke:#333,stroke-width:2px

    class API external
    class ENV env
    class OUT output
    class DOCKER,CICD infra

    %% Legend
    subgraph Legend
        L1["Component"]
        L2(("External Service"))
        L3[("Data Store")]
        L4["Infrastructure"]:::infra
        L5["→ Direct Call"]
        L6["-.-> HTTP/Container"]
    end
```
