# k-4u/customirc architecture

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

- Interactive diagram: https://gitdiagram.com/k-4u/customirc
- Repository: https://github.com/k-4u/customirc

## Overview

Based on our analysis of the file tree and README, CustomIRC is a project that implements an IRC (Internet Relay Chat) system with both client and server components. The project is built using QT5 (with QT Creator) and is designed to work across different platforms – there is a desktop version (Windows, Linux, etc.) and an Android version. The Android part even integrates with the Necessitas SDK for Android development.

##### Overall System View
- Two major subsystems: the IRC Client and the IRC Server.
- That the Client has two “flavors” – a desktop version and an Android version. This separation is visible in the file tree (directories such as “android” and “desktop” under customIrcClient).
- Supporting libraries and shared resources (such as the “resources” directory with event handling, logging, and JSON support) that may be used by both the client and the server.

##### Main Components
a. Custom IRC Server:
- Core server logic files (e.g., files in the customIrcServer directory such as main.cpp, mainapp, ircclient, uiserver, uiclient).
- Configuration and settings (settings.xml template in the server directory).
- Additional utilities for IRC message processing (like ircCodes.h, functions.cpp, and functions.h).

b. Custom IRC Client:
- Shared core client communication (in customIrcClient root, including main.cpp, mainwindow, chatbox, chatentry, chatnotification, and clsserverconn).
- Desktop specific files (under the “desktop” directory, including UI files and classes such as clsnotify and clsuserentry).
- Android-specific structure (entire “android” directory, which contains AndroidManifest.xml, JNI or C++ wrappers, auto-generated QT code in “gen”, as well as platform-specific layout and resource files).
- Individual UI components (chatbox.ui, chatentry.ui, chatnotification.ui) and their corresponding source (.cpp/.h) files.
- Client settings handling (e.g., clssettings.cpp/h and settings.xml template for the client).

c. Shared Resources:
- “resources” directory that encapsulates logging (clslog), event management (clsevent, eventchat, eventuserjoin etc.), and JSON processing (json.cpp, jsoncommand.cpp).
- These components support modular event and message processing across components.

##### Relationships and Data Flow
- The Client-side should show how the UI components (chatbox, chatentry, and notifications) interact with underlying network modules (e.g., clsserverconn) to connect to the server.
- On the Android branch, indicate the separation between QT UI components and the Android-specific layers (including JNI or Necessitas integration), showing that while the application logic remains similar, the platform-specific UI and lifecycle handling differ.
- Configuration flow (settings.xml files) that are used at startup to initialize various parameters (like gravatar email fields mentioned in the README).

##### Architectural Patterns & Design Principles
- The project is structured following a clear separation of concerns:
- UI Layer: Contains all .ui files and their corresponding view handling (both desktop and Android).
- Business Logic/Communication Layer: Includes classes that manage connections, server communication, and event/message processing (e.g., clsserverconn, chat-related classes).
- Configuration & Resource Layer: Settings and shared resources (settings.xml templates, resource event handlers, logging, JSON parsing).
- The file organization hints at a modular design where both client and server share similar principles but are separated into their own directories, implying that different deployment models are supported.
- For the Android path, note the separation of native C++ components and autogenerated code (in “gen”) which might involve interfacing with Java components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% IRC Server Subsystem
    subgraph "IRC Server"
        ServerCore["IRC Server Core (C++/customIrcServer)"]:::backend
        ServerConfig["Settings XML (Server)"]:::config
    end

    %% IRC Client Subsystem
    subgraph "IRC Client"
        ClientShared["Client Shared Core (C++/customIrcClient)"]:::backend
        ClientSettings["Client Settings (settings.xml)"]:::config
        ClientNet["Network Module (clsserverconn)"]:::backend

        subgraph "Desktop Client"
            DesktopUI["Desktop UI Components (Desktop-specific)"]:::frontend
        end

        subgraph "Android Client"
            AndroidUI["Android UI Components & Necessitas Integration (Android)"]:::frontend
        end
    end

    %% Shared Resources Subsystem
    subgraph "Shared Resources"
        SharedRes["Shared Resources (Logging, Events, JSON) (C++/resources)"]:::resource
    end

    %% Relationships and Data Flow
    ClientShared -->|"IRC_Message"| ServerCore
    ServerCore -->|"Server_Response"| ClientShared

    ClientSettings -->|"Configuration_Data"| ClientShared
    ServerConfig -->|"Configuration_Data"| ServerCore

    DesktopUI -->|"User_Input"| ClientShared
    AndroidUI -->|"User_Input"| ClientShared

    ClientShared -->|"Network_Calls"| ClientNet
    ClientNet -->|"Sends_IRC_Message"| ServerCore
    ServerCore -->|"Server_Ack"| ClientNet

    SharedRes --- ServerCore
    SharedRes --- ClientShared

    %% Click Events (Paths are for click events only)
    click ServerCore "https://github.com/k-4u/customirc/tree/master/C++/customIrcServer"
    click ClientShared "https://github.com/k-4u/customirc/tree/master/C++/customIrcClient"
    click DesktopUI "https://github.com/k-4u/customirc/tree/master/C++/customIrcClient/desktop"
    click AndroidUI "https://github.com/k-4u/customirc/tree/master/C++/customIrcClient/android"
    click SharedRes "https://github.com/k-4u/customirc/tree/master/C++/resources"

    %% Styles
    classDef frontend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef backend fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef config fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef resource fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
