# decaprime/killfeed architecture

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

- Interactive diagram: https://gitdiagram.com/decaprime/killfeed
- Repository: https://github.com/decaprime/killfeed

## Overview

##### Project Type & Purpose
- The project is a game mod/plugin (for a game like VRising) that listens for in-game events (like player kills) and announces them in chat, while maintaining leaderboards for kills, kill streaks, and deaths.
- The README’s description (features, settings preview, changelog) confirms that its main responsibility is to process and report PvP events and statistics.

##### Analyzing the File Structure
- The top-level C# source files (Commands.cs, DataStore.cs, ECSExtensions.cs, Plugin.cs, Settings.cs, Markup.cs, VampireDownedHook.cs) indicate that functionality is divided among several dedicated components:
- Plugin.cs acts as the entry point where the mod hooks into the game’s event system.
- VampireDownedHook.cs likely represents a hook into specific game events (e.g., when a “vampire” or similar is downed), supporting the kill announcement.
- Commands.cs might set up any console or in-game commands to interact with the mod (e.g., retrieve leaderboards).
- DataStore.cs probably deals with persistence or the in-memory representation of kill statistics.
- ECSExtensions.cs hints that the project uses or extends an Entity-Component-System approach, perhaps to register and manage game entities.
- Settings.cs handles configuration (with default settings auto-generated on first run) drawn from the provided settings preview.
- Markup.cs could be in charge of formatting output messages (e.g., chat announcements).
- The build, release, and configuration files (.editorconfig, .github workflows, nuget.config, thunderstore.toml) outline the build/deployment pipeline and dependency management.

##### Key Components
a. Core Plugin Module:
- “Plugin.cs”: Mark this as the central component that initializes the plugin, registers hooks, and connects other modules.
b. Event Handling:
- “VampireDownedHook.cs” and possibly other hooks (implied by filenames) are responsible for capturing in-game events.
- “ECSExtensions.cs” may assist in integrating with the game’s ECS framework for event dissemination.
c. Business Logic & Command Processing:
- “Commands.cs” for in-game console commands or API endpoints allowing external interaction.
d. Data Management:
- “DataStore.cs” that collects, aggregates, and stores kill events and leaderboard data.
e. Configuration & Settings:
- “Settings.cs” that reads/writes settings (the structure is also showcased in the README).
f. Output & Presentation:
g. External Integration:
- Dependencies managed via NuGet (nuget.config) and distribution via Thunderstore (thunderstore.toml) could be noted as external interfaces or services.

##### Relationships and Interactions
- The Plugin module initializes and registers event hooks (VampireDownedHook, ECS extensions).
- Hooks feed game event data into the DataStore for leaderboard tracking.
- The Commands module queries DataStore for leaderboard updates.
- The Markup module is called upon by Plugin or Commands to format messages before announcing them in the game’s chat.
- Configuration Settings (Settings.cs) alter behavior across these modules.

##### Architectural Patterns & Design Principles
- Although the project is simple, hint at a separation of concerns:
- The core plugin handles initialization and event registration.
- Specific modules (hooks, commands, data store, markup) each handle their own area.
- Event-driven programming: game events are captured by hooks, processed and then disseminated as announcements.
- How configuration is externalized, enabling flexible behavior adjustments through Settings.cs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    Plugin["Plugin.cs (Core Plugin)"]:::core
    EventHooks["VampireDownedHook.cs (Game Event Hooks)"]:::core
    ECS["ECSExtensions.cs (ECS Integration)"]:::core

    %% Supporting Modules
    Commands["Commands.cs (Command Processing)"]:::utility
    DataStore["DataStore.cs (Data Management)"]:::data
    Markup["Markup.cs (Output & Presentation)"]:::utility
    Settings["Settings.cs (Configuration & Settings)"]:::config

    %% External Integrations
    Dependencies["nuget.config (Dependency Management)"]:::external
    Distribution["thunderstore.toml (Distribution Configuration)"]:::external
    Pipeline[".github/workflows (Build & Deployment Pipeline)"]:::external

    %% Relationships between core modules
    Plugin -->|"RegistersEvents"| EventHooks
    Plugin -->|"IntegratesWithECS"| ECS

    %% Event and Data processing flows
    EventHooks -->|"SendsKillData"| DataStore
    Commands -->|"QueriesLeaderboard"| DataStore
    DataStore -->|"ReturnsData"| Commands

    %% Formatting and output processing
    Plugin -->|"FormatsAnnouncement"| Markup
    Commands -->|"FormatsAnnouncement"| Markup

    %% Configuration connection to all modules
    Settings -->|"Configures"| Plugin
    Settings -->|"Configures"| EventHooks
    Settings -->|"Configures"| ECS
    Settings -->|"Configures"| Commands
    Settings -->|"Configures"| DataStore
    Settings -->|"Configures"| Markup

    %% External Integration relationships
    Plugin -->|"UsesDependencies"| Dependencies
    Plugin -->|"DistributedVia"| Distribution
    Plugin -->|"BuiltUsing"| Pipeline

    %% Click Events
    click Plugin "https://github.com/decaprime/killfeed/blob/main/Plugin.cs"
    click EventHooks "https://github.com/decaprime/killfeed/blob/main/VampireDownedHook.cs"
    click ECS "https://github.com/decaprime/killfeed/blob/main/ECSExtensions.cs"
    click Commands "https://github.com/decaprime/killfeed/blob/main/Commands.cs"
    click DataStore "https://github.com/decaprime/killfeed/blob/main/DataStore.cs"
    click Settings "https://github.com/decaprime/killfeed/blob/main/Settings.cs"
    click Markup "https://github.com/decaprime/killfeed/blob/main/Markup.cs"
    click Dependencies "https://github.com/decaprime/killfeed/blob/main/nuget.config"
    click Distribution "https://github.com/decaprime/killfeed/blob/main/thunderstore.toml"
    click Pipeline "https://github.com/decaprime/killfeed/tree/main/.github/workflows"

    %% Styles
    classDef core fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef utility fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;
    classDef data fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef config fill:#fadbd8,stroke:#cd6155,stroke-width:2px;
    classDef external fill:#f5cba7,stroke:#d35400,stroke-width:2px;
```
