# sadham-hussian/distributedparallelwebserver architecture

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

- Interactive diagram: https://gitdiagram.com/sadham-hussian/distributedparallelwebserver
- Repository: https://github.com/sadham-hussian/distributedparallelwebserver

## Overview

- A load balancer (implemented in Go) that acts as the entry point for incoming HTTP requests.
- A web server (implemented in Java) that handles and processes these requests.

##### Main Components Identification
a. Load Balancer:
– Located in the “load_balancer” directory.
– Contains a main Go file (main.go) along with its module definitions (go.mod), indicating it is a standalone service.
– Acts as the gateway that receives incoming client requests and directs them to backend servers.

b. Web Server:
– Located in the “webserver” directory, with its source code in “webserver/src”.
– Contains Java files (Connection.java, HTTPRequest.java, HTTPResponse.java, WebServer.java) which define how the HTTP transactions are managed.
– Includes a Dockerfile, implying the server can be containerized for easier deployment and scalability.
– Likely allows for multiple instances given the “DistributedParallelWebServer” concept.

##### Interactions and Data Flow
a. Client Request Flow:
– External clients send HTTP requests to the load balancer.
b. Request Routing:
– The load balancer receives the request and, based on its internal logic, distributes them across one or more web server instances.
c. Web Server Processing:
– The web servers process the HTTP requests, manage connections, and generate HTTP responses that are sent back through the load balancer to the client.

##### Architectural Patterns & Design Principles
a. Separation of Concerns:
– The design clearly distinguishes between the entry-point (load balancing) and the backend processing (web server).
b. Parallel/Distributed Processing:
– This design enables multiple web server instances to operate in parallel and distribute load, improving performance and scalability.
c. Containerization:
– The presence of a Dockerfile in the web server suggests containerized deployment, which can simplify orchestration in distributed environments.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    Client("Clients"):::client

    subgraph "Load Balancer (Go Based)"
        LBSvc("Load Balancer Service"):::lbService
        LB_Main("main.go"):::lbFile
        LB_GoMod("go.mod"):::lbFile
        LB_Module("load_balancer Directory"):::lbDir
    end

    subgraph "Web Server (Java Based)"
        WSSvc("Web Server Service"):::wsService
        WS_WebServer("WebServer.java"):::wsFile
        WS_Connection("Connection.java"):::wsFile
        WS_HTTPRequest("HTTPRequest.java"):::wsFile
        WS_HTTPResponse("HTTPResponse.java"):::wsFile
        WS_Docker("Dockerfile"):::wsFile
    end

    Client -->|"HTTP_Request"| LBSvc
    LBSvc -->|"Forward_Request"| WSSvc
    WSSvc -->|"HTTP_Response"| LBSvc
    LBSvc -->|"Response_Delivery"| Client

    click LB_Main "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/load_balancer/main.go"
    click LB_GoMod "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/load_balancer/go.mod"
    click LB_Module "https://github.com/sadham-hussian/distributedparallelwebserver/tree/master/load_balancer/load_balancer"
    click WS_WebServer "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/webserver/src/WebServer.java"
    click WS_Connection "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/webserver/src/Connection.java"
    click WS_HTTPRequest "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/webserver/src/HTTPRequest.java"
    click WS_HTTPResponse "https://github.com/sadham-hussian/distributedparallelwebserver/blob/master/webserver/src/HTTPResponse.java"
    click WS_Docker "https://github.com/sadham-hussian/distributedparallelwebserver/tree/master/webserver/src/Dockerfile"

    classDef client fill:#f9d5bb,stroke:#333,stroke-width:2px;
    classDef lbService fill:#bbdef0,stroke:#333,stroke-width:2px;
    classDef lbFile fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef lbDir fill:#a5d6a7,stroke:#333,stroke-width:2px;
    classDef wsService fill:#f8bbd0,stroke:#333,stroke-width:2px;
    classDef wsFile fill:#e1bee7,stroke:#333,stroke-width:2px;
```
