# enimaloc/jircd architecture

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

- Interactive diagram: https://gitdiagram.com/enimaloc/jircd
- Repository: https://github.com/enimaloc/jircd

## Overview

##### Project type and purpose
- This is a Java-based IRC daemon (server) implementing the IRC protocol (RFC 2812 + modern extensions).
- It listens on a TCP port, accepts client connections, parses IRC messages, executes commands, updates server state (users, channels), and sends back replies.

##### File structure
- Top‐level build: Gradle. CI/CD: GitHub Actions, Jenkinsfile.
- src/main/java/fr/enimaloc/jircd: the core server code.
– “server” package: JIRCD bootstrap, ServerSettings, attribute definitions.
– “user” package: User model, modes, state.
– “channel” package: Channel model, modes.
– “commands” package: one subpackage per command category, each containing Command implementations.
– “message” package: parsing (Regex), formatting (Message, Mask).
– “utils” package: functional helpers (TriConsumer).
- No frontend—pure back-end network daemon.

##### README for additional insights
- The README confirms supported commands (Join, Part, Nick, Privmsg, etc.) and adherence to the IRC protocol.
- It mentions logging (logback.xml) and configuration conventions.

##### Main components and their interactions
a. Network Layer
– Component: ServerSocketListener (inside JIRCD)
– Role: binds TCP port, accepts client sockets, spawns ClientSession handlers
b. Connection Handler (ClientSession)
– Reads raw lines, passes to Parser, queues outgoing lines to the socket
c. Protocol Layer
– MessageParser: parses raw text → Message object (using Regex)
– CommandFactory / Registry: maps Message.commandName → Command instance
d. Command Execution Layer
– Command interface (execute(context))
– Concrete Commands (JoinCommand, NickCommand, PrivmsgCommand, etc.)
– Each Command updates the Domain Model and emits zero or more response Message objects
e. Domain Model
– UserManager: tracks connected users (User, UserInfo, UserState, UserModes)
– ChannelManager: tracks channels (Channel, ChannelModes, topic, members)
– Attributes: static server capabilities (ServerAttribute, SupportAttribute, etc.)
– ServerSettings: configuration properties (ports, limits)
f. Response Dispatcher
– Takes generated Message objects, serializes back to IRC text, sends via ClientSession

##### Architectural patterns and design principles
- Command Pattern: each IRC command is a class implementing a common interface.
- Factory/Registry Pattern: one place to register and lookup Command classes by name.
- MVC-like flow: Input (network) → Controller (Command) → Model (User/Channel) → Output (network).
- Single Responsibility: separation of parsing, command logic, state management, I/O.
- Functional registration: TriConsumer used for registering command handlers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["IRC Client"]:::external

    %% Network Layer
    subgraph "Network Layer"
        direction TB
        Main["Main Launcher"]:::io
        JIRCD["JIRCD Bootstrap"]:::io
        SSListener["ServerSocketListener"]:::io
        Session["ClientSession"]:::io
    end

    %% Protocol Layer
    subgraph "Protocol Layer"
        direction TB
        Regex["Regex Parser"]:::protocol
        Message["IRC Message Model"]:::protocol
        Mask["Mask Handling"]:::protocol
    end

    %% Command Factory / Registry
    subgraph "Protocol Layer (continued)"
        direction TB
        CmdFactory["CommandFactory (Registry)"]:::protocol
        CmdInterface["Command Interface"]:::protocol
    end

    %% Command Execution Layer
    subgraph "Command Layer"
        direction TB
        Commands["Concrete Command Implementations"]:::command
    end

    %% Domain Model
    subgraph "Domain Model"
        direction TB
        UserMgr["UserManager"]:::domain
        ChanMgr["ChannelManager"]:::domain
        Settings["ServerSettings"]:::domain
        Attributes["Server Attributes"]:::domain
    end

    %% Response Dispatcher
    Dispatcher["Response Dispatcher"]:::io

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Logging["Logging Configuration"]:::infra
        BuildCI["Build & CI"]:::infra
    end

    %% Connections / Data Flow
    Client -->|"connects to"| Main
    Main --> JIRCD
    JIRCD --> SSListener
    SSListener --> Session
    Session --> Regex
    Session --> Message
    Session --> Mask
    Regex --> CmdFactory
    Message --> CmdFactory
    Mask --> CmdFactory
    CmdFactory --> CmdInterface
    CmdInterface --> Commands
    Commands --> UserMgr
    Commands --> ChanMgr
    Commands --> Attributes
    Commands --> Settings
    UserMgr --> Dispatcher
    ChanMgr --> Dispatcher
    Attributes --> Dispatcher
    Settings --> Dispatcher
    Dispatcher --> Session
    Session --> Client

    %% Click Events
    click Main "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/Main.java"
    click JIRCD "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/server/JIRCD.java"
    click Regex "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/message/Regex.java"
    click Message "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/message/Message.java"
    click Mask "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/message/Mask.java"
    click CmdInterface "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/commands/Command.java"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/channel"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/connection"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/messages"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/operator"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/optional"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/server"
    click Commands "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/commands/user"
    click UserMgr "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/user"
    click ChanMgr "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/channel"
    click Settings "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/server/ServerSettings.java"
    click Attributes "https://github.com/enimaloc/jircd/tree/master/src/main/java/fr/enimaloc/jircd/server/attributes"
    click Constants "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/utils/function/TriConsumer.java"
    click Constants "https://github.com/enimaloc/jircd/blob/master/src/main/java/fr/enimaloc/jircd/Constant.java"
    click Logging "https://github.com/enimaloc/jircd/blob/master/src/main/resources/logback.xml"
    click BuildCI "https://github.com/enimaloc/jircd/blob/master/build.gradle"
    click BuildCI "https://github.com/enimaloc/jircd/blob/master/settings.gradle"
    click BuildCI "https://github.com/enimaloc/jircd/tree/master/Jenkinsfile"
    click BuildCI "https://github.com/enimaloc/jircd/tree/master/.github/workflows"
    click BuildCI "https://github.com/enimaloc/jircd/tree/master/gradlew"
    click BuildCI "https://github.com/enimaloc/jircd/blob/master/gradlew.bat"
    click BuildCI "https://github.com/enimaloc/jircd/blob/master/README.md"
    click BuildCI "https://github.com/enimaloc/jircd/blob/master/version.txt"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef io fill:#bbdefb,stroke:#1e88e5,stroke-width:2px
    classDef protocol fill:#c8e6c9,stroke:#43a047,stroke-width:2px
    classDef command fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
    classDef domain fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px
    classDef infra fill:#e0e0e0,stroke:#757575,stroke-width:2px
```
