# kangarko/chatcontrol architecture

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

- Interactive diagram: https://gitdiagram.com/kangarko/chatcontrol
- Repository: https://github.com/kangarko/chatcontrol

## Overview

##### Project type and purpose
- This is a modular Minecraft server plugin suite (“ChatControl™”) for filtering and managing in-game chat across multiple server platforms.
- It supports Bukkit/Spigot, BungeeCord, and Velocity server types and provides cross-server synchronization, rule-based chat filtering, private messaging, join/quit/death messages, Discord integration, etc.

##### File structure
- Top-level POM pulls in five Maven modules:
- chatcontrol-core – shared API, models, enums, and synchronization logic
- chatcontrol-bukkit – Bukkit/Spigot implementation (commands, listeners, rule engine, database layer)
- chatcontrol-bungeecord – BungeeCord implementation (listener, hooks, plugin entry point)
- chatcontrol-velocity – Velocity implementation
- chatcontrol-proxy-core – cross-platform proxy logic (Redis pub/sub, proxy events, synchronized cache)
- Resources in each module include configuration (YML), language files, rule definitions, message templates.
- Build.xml and pom.xml in platform modules handle compilation and packaging.
- The database abstraction (model/db) under chatcontrol-bukkit indicates persistent storage (e.g., MySQL/SQLite via database.yml).

##### README for additional insights
- Mentions cross-server support via BungeeCord and Discord, and asynchronous offline player support.
- Instructs compilation against “Foundation v7” dependency.

a. Main components
- Minecraft Server Instances (Bukkit/Spigot)
- Proxy Server Instances (BungeeCord or Velocity)
- ChatControl Bukkit Plugin
- ChatControl BungeeCord/Velocity Plugin
- ChatControl Core Library (shared code)
- ChatControl Proxy Core (Redis integration)
- External Services & Stores:
– Redis (pub/sub for cross-server sync)
– Relational Database (persistent storage for mails, caches, settings)
– Discord API (for Discord support)
b. Relationships & interactions
1. Players connect to BungeeCord/Velocity Proxy
2. Proxy plugin intercepts chat/command events and publishes ProxyEvents via Redis
3. Bukkit plugin on each backend receives local PlayerChatEvents/CommandEvents
4. Bukkit plugin applies rule engine (RuleOperator, Checker) and may read/write to DB
5. If message must be broadcast cross-server, Bukkit plugin publishes ChatControlProxyMessage to Redis
6. Proxy-core module subscribes to Redis channels, relays messages to other server instances
7. Discord hook listens to events and forwards to Discord API if enabled
c. Architectural patterns & design principles
- Modular multi-platform design – core logic separated from platform adapters
- Event-driven architecture – custom events (ChannelPreChat, MuteEvent, etc.)
- Pub/Sub for synchronization – Redis acts as message bus for proxy <-> backend
- Rule engine – chain of Checker/Operator objects apply filtering rules loaded from YML
- Dependency Injection via Maven modules – core vs. platform modules
d. Key technologies, frameworks, libraries
- Java + Bukkit/Spigot API
- BungeeCord API or Velocity API
- Redis (Jedis or custom wrapper)
- Maven for build lifecycle
- YML for configuration, JSON for language files
- Foundation v7 plugin (external dependency)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Proxy Layer
    subgraph "Proxy Layer"
        PC["ChatControl Proxy Core"]:::core
        subgraph "BungeeCord Module"
            BUN["ChatControl BungeeCord Plugin"]:::bungee
            BUNLIST["RedisListener"]:::bungee
        end
        subgraph "Velocity Module"
            VEL["ChatControl Velocity Plugin"]:::velocity
            VELLIST["RedisListener"]:::velocity
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        CORE["ChatControl Core Library"]:::core
        CBK["ChatControl Bukkit Plugin"]:::bukkit
        DBABS["Bukkit DB Abstraction"]:::bukkit
        RULE["Rule Engine (Checker/Operator)"]:::bukkit
    end

    %% External Services
    subgraph "External Services"
        REDIS["Redis Pub/Sub Bus"]:::external
        DB["MySQL/SQLite Database"]:::external
        DISCORD["Discord API"]:::external
    end

    %% Data Flows
    BUN -->|"pub/sub events"| REDIS
    BUNLIST -->|"listens"| REDIS
    VEL -->|"pub/sub events"| REDIS
    VELLIST -->|"listens"| REDIS
    PC -->|"uses Redis"| REDIS
    REDIS -->|"channel events"| CBK
    CBK -->|"uses Core"| CORE
    CBK -->|"applies rules"| RULE
    RULE -->|"reads/writes"| DBABS
    DBABS -->|"persists"| DB
    CBK -->|"Discord Hook"| DISCORD
    BUN -->|"Discord Hook"| DISCORD
    VEL -->|"Discord Hook"| DISCORD

    %% Click Events
    click CORE "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-core/src/main/java/org/mineacademy/chatcontrol"
    click CBK "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-bukkit/src/main/java/org/mineacademy/chatcontrol"
    click DBABS "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-bukkit/src/main/java/org/mineacademy/chatcontrol/model/db"
    click RULE "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-bukkit/src/main/java/org/mineacademy/chatcontrol/operator"
    click BUN "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-bungeecord/src/main/java/org/mineacademy/chatcontrol/bungee"
    click BUNLIST "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-bungeecord/src/main/java/org/mineacademy/chatcontrol/bungee/listener/RedisListener.java"
    click VEL "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity"
    click VELLIST "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/listener/RedisListener.java"
    click PC "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy"
    click PCCMD "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/command"
    click PCOP "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator"
    click PCSET "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/settings/ProxySettings.java"
    click PCR "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/Redis.java"
    click BCONFIG "https://github.com/kangarko/chatcontrol/tree/master/chatcontrol-bukkit/src/main/resources"
    click BUNC "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-bungeecord/src/main/resources/bungee.yml"
    click PKCONFIG "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-proxy-core/src/main/resources/settings.yml"
    click VCONF "https://github.com/kangarko/chatcontrol/blob/master/chatcontrol-velocity/src/main/resources/velocity-plugin.json"

    %% Styles
    classDef bukkit fill:#a8e6cf,stroke:#333,stroke-width:1px
    classDef bungee fill:#dcedc1,stroke:#333,stroke-width:1px
    classDef velocity fill:#ffd3b6,stroke:#333,stroke-width:1px
    classDef core fill:#ffaaa5,stroke:#333,stroke-width:1px
    classDef external fill:#e0e0e0,stroke:#333,stroke-width:1px
```
