digraph {
  rankdir = "LR"

  subgraph cluster_cvd_client {
    label = "cvd (client)"
    CvdClient
  }
  subgraph cluster_cvd_server {
    label = "cvd (server)"
    CvdServer
    CvdCommandHandler [style = "dashed"]
    CommandSequenceExecutor

    subgraph first_order_handlers {
      rank = same;

      CvdFetchCommandHandler
      CvdFleetCommandHandler
      CvdHelpHandler
      CvdGenericCommandHandler
      CvdResetCommandHandler
      CvdShutdownHandler
      CvdStartCommandHandler
      CvdVersionHandler
    }
    subgraph second_order_handlers {
      rank = same;

      CvdCommandHandlerProxy
      CvdVmControlCommandHandler
      LoadConfigsCommand
      SerialLaunchCommand
      SerialPreset
    }
  }
  subgraph device_executables {
    rank = same;

    launch_cvd
    restart_cvd
    powerbtn_cvd
    powerwash_cvd
    all_cvd [label = "*_cvd"]
    cvd_status
    stop_cvd
    cvd_host_bugreport
  }

  CvdClient -> CvdServer [label = "AF_UNIX"]
  CvdServer -> CvdCommandHandler

  CvdCommandHandler -> CvdVmControlCommandHandler
  CvdCommandHandler -> CvdFetchCommandHandler
  CvdCommandHandler -> CvdFleetCommandHandler
  CvdCommandHandler -> CvdGenericCommandHandler [minlen = 2]
  CvdCommandHandler -> CvdCommandHandlerProxy
  CvdCommandHandler -> CvdHelpHandler
  CvdCommandHandler -> LoadConfigsCommand
  CvdCommandHandler -> CvdResetCommandHandler
  CvdCommandHandler -> SerialLaunchCommand
  CvdCommandHandler -> SerialPreset
  CvdCommandHandler -> CvdShutdownHandler
  CvdCommandHandler -> CvdStartCommandHandler
  CvdCommandHandler -> CvdVersionHandler

  CommandSequenceExecutor -> CvdCommandHandlerProxy [dir = "back"]
  CommandSequenceExecutor -> LoadConfigsCommand [dir = "back"]
  CommandSequenceExecutor -> SerialPreset [dir = "back"]
  CommandSequenceExecutor -> SerialLaunchCommand [dir = "back"]
  CommandSequenceExecutor -> CvdVmControlCommandHandler [dir = "back"]

  CommandSequenceExecutor -> CvdCommandHandler

  CvdStartCommandHandler -> launch_cvd [label = "fork/exec"]
  CvdGenericCommandHandler -> restart_cvd [label = "fork/exec"]
  CvdGenericCommandHandler -> powerbtn_cvd [label = "fork/exec"]
  CvdGenericCommandHandler -> powerwash_cvd [label = "fork/exec"]
  CvdHelpHandler -> all_cvd [label = "fork/exec"]
  CvdFleetCommandHandler -> cvd_status [label = "fork/exec"]
  CvdGenericCommandHandler -> stop_cvd [label = "fork/exec"]
  CvdGenericCommandHandler -> cvd_host_bugreport [label = "fork/exec"]
}
