# abraimi/ft_irc architecture

> Architecture diagram of the GitHub repository abraimi/ft_irc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abraimi/ft_irc
- Repository: https://github.com/abraimi/ft_irc

## Overview

ft_irc is a C++98 IRC server. An IRC client connects over TCP, registers with PASS/NICK/USER, then sends commands for private or channel messaging and channel administration; the server returns IRC protocol replies. The main runtime is a non-blocking poll loop, with per-client state, message parsing, command dispatch, and in-memory channel membership and modes. README documents the supported command families and buffered I/O. Some source excerpts are partial, so edges are limited to shown calls or documented behavior.

Main entry points: [`src/Dispatcher.cpp`](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp) (Command dispatcher), [`src/Server.cpp`](https://github.com/abraimi/ft_irc/blob/master/src/Server.cpp) (TCP poll server), [`src/MessageException.cpp`](https://github.com/abraimi/ft_irc/blob/master/src/MessageException.cpp) (Protocol errors), [`src/Utils.cpp`](https://github.com/abraimi/ft_irc/blob/master/src/Utils.cpp) (Wire formatting utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_entry["Program entry<br/>[main.cpp]"]
  node_server["TCP poll server<br/>[Server.cpp]"]
end

subgraph group_protocol["IRC protocol"]
  node_message_parser["Message parsing<br/>[Message.cpp]"]
  node_protocol_errors["Protocol errors"]
  node_wire_utils["Wire formatting utilities<br/>[Utils.cpp]"]
end

subgraph group_commands["Command handling"]
  node_dispatcher["Command dispatcher<br/>[Dispatcher.cpp]"]
  node_registration["Registration<br/>[Dispatcher.cpp]"]
  node_messaging["Channel and private messaging<br/>[Dispatcher.cpp]"]
  node_channel_admin["Channel administration<br/>[Dispatcher.cpp]"]
  node_connection_compat["CAP and PING<br/>[Dispatcher.cpp]"]
end

subgraph group_state["Session and channels"]
  node_client_state["Client session state<br/>[Client.cpp]"]
  node_channel_state["Channel state<br/>[Channel.cpp]"]
end

node_irc_client(("IRC client"))

node_entry -->|"starts"| node_server
node_irc_client -->|"connects and sends"| node_server
node_server -->|"creates and tracks"| node_client_state
node_server -->|"dispatches messages"| node_dispatcher
node_server -->|"manages membership"| node_channel_state
node_dispatcher -->|"handles"| node_registration
node_dispatcher -->|"handles"| node_messaging
node_dispatcher -->|"handles"| node_channel_admin
node_dispatcher -->|"handles"| node_connection_compat
node_dispatcher -->|"updates channel state"| node_channel_state
node_dispatcher -->|"updates session"| node_client_state
node_dispatcher -->|"raises command errors"| node_protocol_errors
node_dispatcher -->|"formats replies"| node_wire_utils
node_message_parser -->|"raises validation errors"| node_protocol_errors
node_server -->|"formats replies"| node_wire_utils

click node_entry "https://github.com/abraimi/ft_irc/blob/master/src/main.cpp"
click node_server "https://github.com/abraimi/ft_irc/blob/master/src/Server.cpp"
click node_client_state "https://github.com/abraimi/ft_irc/blob/master/src/Client.cpp"
click node_channel_state "https://github.com/abraimi/ft_irc/blob/master/src/Channel.cpp"
click node_message_parser "https://github.com/abraimi/ft_irc/blob/master/src/Message.cpp"
click node_dispatcher "https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp"
click node_registration "https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp"
click node_messaging "https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp"
click node_channel_admin "https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp"
click node_connection_compat "https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp"
click node_protocol_errors "https://github.com/abraimi/ft_irc/blob/master/src/MessageException.cpp"
click node_wire_utils "https://github.com/abraimi/ft_irc/blob/master/src/Utils.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_server,node_irc_client toneBlue
class node_message_parser,node_protocol_errors,node_wire_utils toneAmber
class node_dispatcher,node_registration,node_messaging,node_channel_admin,node_connection_compat toneMint
class node_client_state,node_channel_state toneRose
```

## Components

### Server runtime

- [Program entry](https://github.com/abraimi/ft_irc/blob/master/src/main.cpp): `src/main.cpp`
- [TCP poll server](https://github.com/abraimi/ft_irc/blob/master/src/Server.cpp): `src/Server.cpp`

### IRC protocol

- [Message parsing](https://github.com/abraimi/ft_irc/blob/master/src/Message.cpp): `src/Message.cpp`
- [Protocol errors](https://github.com/abraimi/ft_irc/blob/master/src/MessageException.cpp): `src/MessageException.cpp`
- [Wire formatting utilities](https://github.com/abraimi/ft_irc/blob/master/src/Utils.cpp): `src/Utils.cpp`

### Command handling

- [Command dispatcher](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`
- [Registration](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`
- [Channel and private messaging](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`
- [Channel administration](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`
- [CAP and PING](https://github.com/abraimi/ft_irc/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`

### Session and channels

- [Client session state](https://github.com/abraimi/ft_irc/blob/master/src/Client.cpp): `src/Client.cpp`
- [Channel state](https://github.com/abraimi/ft_irc/blob/master/src/Channel.cpp): `src/Channel.cpp`

### Other components

- **IRC client**

## Connections

- Program entry → TCP poll server: starts (evidence: `src/main.cpp`)
- IRC client → TCP poll server: connects and sends (evidence: `README.md`)
- TCP poll server → Client session state: creates and tracks (evidence: `src/Server.cpp`)
- TCP poll server → Command dispatcher: dispatches messages (evidence: `src/Server.cpp`)
- TCP poll server → Channel state: manages membership (evidence: `src/Server.cpp`)
- Command dispatcher → Registration: handles (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Channel and private messaging: handles (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Channel administration: handles (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → CAP and PING: handles (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Channel state: updates channel state (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Client session state: updates session (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Protocol errors: raises command errors (evidence: `src/Dispatcher.cpp`)
- Command dispatcher → Wire formatting utilities: formats replies (evidence: `src/Dispatcher.cpp`)
- Message parsing → Protocol errors: raises validation errors (evidence: `src/Message.cpp`)
- TCP poll server → Wire formatting utilities: formats replies (evidence: `src/Server.cpp`)
