How mobz/elasticsearch-head works
Project type and purpose
• This is an open-source, single-page web application (“elasticsearch-head”) that provides a rich front-end GUI for inspecting and administering one or more Elasticsearch clusters.
• It can run as:
• a standalone HTTP server (Node.js + Grunt) serving static assets (port 9100)
• a Docker container (mobz/elasticsearch-head)
• a Chrome extension (src/chrome_ext)
• a deprecated Elasticsearch site plugin
File structure
• Top-level build & config:
• Gruntfile.js, Dockerfile(.alpine), package.json → build & dev server
• proxy/ → Node.js code (proxy/index.js) + cluster config (proxy/clusters/*.json) + recipes for bypassing CORS
• Core application:
• src/app/
– data/ (query, model, metadata, data–source interfaces)
– services/ (cluster discovery, cluster-state polling, user preferences)
– ui/ (widgets, panels, views, controls)
– ux/ (base classes: observable, drag-drop, templates)
– app.js + app.css → entry-point, bootstrapping
• src/chrome_ext/ → background.js + manifest.json for the Chrome extension version
• src/vendor/ → third-party libraries
• Distribution:
• _site/ → compiled static site (HTML, CSS, JS, fonts, i18n bundles)
README for additional insights
• Describes run modes, CORS requirements, Docker tags, special proxy mode, URL parameters for base_uri/auth/lang.
• Mentions the HTTP REST API at port 9200 exposed by Elasticsearch.
• Emphasizes single-page nature and simple static-file deployment.
Components & Relationships – how to represent them
1. Browser (Client): loads SPA assets, renders UI, fires HTTP requests
2. Static Server (Node.js/Grunt) or any webserver (serves _site/ assets)
3. Local Proxy (Node.js in proxy/) – optional: bypasses same-origin restrictions, multiplexes to multiple clusters
4. Elasticsearch cluster(s) (REST API on port 9200)
5. Chrome Extension (background script in src/chrome_ext) – alternate client path
• Browser GET → Static Server (9100) → retrieves HTML/CSS/JS
• Browser (JS) → HTTP REST → Elasticsearch directly (CORS enabled)
• Browser (JS) → HTTP → Local Proxy → HTTP → one or more Elasticsearch clusters
• Chrome Extension → HTTP → Elasticsearch (no CORS)
• Presentation Layer (src/app/ui + src/app/ux)
• Application Logic / Services (src/app/services)
• Data Abstraction Layer (src/app/data)
• External Integration (proxy module, Elasticsearch REST)
d. Key technologies & frameworks:
• JavaScript, HTML5, CSS (SPA)
• Grunt (build tool), Node.js (dev server + proxy)
• Docker (containerized deployment)
• Chrome Extension APIs
Be exhaustive but not cluttered
• Every major subdirectory as a module if it plays a standalone role (e.g., src/app/data, src/app/services/clusterState, proxy).