# deydoux/42cursus-ft_irc architecture

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

- Interactive diagram: https://gitdiagram.com/deydoux/42cursus-ft_irc
- Repository: https://github.com/deydoux/42cursus-ft_irc

## Overview

##### Main Components
- IRC Server Core: This is the central component that listens for incoming TCP connections, manages sockets, and orchestrates command processing.
- Client Management: Classes (such as Client) handle the state, connection, and interactions of each IRC user.
- Channel Management: The Channel component manages channel creation, membership, and modes (like +i, +t, +k, +o, +l).
- Network and Connection Handling: Using TCP/IP sockets and poll(), this component integrates with the core to manage multiple simultaneous client connections.
- Logging and Utility Libraries: These modules (found in src/lib and bot/src/lib) are used for error logging, string manipulation, and various helper functions.
- Bot Functionality (Optional/Bonus): Located in the “bot” directory, this module serves as an IRC bot and may interact with the server to automate certain tasks.

##### Relationships and Interactions
- The IRC Server Core receives network connections and dispatches incoming messages to the Command Processor.
- The Command Processor interprets commands and forwards them to the appropriate Client, Channel, and Server classes.
- Client Management keeps track of connected users, while Channel Management holds channel states, including modes and operators.
- Utilities (logging, text formatting, etc.) support all these interactions, ensuring correct output, error handling, and debugging.
- The Bot module acts as an external client that connects to the server, issuing commands and interfacing with the server like any other client.

##### Architectural Patterns and Design Principles
- Modular Design: Each component – especially commands – is split into separate classes and files for maintainability.
- Separation of Concerns: Networking, command parsing, client management, and logging are clearly separated.
- Client-Server Model: The system strictly follows client-server principles where the server handles multiple client sessions concurrently.
- Extensibility: The use of distinct modules for commands and additional bot features provides clear extension points for future improvements.

##### Technologies and Frameworks
- C++98 Standard: The project is implemented in C++ using older standards, so modern facilities (or libraries) are not used.
- POSIX Sockets and poll() for network communication.
- Custom logging and utility libraries under src/lib and bot/src/lib.
- Makefiles and GitHub Actions (in .github/workflows) for building and CI, indicating integration with a continuous integration process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "IRC Server Core"
        N["Network Listener"]:::server
        CP["Command Processor"]:::server
        CM["Client Manager"]:::server
        CH["Channel Manager"]:::server
        UT["Utilities/Logging"]:::server
    end

    subgraph "Bot Module"
        IB["IRC Bot"]:::external
    end

    N -->|"dispatches"| CP
    CP -->|"handlesClient"| CM
    CP -->|"handlesChannel"| CH
    CP -.->|"uses"| UT
    CM -.->|"uses"| UT
    CH -.->|"uses"| UT
    IB -->|"connectsTo"| N

    click N "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/main.cpp"
    click N "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Server.cpp"
    
    click CP "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Command/join.cpp"
    click CP "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Command/nick.cpp"
    click CP "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Command/privmsg.cpp"
    
    click CM "https://github.com/deydoux/42cursus-ft_irc/blob/master/include/class/Client.hpp"
    click CM "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Client.cpp"
    
    click CH "https://github.com/deydoux/42cursus-ft_irc/blob/master/include/class/Channel.hpp"
    click CH "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/class/Channel.cpp"
    
    click UT "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/lib/log.cpp"
    click UT "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/lib/match_mask.cpp"
    click UT "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/lib/split.cpp"
    click UT "https://github.com/deydoux/42cursus-ft_irc/blob/master/src/lib/to_lower.cpp"
    
    click IB "https://github.com/deydoux/42cursus-ft_irc/blob/master/bot/src/main.cpp"
    click IB "https://github.com/deydoux/42cursus-ft_irc/blob/master/bot/src/class/IRC.cpp"
    click IB "https://github.com/deydoux/42cursus-ft_irc/blob/master/bot/src/class/TriviaGame.cpp"
    click IB "https://github.com/deydoux/42cursus-ft_irc/blob/master/bot/src/lib/text_formatting.cpp"
    click IB "https://github.com/deydoux/42cursus-ft_irc/blob/master/bot/src/lib/log.cpp"
    click IB "https://github.com/deydoux/42cursus-ft_irc/tree/master/bot/Makefile"

    classDef server fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef external fill:#F9E79F,stroke:#000,stroke-width:1px;
```
