-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add construct architecture diagrams (#508)
- Loading branch information
Showing
24 changed files
with
255 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
RFDK Architecture Diagrams | ||
========================== | ||
|
||
RFDK uses https://app.diagrams.net for our diagrams. We use the `.svg` file format and embed the draw.io diagram inside. | ||
|
||
## Directory Structure | ||
The following directory structure convention is used to place the architecture diagrams: | ||
|
||
packages/aws-rfdk/docs/diagrams/<package>/<ConstructName>.svg | ||
|
||
Or visually speaking: | ||
|
||
``` | ||
aws-rfdk/ | ||
└── packages | ||
└── aws-rfdk | ||
└── docs | ||
└── diagrams | ||
├── core | ||
│ ├── <ConstructName>.svg | ||
│ └── ... | ||
├── deadline | ||
│ ├── <ConstructName>.svg | ||
│ └── ... | ||
└── <additional_package> | ||
├── <ConstructName>.svg | ||
└── ... | ||
``` | ||
|
||
## Referencing the Architecture Diagrams in Code | ||
|
||
Architecture diagrams should be embedded in construct JSDoc strings. They can be expressed using Markdown image syntax: | ||
|
||
```md | ||
![architecture diagram](/diagrams/<package>/<ConstructName>.svg) | ||
``` | ||
|
||
where the URL is an absolute POSIX path rooted from `aws-rfdk/packages/aws-rfdk/docs`. The RFDK API reference docs | ||
only process image URLs that begin with `/diagrams`. Putting this together, the JSDoc header for construct `MyConstruct` | ||
in the `core` package would look: | ||
|
||
```ts | ||
import { Construct } from '@aws-cdk/core'; | ||
|
||
/** | ||
* Documentation for MyConstruct | ||
* | ||
* ![architecture diagram](/diagrams/core/MyConstruct.svg) | ||
*/ | ||
export class MyConstruct extends Construct { | ||
// ... | ||
} | ||
``` | ||
|
||
## Diagram Style Conventions | ||
|
||
Please make a best-effort to match the design language of the architecture diagrams. Some details include: | ||
|
||
### General | ||
|
||
* 10pt Helvetica font | ||
* Orthogonal (horizontal and vertical only) routing of lines with no curves | ||
* For connecting lines that overlap other lines of the same color, use the **Arc** for the **Line jumps** line | ||
property | ||
|
||
### Constructs | ||
|
||
|
||
#### Primary Construct Overlay | ||
|
||
For per-construct architecture diagrams, the resources deployed by the primary construct being documented should have an | ||
overlay rectangle with the following properties: | ||
|
||
| Property | Value | | ||
| --------------------- | ----------------------------- | | ||
| **Fill color** | 0E7017 | | ||
| **Fill opacity** | 8 | | ||
| **Font color** | 0A5211 | | ||
| **Font** | Helvetica, 16pt | | ||
| **Text Alignment** | Top Center / Bottom Center | | ||
|
||
It should be brought to the top of the layers. See the `SpotEventPluginFleet` diagram for an example: | ||
|
||
![SpotEventPluginFleet architecture diagram](./deadline/SpotEventPluginFleet.svg) | ||
|
||
### Interfaces | ||
|
||
In a construct architecture diagram, illustrate the interfaces between other RFDK constructs. For these related | ||
constructs, only resources that participate in the interface need to be included in the diagram. For example, see the | ||
following architecture diagram for the `RenderQueue`: | ||
|
||
![RenderQueue architecture diagram](./deadline/RenderQueue.svg) | ||
|
||
### Resources and Services | ||
|
||
When a CloudFormation resource is present in a diagram, its corresponding service should have its own icon in the | ||
diagram with a connnecting line between the service and the resource. These services and resources are color-coded | ||
as provided by the **AWS19** draw.io icon library. The color of the font and line connecting the service to the resource | ||
should match the service/resource fill color to help visually connect and group the resources and services. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/core/ImportedAcmCertificate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/core/X509CertificatePkcs12.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/deadline/ConfigureSpotEventPlugin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/deadline/SpotEventPluginFleet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/deadline/UsageBasedLicensing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/aws-rfdk/docs/diagrams/deadline/WorkerInstanceFleet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions
75
packages/aws-rfdk/docs/diagrams/tests/svg-embedded-drawio.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as fs from 'fs'; | ||
import { promises as fsPromises } from 'fs'; | ||
import * as path from 'path'; | ||
|
||
/** | ||
* This is the regular expression that validates that the draw.io diagram is embedded within the SVG file. | ||
* | ||
* draw.io embeds the diagram as a "content" XML attribute of the <svg> element. This looks like: | ||
* | ||
* <svg ... content="...embedded SVG diagram..."> | ||
* ... | ||
* </svg> | ||
* | ||
* When you choose to not include a copy of the draw.io diagram, this attribute is not written to the file. | ||
* | ||
* This is a very simple regular expression that will match the opening <svg> tag and ensure it has a non-empty | ||
* XML attribute named "content". While this validation doesn't assert the validity of the content attribute, | ||
* it will catch the common mistake of forgetting to include an embedded copy of the draw.io diagram. | ||
*/ | ||
const DRAW_IO_EMBEDDED_XML_ATTR_REGEX = /<svg( [^>]+)?content="[^"]+?"[^>]*?>/; | ||
const DIAGRAM_ROOT = path.join(__dirname, '..'); | ||
|
||
/** | ||
* Returns all `.svg` files that are descendants of the `packages/aws-rfdk/docs/diagrams` directory. | ||
*/ | ||
function findSvgDiagrams(dirPath?: string): string[] { | ||
if (!dirPath) { | ||
dirPath = DIAGRAM_ROOT; | ||
} | ||
|
||
let diagrams: string[] = []; | ||
|
||
const listings = fs.readdirSync(dirPath); | ||
|
||
for (const listing of listings) { | ||
const listingPath = path.join(dirPath, listing); | ||
const stat = fs.statSync(listingPath); | ||
if (stat.isDirectory()) { | ||
const dirDiagrams = findSvgDiagrams(listingPath); | ||
diagrams = diagrams.concat(...dirDiagrams); | ||
} | ||
else if (path.extname(listing).toLowerCase() === '.svg') { | ||
diagrams.push(listingPath); | ||
} | ||
} | ||
|
||
return diagrams; | ||
} | ||
|
||
describe('diagrams', () => { | ||
const diagrams = findSvgDiagrams(); | ||
|
||
describe('have draw.io diagrams embedded', () => { | ||
|
||
diagrams.forEach(diagram => { | ||
const relativeDiagramPath = path.relative(DIAGRAM_ROOT, diagram); | ||
|
||
// We use string interpolation below, otherwise eslint incorrectly believes that the test name is not a valid | ||
// string | ||
test(`${relativeDiagramPath}`, async () => { | ||
// GIVEN | ||
const diagramContents = await fsPromises.readFile(diagram, { encoding: 'utf8' }); | ||
|
||
// THEN | ||
expect(diagramContents).toMatch(DRAW_IO_EMBEDDED_XML_ATTR_REGEX); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters