# viktorhafdal/oddevenserver architecture

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

- Interactive diagram: https://gitdiagram.com/viktorhafdal/oddevenserver
- Repository: https://github.com/viktorhafdal/oddevenserver

## Overview

##### Project type and purpose
- This is a simple client–server console application written in C#/.NET 8.0.
- Purpose: students’ exam task to build a multi-threaded server that receives numeric input from a client; if the number is even/odd it replies “even”/“odd” the first time and “even again”/“odd again” on subsequent occurrences.

##### File structure
- Top-level solution file: OddEvenServer.sln
- Three subprojects:
- Server (Server.csproj) – hosts the multi-threaded TCP server
– Key classes: ClientManager (accepts connections), ClientWorker (per-client handler), Program.cs (entry point)
- Client (Client.csproj) – console client connecting over TCP to the Server
– Contains Client.cs (logic to connect, send numbers, receive responses), Program.cs (entry point)
- Program (Program.csproj) – appears to be a standalone console app (likely a test harness or alternative entry point)
- Each project folder has its own bin/obj artifacts, .csproj, and Program.cs.

##### README for additional insights
- Describes threading behavior and expected response patterns for even/odd numbers.
- No external dependencies other than .NET Core runtime.

##### Detailed capture of essential architectural elements
- That each incoming connection spins up a ClientWorker (a thread or Task) which invokes the odd/even stateful logic.
- If the Program project is relevant to your deployment or testing, include it as its own process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Solution["OddEvenServer.sln"]:::module

    subgraph "Client Application (Console)"
        ClientDir["Client/"]:::module
        ClientProj["Client.csproj"]:::module
        ClientProgram["Program.cs"]:::module
        ClientLogic["Client.cs"]:::module
    end

    subgraph "Test Harness (Console)"
        ProgramDir["Program/"]:::module
        ProgramProj["Program.csproj"]:::module
        ProgramProgram["Program.cs"]:::module
    end

    subgraph "Network"
        TCP["TCP Socket"]:::boundary
    end

    subgraph "Server Application (Console)"
        ServerDir["Server/"]:::module
        ServerProj["Server.csproj"]:::module
        ServerProgram["Program.cs"]:::module
        Listener["ClientManager (Listener)"]:::process
        WorkerThread["ClientWorker (Thread)"]:::process
        LogicModule["Odd/Even Logic"]:::module
    end

    Solution --> ClientDir
    Solution --> ServerDir
    Solution --> ProgramDir

    ClientDir --> ClientProj
    ClientDir --> ClientProgram
    ClientDir --> ClientLogic

    ProgramDir --> ProgramProj
    ProgramDir --> ProgramProgram

    ServerDir --> ServerProj
    ServerDir --> ServerProgram

    ClientLogic -->|calls| TCP
    TCP -->|accepts connection| Listener
    Listener -->|spawns| WorkerThread
    WorkerThread -->|processes number| LogicModule
    LogicModule -->|returns result| WorkerThread
    WorkerThread -->|sends reply| TCP
    TCP -->|delivers reply| ClientLogic

    classDef process fill:#e0f7fa,stroke:#333,stroke-width:1px;
    classDef module fill:#ffe0b2,stroke:#333,stroke-width:1px;
    classDef boundary fill:#c5cae9,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;

    click Solution "https://github.com/viktorhafdal/oddevenserver/blob/master/OddEvenServer.sln"
    click ClientDir "https://github.com/viktorhafdal/oddevenserver/tree/master/Client/"
    click ClientProj "https://github.com/viktorhafdal/oddevenserver/blob/master/Client/Client.csproj"
    click ClientProgram "https://github.com/viktorhafdal/oddevenserver/blob/master/Client/Program.cs"
    click ClientLogic "https://github.com/viktorhafdal/oddevenserver/blob/master/Client/Client.cs"
    click ServerDir "https://github.com/viktorhafdal/oddevenserver/tree/master/Server/"
    click ServerProj "https://github.com/viktorhafdal/oddevenserver/blob/master/Server/Server.csproj"
    click ServerProgram "https://github.com/viktorhafdal/oddevenserver/blob/master/Server/Program.cs"
    click Listener "https://github.com/viktorhafdal/oddevenserver/blob/master/Server/ClientManager.cs"
    click WorkerThread "https://github.com/viktorhafdal/oddevenserver/blob/master/Server/ClientWorker.cs"
    click ProgramDir "https://github.com/viktorhafdal/oddevenserver/tree/master/Program/"
    click ProgramProj "https://github.com/viktorhafdal/oddevenserver/blob/master/Program/Program.csproj"
    click ProgramProgram "https://github.com/viktorhafdal/oddevenserver/blob/master/Program/Program.cs"
```
