How typpo/quickchart works
1. Repository shape
- This is a single-process Node.js image-rendering service. It exposes HTTP endpoints that turn request parameters into downloadable image artifacts rather than serving a traditional UI.
- The main app entrypoint is index.js; the rest of the code is organized around renderers for different output types.
2. Core runtime
- The server listens on PORT (default 3400) and is designed to run either directly with Node or inside the provided Dockerfile.
- The README indicates native image dependencies matter: Cairo, Pango, libjpeg, libgif. That means the architecture depends on system-level graphics libraries, not just npm packages.
3. Primary request surface
- The service centers on a few API families:
- /chart for Chart.js-based chart images
- /qr for QR code generation
- /graphviz for Graphviz/DOT rendering
- health endpoints such as /healthcheck and /healthcheck/chart
- This is an API-driven image generator; request parameters define the rendered output.
4. Chart rendering subsystem
- lib/charts.js appears to be the main chart orchestration layer, translating URL/query inputs into chart output.
- Supporting modules such as lib/google_image_charts.js, lib/svg.js, and lib/pdf.js suggest the chart pipeline can emit multiple formats or compatibility variants.
- The README emphasizes Chart.js compatibility, so the chart subsystem is the most important functional path.
5. Chart format handling
- lib/svg.js and lib/pdf.js indicate a format-conversion boundary around the chart renderer:
- raster/image generation for standard responses
- SVG export
- PDF export
- This implies a rendering core plus output adapters, rather than separate implementations for each format.
6. QR code subsystem
- lib/qr.js is a distinct renderer for QR codes, with parameters for text, size, margin, error correction, colors, and output format.
- This is a simpler independent path than charts, but it shares the same HTTP service and response model.
7. Graphviz subsystem
- lib/graphviz.js handles graph rendering from DOT-like input.
- Architecturally, it is another isolated renderer behind the same API layer, which means the service is a multi-renderer image gateway rather than a single-purpose chart app.
8. Shared utilities and cross-cutting logic
- lib/util.js likely contains parsing, normalization, validation, or response helpers shared by the renderers.
- logging.js and telemetry.js are cross-cutting support modules for operational visibility and request/event reporting.
9. Security and trust boundary
- The README explicitly warns that chart configs may contain arbitrary JavaScript and should be treated as trusted input.
- That means the main trust boundary is at the HTTP request edge; this repo does not appear to provide strong sandboxing itself.
- In architecture terms, this service should be diagrammed as a trusted internal renderer, not a safe public script execution environment.
10. Deployment model
- The repo is built for containerized deployment through Dockerfile, with scripts/update_docker.sh supporting image maintenance.
- Production usage is expected to sit behind a reverse proxy or platform ingress, but the app itself is self-contained and stateless.
11. Health and monitoring
- /healthcheck is a lightweight liveness endpoint.
- /healthcheck/chart is a heavier “render-a-chart” probe used to validate the actual rendering pipeline, not just process uptime.
- test/monit/ contains configuration for process supervision, indicating this service is expected to be automatically restarted if unhealthy.
12. Testing and validation
- test/ci/ contains endpoint-focused integration tests for charts, QR codes, Graphviz, helpers, and color handling.
- test/perf/ suggests performance/regression checks for rendering throughput or latency.
- These tests reinforce that the important architectural boundary is the HTTP rendering contract plus output correctness.
13. High-level data flow
- A client sends a URL with parameters.
- index.js routes the request to the appropriate renderer in lib/.
- The renderer parses inputs, applies chart/QR/graph logic, generates an image or document response, and returns it over HTTP.
- Logging/telemetry capture operational events around that flow.
14. How to draw the diagram
- Represent this repo as one HTTP API service with multiple renderer backends:
- request ingress
- routing/controller layer
- chart / QR / Graphviz renderers
- shared utilities and format adapters
- health/ops endpoints
- Show the native graphics/runtime dependency layer underneath, since it is essential to successful rendering.
Main entry points: charts.js Chart API · index.js Request router · util.js Helpers · qr.js QR API
Components 16
HTTP service
Request ingress and routing
- QuickChart · Main HTTP image-rendering service entrypoint
index.js - Request router · Dispatches endpoints to the right renderer
index.js - Health checks · Liveness and render-check endpoints
index.js
Renderers
Primary image generation backends
- Chart API · Chart.js-compatible rendering orchestration
lib/charts.js - Google charts · Compatibility layer for Google Image Charts-style inputs
lib/google_image_charts.js - SVG output · SVG export and response formatting
lib/svg.js - PDF output · PDF export and response formatting
lib/pdf.js - QR API · QR code generation pipeline
lib/qr.js - Graphviz API · DOT/Graphviz rendering pipeline
lib/graphviz.js
Support
Shared utilities and operational concerns
Ops
Deployment, monitoring, and validation
- Docker · Container entrypoint and runtime packaging
Dockerfile - Native libs · Cairo, Pango, libjpeg, and libgif rendering dependencies
- Integration tests · Endpoint and rendering validation coverage
test/ci/app.js - Perf checks · Rendering throughput and regression checks
test/perf/run.sh
Connections 17
- QuickChart → Request router: serves · Starts the HTTP server and accepts requests
- Request router → Chart API: /chart · Routes chart requests to the chart pipeline
- Request router → QR API: /qr · Routes QR requests to the QR pipeline
- Request router → Graphviz API: /graphviz · Routes Graphviz requests to the DOT renderer
- Request router → Health checks: health · Exposes liveness and render-probe endpoints
- Chart API → Helpers: uses · Shares parsing and normalization helpers
- Chart API → Google charts: compat · Supports Google Image Charts-style behavior
- Chart API → SVG output: exports · Can emit SVG responses
- Chart API → PDF output: exports · Can emit PDF responses
- QR API → Helpers: uses · Shares request parsing and response helpers
- Graphviz API → Helpers: uses · Shares request parsing and response helpers
- QuickChart → Logging: logs · Records service activity and failures
- QuickChart → Telemetry: reports · Sends operational telemetry
- Docker → Native libs: depends on · Container runtime requires native graphics libraries
- Integration tests → Request router: verifies · Exercises HTTP rendering contract
- Perf checks → Chart API: measures · Tracks rendering performance and regressions
- Health checks → Chart API: probes · Render-check endpoint validates the chart pipeline