# thuong31415/vortex architecture

> Architecture diagram of the GitHub repository thuong31415/vortex, 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/thuong31415/vortex
- Repository: https://github.com/thuong31415/vortex

## Overview

##### Project Overview & Components
- Project Type & Purpose: Vortex is a high-performance web server aimed at efficiently handling HTTP requests with minimal resources. It implements a multi-threaded architecture to support concurrency and uses epoll for scalable event handling.
- Main Components:
- HTTP module: Includes HTTPRequest, HTTPResponse, and HttpHandler that parse and manage HTTP transactions.
- Network module: Contains components like Socket and Epoll, which implement the low-level I/O multiplexer and network socket management.
- Server module: Embodies the core server logic (accepting connections, routing requests, etc.).
- Thread Pool: Provides multi-threading support to handle multiple client requests concurrently.
- Client module: Although not a core server component, this directory indicates a basic test or demonstration client for sending requests and possibly validating the server functionality.
- Main Application (main.cpp): Likely responsible for bootstrapping the server, initializing modules, and starting the event loop.

##### Architectural Patterns & Design Principles
- Multi-threaded / Thread Pool Pattern: Emphasize how the thread pool serves concurrent tasks.
- Reactor Pattern: As implemented through the epoll-based event loop that listens for I/O events on multiple sockets.
- Separation of Concerns: Break down system responsibilities between networking (connection management), HTTP processing (protocol interpretation), and server orchestration.
- Lightweight Architecture: Note that each module is designed with minimal overhead for performance.

- Main → Server
- Server → Epoll (Network)
- Epoll → Thread Pool (upon detecting an event)
- Thread Pool → HTTP Handler (for processing)
- HTTP Handler → Socket (for sending response back to client)
- Another shade for concurrency (Thread Pool).

## Diagram (Mermaid)

```mermaid
flowchart TD
    C["Client Module"]:::client

    subgraph "Server Side"
        M["Main (Bootstrap)"]:::main
        S["Server Module"]:::server
        E["Epoll (Event Loop)"]:::network
        T["Thread Pool Module"]:::threadpool
        H["HTTP Module (Handler,Request,Response)"]:::http
        N["Socket (Network)"]:::network
    end

    C -->|"sendsRequest"| N
    M -->|"initializes"| S
    S -->|"manages"| E
    E -->|"dispatchesTo"| T
    T -->|"processesWith"| H
    H -->|"sendsResponseTo"| N
    N -->|"returnsResponse"| C

    click M "https://github.com/thuong31415/vortex/blob/main/src/main.cpp"
    click S "https://github.com/thuong31415/vortex/blob/main/src/server/Server.cpp"
    click E "https://github.com/thuong31415/vortex/blob/main/src/network/Epoll.cpp"
    click N "https://github.com/thuong31415/vortex/blob/main/src/network/Socket.cpp"
    click T "https://github.com/thuong31415/vortex/blob/main/src/thread_pool/ThreadPool.cpp"
    click H "https://github.com/thuong31415/vortex/blob/main/src/http/HttpHandler.cpp"
    click C "https://github.com/thuong31415/vortex/blob/main/src/client/Client.cpp"

    classDef main fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef server fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef network fill:#87ceeb,stroke:#000,stroke-width:2px;
    classDef threadpool fill:#ffa500,stroke:#000,stroke-width:2px;
    classDef http fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef client fill:#dda0dd,stroke:#000,stroke-width:2px;
```
