// Copyright 2017 The OpenPitrix Authors. All rights reserved.
// Use of this source code is governed by a Apache license
// that can be found in the LICENSE file.

// dot -Tpng -o output.png input.dot

digraph G {
	rankdir = LR;

	subgraph clusterClient {
		node [
			fixedsize = true,
			width = 1, height = 1,
		]
		WebUI [shape = doublecircle];
		MobileApp [shape = doublecircle];
		XClient [shape = doublecircle];
	}

	WebUI -> ApiGateway[
		label = "rest api",
		dir   = both,
		style = bold,
	];
	MobileApp -> ApiGateway[
		label = "rest api",
		dir   = both,
		style = bold,
	];
	XClient -> ApiGateway[
		label = "rest api",
		dir   = both,
		style = bold,
	];

	subgraph clusterOpenpitrix {

		// rest api gateway
		ApiGateway [shape = rect,
			fixedsize = true,
			width = 1.4, height = 6.2,
		];

		// microservice
		subgraph clusterServices {
			node [
				shape=record,
				fixedsize = true,
				width = 2.6, height = 1.3,
			];
			Cluster [shape = Mrecord];
			Runtime [shape = Mrecord,
				label="Runtime |{ plugin |{k8s|QingCloud|Other} }"
			];
			App [shape = Mrecord];
			Repo [shape = Mrecord];
		}

		// service database
		subgraph clusterDB {
			node [
				fixedsize = true,
				width = 2.6, height = 1.3,
			];
			RepoDB [shape = cylinder];
			AppDB [shape = cylinder];
			RuntimeDB [shape = cylinder];
			ClusterDB [shape = cylinder];
		}

		// api gateway
		ApiGateway -> Cluster [
			label = "grpc",
			dir   = both,
			style = bold,
		];
		ApiGateway -> Repo [
			label = "grpc",
			dir   = both,
			style = bold,
		];
		ApiGateway -> App [
			label = "grpc",
			dir   = both,
			style = bold,
		];
		ApiGateway -> Runtime [
			label = "grpc",
			dir   = both,
			style = bold,
		];

		Repo -> RepoDB [label="SQL"];
		App -> AppDB [label="SQL"];
		Runtime -> RuntimeDB [label="SQL"];
		Cluster -> ClusterDB [label="SQL"];
	}
}

