# jauderho/bl3auto architecture

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

- Interactive diagram: https://gitdiagram.com/jauderho/bl3auto
- Repository: https://github.com/jauderho/bl3auto

## Overview

##### Main Components

a. Core Components:
- CLI Interface (cmd/bl3auto.go)
- SHiFT Client (client.go)
- SHiFT API Handler (shift.go)
- Utilities Layer (utils.go)
- Configuration Management (config.json)
- Persistent Storage (codes directory)

b. External Systems:
- Borderlands/SHiFT Authentication Service
- SHiFT Code Redemption API
- Docker Container Runtime (optional deployment)

**[User/CLI Layer]**
- ↓
**[Application Core]**
- ↓
**[External Services Layer]**

##### Specific Elements

a. User Interaction Flow:
- Command-line interface entry point
- Authentication flow (username/password input)
- Code redemption process

b. Core Application Components:
- Configuration Manager
- SHiFT Client Handler
- Code Redemption Processor
- Storage Manager (for tracking used codes)

c. External Integration Points:
- SHiFT Authentication Endpoint
- Code Redemption API Endpoint

##### Important Architectural Aspects to Highlight

a. State Management:
- How previously redeemed codes are tracked
- Configuration persistence

b. Authentication Flow:
- Credential handling
- Session management

c. Container Deployment:
- Docker container boundaries
- Volume mounting for persistence

##### Key Relationships

**[CLI Interface] → [Configuration Manager] → [SHiFT Client]**
- ↓
**[Storage Manager] ← [Code Processor] ← [SHiFT API Handler]**
- ↓
- [External SHiFT Services]

##### Technical Details to Note

- Go-based implementation
- Stateful operation (tracking used codes)
- Cross-platform compatibility
- Docker deployment support

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef user fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef container fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ci fill:#e74c3c,stroke:#c0392b,color:white

    %% User Layer
    User[User Input]:::user

    %% CLI Layer
    subgraph CLI
        CLInterface[CLI Interface]:::core
    end

    %% Core Application Layer
    subgraph CoreApp[Core Application]
        Config[Configuration Manager]:::core
        ShiftClient[SHiFT Client]:::core
        ShiftAPI[SHiFT API Handler]:::core
        Utils[Utilities Layer]:::core
    end

    %% Storage Layer
    subgraph Storage
        ConfigFile[Configuration File]:::storage
        CodesStorage[Codes Storage]:::storage
    end

    %% External Services
    subgraph External[External Services]
        AuthService[SHiFT Authentication Service]:::external
        RedemptionAPI[Code Redemption API]:::external
    end

    %% Deployment
    subgraph Deployment
        Docker[Docker Container]:::container
        Volume[Persistent Volume]:::storage
    end

    %% CI/CD
    subgraph CICD[CI/CD Pipeline]
        Build[Build Workflow]:::ci
        Security[Security Scanning]:::ci
        CodeQuality[Code Quality Checks]:::ci
    end

    %% Relationships
    User --> CLInterface
    CLInterface --> Config
    Config --> ShiftClient
    ShiftClient --> ShiftAPI
    ShiftAPI --> AuthService
    ShiftAPI --> RedemptionAPI
    Config --> ConfigFile
    ShiftAPI --> CodesStorage
    Docker --> Volume
    Utils --> ShiftClient
    Utils --> ShiftAPI

    %% Click events
    click CLInterface "https://github.com/jauderho/bl3auto/blob/main/cmd/bl3auto.go"
    click ShiftClient "https://github.com/jauderho/bl3auto/blob/main/client.go"
    click ShiftAPI "https://github.com/jauderho/bl3auto/blob/main/shift.go"
    click Utils "https://github.com/jauderho/bl3auto/blob/main/utils.go"
    click ConfigFile "https://github.com/jauderho/bl3auto/blob/main/config.json"
    click Docker "https://github.com/jauderho/bl3auto/tree/main/Dockerfile"
    click Build "https://github.com/jauderho/bl3auto/blob/main/.github/workflows/build.yml"
    click Security "https://github.com/jauderho/bl3auto/blob/main/.github/workflows/scan.yml"
    click CodeQuality "https://github.com/jauderho/bl3auto/blob/main/.github/workflows/codeql-analysis.yml"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[External Services]:::external
        L3[User Interface]:::user
        L4[Storage]:::storage
        L5[Container]:::container
        L6[CI/CD]:::ci
    end
```
