# ranjithr95/alation-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/ranjithr95/alation-assignment
- Repository: https://github.com/ranjithr95/alation-assignment

## Overview

#### Purpose and Scope
This repository documents a minimal highly available HTTP deployment: an HAProxy reverse proxy/load balancer distributes requests across two Apache web servers. The only tracked artifact is `README.md`; the runtime configuration and web content described there exist on AWS EC2 hosts rather than in this repository.

#### Entry Points
- Public HTTP entry point: HAProxy listens on port 80 and forwards requests to an available backend.
- Operational entry point: HAProxy statistics UI listens on port 8181 with HTTP basic authentication.
- Backend direct entry points: each Apache instance serves its own `index.html` response on port 80.
- Repository documentation/source of truth: `README.md`.

#### Infrastructure Topology
Three Ubuntu-based AWS EC2 instances form the deployment:
1. HAProxy server, running HAProxy 1.8.27.
2. `webserver1`, running Apache 2.4.41 and serving `"Hello World 1"`.
3. `webserver2`, running Apache and serving `"Hello World 2"`.

AWS EC2 supplies the compute/network boundary. The design uses public IP-based backend addressing, so HAProxy configuration is coupled to the provisioned EC2 addresses. Details are documented in `README.md`.

#### Request Routing and Failover
A client sends HTTP traffic to HAProxy port 80. The `http_front` frontend selects `http_back` as its default backend. `http_back` uses round-robin balancing between the two Apache servers.

Each backend is configured with HAProxy `check` health monitoring. If either Apache target is unavailable, HAProxy removes it from eligible routing and sends subsequent requests to the remaining healthy server. The demonstrated alternating Hello World responses validate the round-robin path; backend removal is intended to validate failover. Configuration is described in `README.md`.

#### Backend Serving Layer
Apache is the application-serving boundary. Each backend serves static content from the standard Ubuntu Apache document root, `/var/www/html/index.html`, with intentionally distinct text to reveal which node fulfilled a request. Apache runs as a systemd-managed service, independent of HAProxy’s lifecycle. The repository contains no application code or deployment automation for this layer; `README.md` documents manual host setup.

#### Proxy Configuration and Runtime Boundaries
HAProxy operates in HTTP mode with global syslog logging, connection/client/server timeouts, standard HTTP error pages, and a Unix admin socket at `/run/haproxy/admin.sock`. It is managed through `systemctl`, and configuration changes require a HAProxy restart.

The proxy is the only component that knows both backend endpoints and balancing policy. Apache nodes only serve local HTTP content; clients should target HAProxy rather than individual backends.

#### Observability and Administration
HAProxy exposes two operational surfaces:
- A stats URI under the port-80 frontend (`/haproxy?stats`).
- A dedicated stats listener on port 8181, protected by basic authentication.

These endpoints support backend health and traffic inspection, while HAProxy logs flow to the Ubuntu logging subsystem. Credentials and host-specific setup details are currently recorded directly in `README.md`, which is a security-sensitive documentation concern.

Main entry points: [`README.md`](https://github.com/ranjithr95/alation-assignment/blob/main/README.md) (Deployment documentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_aws["AWS EC2 deployment"]
  node_ec2{{"AWS EC2<br/>compute and network boundary"}}
end

subgraph group_proxy["HAProxy host"]
  node_haproxy["HAProxy 1.8.27"]
  node_http_front["http_front :80<br/>HTTP frontend"]
  node_http_back["http_back<br/>round-robin backend pool"]
  node_health_checks["Backend health checks<br/>HAProxy check monitoring"]
  node_stats["Stats surfaces<br/>HAProxy administration"]
  node_admin_socket["Admin socket<br/>Unix control socket"]
  node_logs["Ubuntu logging<br/>syslog sink"]
end

subgraph group_backends["Apache backends"]
  node_webserver1["webserver1<br/>Apache 2.4.41 host"]
  node_webserver2["webserver2<br/>Apache host"]
  node_content1["Hello World 1<br/>static document"]
  node_content2["Hello World 2<br/>static document"]
end

node_client(("HTTP client<br/>external client"))
node_readme["Deployment documentation<br/>repository source of truth<br/>[README.md]"]

node_readme -.->|"documents topology"| node_ec2
node_ec2 -->|"hosts"| node_haproxy
node_ec2 -->|"hosts"| node_webserver1
node_ec2 -->|"hosts"| node_webserver2
node_client -->|"HTTP :80"| node_http_front
node_http_front -->|"default backend"| node_http_back
node_http_back -->|"round-robin HTTP :80"| node_webserver1
node_http_back -->|"round-robin HTTP :80"| node_webserver2
node_health_checks -.->|"check"| node_webserver1
node_health_checks -.->|"check"| node_webserver2
node_health_checks -.->|"eligible targets"| node_http_back
node_webserver1 -->|"serves"| node_content1
node_webserver2 -->|"serves"| node_content2
node_client -.->|"stats UI"| node_stats
node_haproxy -.->|"control"| node_admin_socket
node_haproxy -.->|"syslog"| node_logs

click node_readme "https://github.com/ranjithr95/alation-assignment/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ec2 toneBlue
class node_haproxy,node_http_front,node_http_back,node_health_checks,node_stats,node_admin_socket,node_logs toneAmber
class node_webserver1,node_webserver2,node_content1,node_content2 toneMint
class node_client,node_readme toneNeutral
```

## Components

### AWS EC2 deployment

Three Ubuntu EC2 hosts provide the runtime.

- **AWS EC2**: compute and network boundary · Public IPs couple HAProxy configuration to backend hosts.

### HAProxy host

- **HAProxy 1.8.27**: reverse proxy and load balancer · Systemd-managed HTTP proxy.
- **http_front :80**: HTTP frontend · Routes public requests to the default backend.
- **http_back**: round-robin backend pool · Selects only healthy Apache targets.
- **Backend health checks**: HAProxy check monitoring · Removes unavailable targets from routing.
- **Stats surfaces**: HAProxy administration · Exposes /haproxy?stats and basic-auth-protected port 8181.
- **Admin socket**: Unix control socket
- **Ubuntu logging**: syslog sink

### Apache backends

- **webserver1**: Apache 2.4.41 host · Serves Hello World 1 independently of HAProxy.
- **webserver2**: Apache host · Serves Hello World 2 independently of HAProxy.
- **Hello World 1**: static document
- **Hello World 2**: static document

### Other components

- **HTTP client**: external client
- [Deployment documentation](https://github.com/ranjithr95/alation-assignment/blob/main/README.md): repository source of truth · Documents manual setup, addresses, and credentials. · `README.md`

## Connections

- Deployment documentation → AWS EC2: documents topology
- AWS EC2 → HAProxy 1.8.27: hosts
- AWS EC2 → webserver1: hosts
- AWS EC2 → webserver2: hosts
- HTTP client → http_front :80: HTTP :80
- http_front :80 → http_back: default backend
- http_back → webserver1: round-robin HTTP :80
- http_back → webserver2: round-robin HTTP :80
- Backend health checks → webserver1: check
- Backend health checks → webserver2: check
- Backend health checks → http_back: eligible targets
- webserver1 → Hello World 1: serves
- webserver2 → Hello World 2: serves
- HTTP client → Stats surfaces: stats UI
- HAProxy 1.8.27 → Admin socket: control
- HAProxy 1.8.27 → Ubuntu logging: syslog
