CortexcnCortexcn

Service Map

A root service and the services it sends traffic to, as cards joined by right-angle lines, each with a status badge, metric rows, and a beam of light running down every line.

Last updated: Nov 2 / 10:03 AM

  • API Gateway

    /v1/orders
    48k Reqs
  • Orders, receives traffic from API Gateway

    Healthy
    Traffic
    64%
    Avg
    120ms
  • Inventory, receives traffic from API Gateway

    Healthy
    Traffic
    24%
    Avg
    145ms
  • Shipping, receives traffic from API Gateway

    Warning
    Traffic
    12%
    Avg
    850ms

Installation

ProPart of Cortexcn Pro

The source for service-map comes with a Cortexcn Pro license, along with every other chart and the website templates. Pick a license on the pricing page.

Usage

import { ServiceMap } from "@/components/service-map";
<ServiceMap
  caption="Last updated: 10:03 AM"
  nodes={[
    {
      id: "gateway",
      title: "API Gateway",
      metrics: [{ label: "/v1/orders", value: 48, unit: "k Reqs" }],
      x: 50,
      y: 20,
    },
    {
      id: "orders",
      parent: "gateway",
      title: "Orders",
      status: "healthy",
      metrics: [
        { label: "Traffic", value: 64, unit: "%" },
        { label: "Avg", value: 120, unit: "ms" },
      ],
      x: 30,
      y: 60,
    },
  ]}
/>

Each node is a card placed by its center, in percent of the map's width and height. A node with a parent is joined to it by a line, so one list describes the whole tree. Use it for endpoint traffic, payment rails, queues and their workers, or any system where one service hands work to others.

Examples

Static

With animated={false}, the lines are drawn without the moving beams.

Last updated: Nov 2 / 10:03 AM

  • API Gateway

    /v1/orders
    48k Reqs
  • Orders, receives traffic from API Gateway

    Healthy
    Traffic
    64%
    Avg
    120ms
  • Inventory, receives traffic from API Gateway

    Healthy
    Traffic
    24%
    Avg
    145ms
  • Shipping, receives traffic from API Gateway

    Warning
    Traffic
    12%
    Avg
    850ms

Behavior

  • A child below its parent hangs off a horizontal line shared with its siblings, and a child straight below its parent gets a straight line. A child beside its parent is joined side to side.
  • The lines are measured from the cards after the map renders, and redrawn when the map or any card changes size.
  • Beams run from parent to child, one line after another, only while the map is on screen. With reduced motion enabled, the lines stay still.
  • The map lays out at minWidth or wider (520px by default). In a narrower container it scrolls sideways, and takes keyboard focus so it can be scrolled from the keyboard.
  • Badge text mixes the status color with the text color, so it stays readable in light and dark mode.
  • Each child card tells screen readers which node sends it traffic. Icons are hidden from them.

Props

ServiceMap

PropTypeDefaultDescription
nodesServiceMapNode[]-The cards, and through parent, the lines
captionReactNode-A small label in the top-left corner
animatedbooleantrueSend beams down the lines while the map is on screen
minWidthnumber520Narrowest layout width in pixels; below it, scroll
ariaLabelstring"Service map"Names the map for screen readers
classNamestring-Extra classes; set the height here (default h-80)

ServiceMapNode

PropTypeDefaultDescription
idstring-Unique id, used by children's parent
parentstring-The node that sends this one traffic
titlestring-The card's name
iconReactNode-Icon before the title, drawn at 14px
status"healthy" | "warning" | "critical" | "idle"-Colors the status badge
statusLabelstringThe statusText in the badge
metrics{ label: string; value: ReactNode; unit?: string }[]-Label and value rows under the title
xnumber-The card's center, in percent of the width
ynumber-The card's center, in percent of the height