# barimehdi77/ft_irc architecture

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

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

## Overview

##### Project Type and Purpose
- This is a network‐server project written in C++98 that implements an IRC (Internet Relay Chat) server.
- It supports multiple clients over TCP/IP, handles channels, private messages, operator commands, file transfers, and a built‐in “DEEZNUTS” bot.

##### File Structure Analysis
Top-Level Files
- Makefile, .gitignore, README.md, main.cpp – build script, repo settings, entry point, and documentation
Directories
- headers/ – public interface (.hpp) for core classes: Server, Client, Channel, Request, File
- srcs/ – implementation (.cpp) of all modules: networking (getSocket, pollHandling), command handlers (Join, Part, Kick, Privmsg, etc.), file transfer, utils, and the DEEZNUTS bot

##### README Insights
- Single‐poll() event loop for all I/O (listen, accept, read, write).
- Command set mimics RFC1459 subset: PASS, NICK, USER, OPER, MODE, QUIT, JOIN, PART, TOPIC, KICK, PRIVMSG, NOTICE, SENDFILE, GETFILE, plus the DEEZNUTS bot.
- Bonus: file transfer and meme‐bot.

##### Diagramming Recommendations
- From Network Layer → Reactor → Parser
- Parser → Dispatcher → Command Modules → Data Stores
- Data Stores → Reactor → Network Layer (for outgoing messages)
- Blue for I/O (Network Layer, Reactor)
- Green for parsing & dispatch (Parser, Dispatcher)
- Yellow for business logic (Command Modules)
- Orange for data storage (Clients, Channels)
- Rectangles for long‐lived components,

