Back
Glass Box

15. März 2025

Glass Box

Glass Box is an educational HTTP/1.1 server built to demystify web protocols. It exposes the "hidden" work of a web server by streaming internal metrics to a client-side dashboard, allowing users to watch their requests flow through the parsing, routing, and response pipeline live.

JavaTypeScriptDockerHTTP
View Project →

About the Project

Glass Box is a fully handcrafted HTTP/1.1 server built from the ground up in Java — no frameworks, no magic. The goal was to understand exactly what happens between a browser sending a request and a server sending a response, and to make that invisible process visible.

Rather than treating the server as a black box, Glass Box streams live internal metrics to a browser-based dashboard via Server-Sent Events. You can watch each request move through parsing, routing, and response generation in real time.

Glass Box has shipped 4 releases and 100+ commits. It supports virtual hosts, static file serving, RESTful routing, and real-time server stats — all without a single framework dependency in the core.

Tech Stack

JavaTypeScriptHTMLCSSMavenDocker

Problem & Solution

Problem

HTTP servers are everywhere but their internals are opaque. Most developers use frameworks that hide the protocol layer entirely — making it hard to build intuition for what actually happens during a request/response cycle.

Solution

Build the server from scratch in Java, implementing the TCP/HTTP core, request parsing, routing, and response handling manually. Then expose all of that via a live dashboard so the internals are never hidden.

Key Features

  • HTTP/1.1 implementation — raw TCP socket handling, request parsing, and response formatting
  • Virtual host management — serve multiple domains from one server instance
  • Static file serving — with proper MIME types and error pages
  • RESTful routing — handler hierarchy with a factory pattern for clean extensibility
  • Real-time metrics dashboard — CPU, memory, request counts, and log stream via SSE
  • Structured logging — multiple log levels with per-request tracing
  • Docker support — containerised deployment out of the box

Architecture

The project separates concerns cleanly across three layers: the TCP/HTTP core handles raw socket I/O and protocol parsing; the routing layer dispatches requests to typed handlers; and the metrics layer collects and streams server statistics without coupling to business logic. Handler registration uses a factory pattern, making it straightforward to add new endpoints without touching existing code.