# veluxy/smartgifts architecture

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

- Interactive diagram: https://gitdiagram.com/veluxy/smartgifts
- Repository: https://github.com/veluxy/smartgifts

## Overview

##### Core Components
- Create these major subsystems:
a. Gift Management System
b. Distribution System
c. Command Handler
d. Logging System
e. Configuration Manager
f. Data Storage

##### Component Relationships

a. Input Layer:
- Player Commands ('/sclaim')
- Admin Commands (sgift.entry.*)
→ Connect to Command Handler

b. Core Processing:
- Command Handler → Gift Management System
- Gift Management System → Distribution System
- Distribution System → Player Inventory System (Rust Game)

c. Data Flow:
- Configuration Manager → All Components
- Gift Management System ↔ Data Storage
- Distribution System → Logging System

##### External Integrations
- Discord Webhook Integration
- File System (for logs)
- Oxide Framework
- Rust Game Server

Use these visual elements:

##### Specific elements

a. Gift Entry Structure:
- ID
- Gift Details (Item ShortName, Amount)
- Distribution Type
- Pending Players
- Given Players

b. Distribution Types:
- SpecificPlayers
- MapPlayers
- ServerPlayers
- Everyone

##### Important Flows to Highlight

a. Gift Creation Flow:
- Admin Command → Command Handler → Gift Management → Data Storage

b. Gift Distribution Flow:
- Player Wake/Claim → Distribution System → Player Inventory

c. Logging Flow:
- Distribution System → Logging System → Discord/File System

##### Additional Details

- A permissions layer showing 'smartgifts.admin' access control
- Configuration flow showing how settings affect each component
- Data persistence layer with JSON storage format
- Hooks into Rust game events (player wake-up)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Rectangle: Core Component]
        L2[(Cylinder: Storage)]
        L3{{Hexagon: External System}}
        L4([Rounded: User Interface])
        style L1 fill:#b3d9ff
        style L2 fill:#d9d9d9
        style L3 fill:#90EE90
        style L4 fill:#ffeb99
    end

    subgraph "Input Layer"
        PC([Player Commands]):::ui
        AC([Admin Commands]):::ui
    end

    subgraph "Core Plugin"
        SGP[SmartGifts Plugin]:::core
        GMS[Gift Management System]:::core
        DS[Distribution System]:::core
        CH[Command Handler]:::core
        LS[Logging System]:::core
        CM[Configuration Manager]:::core
    end

    subgraph "Storage Layer"
        DS1[(Data Storage)]:::storage
    end

    subgraph "External Systems"
        OF{{Oxide Framework}}:::external
        RGS{{Rust Game Server}}:::external
        DW{{Discord Webhook}}:::external
        FS{{File System}}:::external
    end

    PC --> CH
    AC --> CH
    CH --> GMS
    GMS --> DS
    DS --> RGS
    CM --> SGP
    CM --> GMS
    CM --> DS
    CM --> LS
    GMS <--> DS1
    DS --> LS
    LS --> DW
    LS --> FS
    SGP --> OF
    OF --> RGS

    classDef core fill:#b3d9ff
    classDef storage fill:#d9d9d9
    classDef external fill:#90EE90
    classDef ui fill:#ffeb99

    click SGP "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click GMS "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click DS "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click CH "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click LS "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click CM "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
    click DS1 "https://github.com/Veluxy/SmartGifts/blob/master/SmartGifts.cs"
```
