How allegro/turnilo works
Project type and purpose
• Turnilo is a full-stack, stateless web application for interactive exploration and visualization of Apache Druid data.
• It provides a React/TypeScript single-page application (SPA) client, a Node.js/Express-style server and a CLI wrapper to start in various modes (run examples, connect to Druid, run with config).
• Shared “common” modules house domain models, query/serialization logic and visualization manifests, used by both client and server.
Top-level directories and architectural patterns
• bin/turnilo – CLI entrypoint that parses arguments, loads config and orchestrates server startup.
• src/client – React/TS SPA, built with Webpack (dev/prod). Implements UI components, views, visualizations, styles and deserializers that consume server JSON APIs.
• src/server – Node.js/TypeScript HTTP server (Express under the hood). Defines CLI commands, loads configuration, exposes REST routes for liveness/readiness, data-cube discovery, query (Timeseries/TopN/GroupBy), URL shortening, static file serving, plugins and request decorators.
• src/common – Shared models (Essence, DataCube, FilterClause, etc.), utils, visualization manifests and view-definition converters. Centralizes business logic, serialization and compatibility layers.
• config, config-examples.yaml – Configuration files for clusters, data cubes, plugins, OAuth, etc.
• assets, lib, docs – Static JSON data sources, fonts, polyfills and Jekyll-based documentation.
• cypress – End-to-end tests against a live Turnilo server with example datasets.
• test – Unit tests for common, client and server modules.
Key architectural patterns and design principles
• Monorepo with three vertically layered modules: common (domain + shared logic), client (presentation + consumption), server (API + orchestration).
• Stateless server: no session/state stored server-side. All state lives in the client (Essence model, URL‐hash, local storage).
• Plugin and request-decorator system: server dynamically loads plugins and decorators per config.
• Code-as-config for data-cubes: YAML/JSON config files instead of UI editor.
• CI/CD automated via GitHub Actions: lint/test/build/e2e/deploy workflows.
• Containerization: Dockerfile to package the server + built SPA assets into a container.
Main components and their interactions
[Browser (User)]
↓ Browses to SPA URL
[Node.js Server]
• Serves static SPA assets
• Exposes REST endpoints:
– /liveness, /readiness
– /sources (list Druid datasources)
– /query (Timeseries, TopN, GroupBy, raw data, pinboard)
– /mkurl & /shorten (URL‐shortener service)
– /plyql & /plywood (ad hoc query endpoints)
• Loads config, plugins, request decorators
• Uses common/models & utils to validate/serialize requests
↓ Forwards Druid queries
[Apache Druid Broker]
← Returns query results JSON
[Node.js Server]
↓ Returns JSON to client
[Browser (React App)]
• Deserializers (app-settings, cluster, data-cube, etc.) build client‐side models
• Renders charts (bar, line, grid, heat-map, table, scatterplot, totals) using visualization settings
• Updates URL hash / local storage with view definition