##### Detail and Clarity
- Poll() as a single central loop with multiple fds hooked in
- Multi-step flows (e.g., file transfer chunking)
- Notes about protocol boundaries (RFC1459 messages in/out)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point
    Main["main.cpp"]:::entry
    MakefileNode["Makefile/README.md"]:::doc

    %% Network Layer
    subgraph "Network Layer"
        SocketManager["Socket Manager"]:::io
        PollLoop["Poll Loop (Reactor)"]:::io
        IOHandler["I/O Handler (read/write)"]:::io
    end

    %% Core Server
    subgraph "Core Server"
        ServerClass["Server Class"]:::core
        ClientClass["Client Class"]:::core
        ChannelClass["Channel Class"]:::core
    end

    %% Request Handling
    subgraph "Request Handling"
        RequestParser["Request Parser"]:::parser
        Dispatcher["Request Dispatcher"]:::parser
    end

    %% Command Modules
    subgraph "Command Modules"
        CmdLoader["Generic Command Loader"]:::business
        JoinCmd["JOIN Command"]:::business
        PartCmd["PART Command"]:::business
        KickCmd["KICK Command"]:::business
        PrivmsgCmd["PRIVMSG Command"]:::business
    end

    %% File Transfer Subsystem
    subgraph "File Transfer Subsystem"
        FileAbstraction["File Abstraction"]:::storage
        FileTransfer["Transfer Logic"]:::business
    end

    %% DEEZNUTS Bot
    DeezNuts["DEEZNUTS Bot"]:::business

    %% Data Storage
    subgraph "Data Storage"
        ClientsStore["Clients Collection"]:::storage
        ChannelsStore["Channels Collection"]:::storage
        FileStore["Pending File Transfers"]:::storage
    end

    %% Utilities
    Utils["Utilities"]:::util

    %% Flow
    Main -->|"start"| SocketManager
    SocketManager -->|"accept()/register fd"| PollLoop
    PollLoop -->|"poll() signals readable"| RequestParser
    RequestParser -->|"parse() returns Request"| Dispatcher
    Dispatcher -->|"invoke command"| CmdLoader
    CmdLoader --> JoinCmd
    CmdLoader --> PartCmd
    CmdLoader --> KickCmd
    CmdLoader --> PrivmsgCmd
    JoinCmd --> ClientsStore
    PartCmd --> ChannelsStore
    KickCmd --> ChannelsStore
    PrivmsgCmd --> ClientsStore
    Dispatcher --> FileTransfer
    FileTransfer --> FileAbstraction
    FileTransfer --> ClientsStore
    Dispatcher --> DeezNuts
    DeezNuts --> ClientsStore
    ServerClass --> ClientsStore
    ServerClass --> ChannelsStore
    ClientClass --> ClientsStore
    ChannelClass --> ChannelsStore
    Dispatcher --> ServerClass
    Utils --> RequestParser
    Utils --> FileTransfer
    Utils --> DeezNuts
    ClientsStore -->|"update leads to"| PollLoop
    ChannelsStore --> PollLoop
    PollLoop -->|"poll() signals writable"| IOHandler
    IOHandler -->|"send() to"| ClientsStore

    MakefileNode --> Main

    %% Click Events
    click SocketManager "https://github.com/barimehdi77/ft_irc/blob/main/srcs/getSocket.cpp"
    click PollLoop "https://github.com/barimehdi77/ft_irc/blob/main/srcs/pollHandling.cpp"
    click IOHandler "https://github.com/barimehdi77/ft_irc/blob/main/srcs/messagesHandling.cpp"
    click ServerClass "https://github.com/barimehdi77/ft_irc/blob/main/headers/Server.hpp"
    click ServerClass "https://github.com/barimehdi77/ft_irc/blob/main/srcs/Server.cpp"
    click ClientClass "https://github.com/barimehdi77/ft_irc/blob/main/headers/Client.hpp"
    click ClientClass "https://github.com/barimehdi77/ft_irc/blob/main/srcs/Client.cpp"
    click ChannelClass "https://github.com/barimehdi77/ft_irc/blob/main/headers/Channel.hpp"
    click ChannelClass "https://github.com/barimehdi77/ft_irc/blob/main/srcs/Channel.cpp"
    click RequestParser "https://github.com/barimehdi77/ft_irc/blob/main/headers/Request.hpp"
    click RequestParser "https://github.com/barimehdi77/ft_irc/blob/main/srcs/Request.cpp"
    click Dispatcher "https://github.com/barimehdi77/ft_irc/blob/main/srcs/requestHandling.cpp"
    click CmdLoader "https://github.com/barimehdi77/ft_irc/blob/main/srcs/commands.cpp"
    click JoinCmd "https://github.com/barimehdi77/ft_irc/blob/main/srcs/JoinCommand.cpp"
    click PartCmd "https://github.com/barimehdi77/ft_irc/blob/main/srcs/PartCommand.cpp"
    click KickCmd "https://github.com/barimehdi77/ft_irc/blob/main/srcs/KickCommand.cpp"
    click PrivmsgCmd "https://github.com/barimehdi77/ft_irc/blob/main/srcs/PrivmsgCommand.cpp"
    click FileAbstraction "https://github.com/barimehdi77/ft_irc/blob/main/headers/File.hpp"
    click FileAbstraction "https://github.com/barimehdi77/ft_irc/blob/main/srcs/File.cpp"
    click FileTransfer "https://github.com/barimehdi77/ft_irc/blob/main/srcs/FileTransfer.cpp"
    click DeezNuts "https://github.com/barimehdi77/ft_irc/blob/main/srcs/DeezNuts.cpp"
    click Utils "https://github.com/barimehdi77/ft_irc/blob/main/srcs/utils.cpp"
    click Main "https://github.com/barimehdi77/ft_irc/blob/main/main.cpp"
    click MakefileNode "https://github.com/barimehdi77/ft_irc/tree/main/Makefile"
    click MakefileNode "https://github.com/barimehdi77/ft_irc/blob/main/README.md"

    %% Styles
    classDef io fill:#bae1ff,stroke:#339,stroke-width:1px
    classDef parser fill:#baffc9,stroke:#393,stroke-width:1px
    classDef business fill:#fff5ba,stroke:#993,stroke-width:1px
    classDef storage fill:#ffd8b1,stroke:#933,stroke-width:1px
    classDef util fill:#e0e0e0,stroke:#666,stroke-width:1px
    classDef entry fill:#d5a6bd,stroke:#732,stroke-width:1px
    classDef doc fill:#f0d9ff,stroke:#732,stroke-width:1px
```
