Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add architectural diagram to main repository #128

Merged
merged 39 commits into from Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
67ea6dc
Set up document.
RubenVerborgh Dec 30, 2016
b46f158
Add main packages.
RubenVerborgh Dec 30, 2016
e636836
Add API Modeling blocks.
RubenVerborgh Dec 30, 2016
a1dc5da
Add hypermedia subpackages.
RubenVerborgh Dec 30, 2016
aa65162
Add paging and filtering.
RubenVerborgh Dec 30, 2016
d8dcc44
Add actions.
RubenVerborgh Dec 30, 2016
63223cb
Add forms.
RubenVerborgh Dec 30, 2016
15a1257
Add errors.
RubenVerborgh Dec 30, 2016
4085258
Compile diagram to PDF on Travis.
RubenVerborgh Dec 30, 2016
15bb724
Push compiled version to gh-pages.
RubenVerborgh Dec 30, 2016
6f56b94
Build SVG image as well.
RubenVerborgh Dec 30, 2016
99299b4
Switch to Helvetica.
RubenVerborgh Dec 30, 2016
7acac57
Fix text alignment.
RubenVerborgh Dec 30, 2016
b080b08
Add README.
RubenVerborgh Dec 30, 2016
ad8a1f4
Explain arrows.
RubenVerborgh Dec 30, 2016
dabd83e
Use safe/unsafe instead of read/write.
RubenVerborgh Jan 4, 2017
a47bae8
Add structure for describing components.
RubenVerborgh Mar 7, 2017
5724255
Explain resources.
RubenVerborgh Mar 7, 2017
55ac89e
Explain collections.
RubenVerborgh Mar 7, 2017
350c686
Add Web API to diagram.
RubenVerborgh Mar 7, 2017
8538f20
Explain Web API.
RubenVerborgh Mar 7, 2017
4ea25a5
Clarify that collections are resources.
RubenVerborgh Mar 7, 2017
9e7bf23
Explain errors.
RubenVerborgh Mar 7, 2017
3f6b4fe
Explain paging.
RubenVerborgh Mar 7, 2017
760b89b
Explain filtering.
RubenVerborgh Mar 7, 2017
7ce66a2
Discuss URI templates.
RubenVerborgh Mar 7, 2017
85b0f14
Refine URI Templates, Fields, Entity Bodies.
RubenVerborgh Mar 7, 2017
9635003
Fix indentation.
RubenVerborgh Mar 7, 2017
2d20c4d
Resources and collections also describe representations.
RubenVerborgh Mar 7, 2017
e30d535
Explain filtering.
RubenVerborgh Mar 7, 2017
c8be137
Explain actions.
RubenVerborgh Mar 7, 2017
9bf8003
Explain dependencies.
RubenVerborgh Mar 7, 2017
cc0ea8c
Make listed properties optional.
RubenVerborgh Mar 27, 2017
d8b7e3d
Clarify separation of controls and data.
RubenVerborgh Mar 28, 2017
8c4dcde
Mention non-RDF bodies.
RubenVerborgh Apr 3, 2017
1235eb5
Fix typo.
RubenVerborgh Apr 6, 2017
7af9931
Add 'drafts/diagram/' from commit '1235eb52ee5617a2bd4545e864fc8126aa…
RubenVerborgh Jun 26, 2017
11f5af3
Update Travis scripts for main repo.
RubenVerborgh Jun 26, 2017
8932d91
Install packages through APT addon.
RubenVerborgh Jun 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
sudo: required
dist: trusty
before_install:
# Install LaTeX (for architecture diagram)
- sudo apt-get -qq update
- sudo apt-get install -y --no-install-recommends texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-extra-utils latex-xcolor pgf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the Travis APT Addon to install dependencies declaratively instead of requiring sudo and doing it through a script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done in 8932d91.

script:
# Build architecture diagram
- cd drafts/diagram
- pdflatex -interaction=nonstopmode -halt-on-error hydra-architecture-diagram.tex
- latex -interaction=nonstopmode -halt-on-error hydra-architecture-diagram.tex
- dvisvgm --no-fonts hydra-architecture-diagram.dvi hydra-architecture-diagram.svg
after_success:
# Update gh-pages branch
- ./.travis_update_ghpages.sh
25 changes: 25 additions & 0 deletions .travis_update_ghpages.sh
@@ -0,0 +1,25 @@
#!/bin/bash
# Only publish from the main repository's master branch
REPO_NAME="HydraCG/Specifications"
if [ "$TRAVIS_REPO_SLUG" != "$REPO_NAME" ] || [ "$TRAVIS_BRANCH" != "master" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ]; then exit; fi
echo -e "Generating gh-pages...\n"

# Checkout the gh-pages branch
REPO_PATH=$PWD
pushd $HOME
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/$REPO_NAME gh-pages 2>&1 > /dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the docs folder approach instead of the (imho) hacky gh-pages branch approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not mess up the main branch. master only contains source; gh-pages contains compiled code.

I'd contest "hacky" BTW; this is a very reasonable approach used in several repositories.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean about "hacky" is that this is a weird use of Git. But I agree that it might be a good idea to have compiled code away from master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean about "hacky" is that this is a weird use of Git.

Not really. GitHub decided to offer gh-pages as a branch whose contents are exposed through HTTP. So this script simply commits to that branch in order to publish a document over HTTP.

It's a well-known procedure and Travis even has a hook for it (which is slightly different than what I want).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not questioning everyone's use of the gh-pages feature as it is an important functionality offered by GitHub. What I'm questioning is how the feature is implemented by GitHub, as I consider having a completely clean branch not related to any other branches in the same repository in any way whatsoever (source code management wise, which is what Git is for).

I think GitHub has implemented web site hosting as a hack and is also why I believe the new docs folder functionality has been added. Either way, this is way off topic and not something I feel is very important to agree on within this PR. Over some 🍻 sometime, perhaps? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 😄

cd gh-pages

# Don't update if already at the latest version
if [[ `git log -1 --pretty=%B` == *$TRAVIS_COMMIT* ]]; then exit; fi

# Update documents
cp -r $REPO_PATH .

# Commit and push latest version
git add .
git config user.name "Travis"
git config user.email "travis@travis-ci.org"
git commit -m "Update to $TRAVIS_COMMIT."
git push -fq origin gh-pages 2>&1 > /dev/null
popd
8 changes: 8 additions & 0 deletions drafts/diagram/.gitignore
@@ -0,0 +1,8 @@
*.aux
*.dvi
*.fdb*
*.fls
*.log
*.pdf
*.svg
*.synctex*
166 changes: 166 additions & 0 deletions drafts/diagram/README.md
@@ -0,0 +1,166 @@
# Hydra Architecture Diagram

This repository contains work in progress for an architecture diagram of the [Hydra Core Vocabulary](http://www.hydra-cg.com/spec/latest/core/).

## Overview

![Latest diagram version](https://rubenverborgh.github.io/Hydra-Architecture-Diagram/hydra-architecture-diagram.svg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but first we need to make sure the CI works.


An arrow represents a dependency from a component on another.

## Components

### Web API
**Web APIs consist of resources and collections.**

#### Defined by Hydra
- structural description of an API
- metadata of an API

### Resources
**Resources are the atoms of (Hydra-enabled) REST Web APIs.**

Resources can have one or more representations.
If those representations are RDF-based formats (or support embedding RDF),
then they describe the resource using elements from the Hydra Core Vocabulary.

#### Defined by Hydra
- how resources can incorporate Hydra descriptions and/or controls
- in particular, how descriptions and controls can be separated from data
- describing representations
- properties that a resource representation will list

#### Dependencies
- on Errors, since resources can generate errors


### Collections
**Collections are sets of resources and associated behavior.**

Collections can contain zero or more resources.
Collections are resources themselves.

#### Defined by Hydra
- describing kinds of collections
- properties of their elements (type etc.)
- describing representations
- (optional) properties of resources that a collection representation will list
- describing operations on collections
- creation
- addition
- deletion

#### Dependencies
- on Resources, since a collection is a resource and contains resources


### Errors
**Errors describe what can go wrong during the interaction with a resource,
and possible ways to address it.**

#### Defined by Hydra
- types of errors
- error metadata
- possible causes
- possible fixes
- connecting errors to resources

#### Dependencies
none


### Fields
**Fields are places where clients can provide input.**

#### Defined by Hydra
- parameter description
- name
- constraints
- range
- validation

#### Dependencies
none


### URI Templates
**URI Templates express how field values are combined into an URL.**

#### Defined by Hydra
- field serialization

#### Dependencies
- on Fields, since they are needed to fill out templates


### Entity Bodies
**Entity Bodies express how field values are combined into a request body (e.g., for `POST`/`PUT`/`PATCH`).**

#### Defined by Hydra
- entity structure
- JSON-LD and other RDF formats
- non-RDF formats
- field serialization

#### Dependencies
- on Fields, since they are needed to fill out entity bodies


### Paging
**Pages partition collections into subsets such that
each child resource appears on exactly one page.**

Pages (only) change [application state](https://www.safaribooksonline.com/library/view/restful-web-services/9780596529260/ch04s05.html#id3189296).

#### Defined by Hydra
- page navigation
- next, previous
- first, last
- jump to specific page
- page metadata
- current page number
- total number of pages
- number of items per page
- ordering
- based on resource attributes
- client-initiated paging
- determine ordering
- determine number of items per page

#### Dependencies
- on Collections, since they are being paged
- on URI Templates, since some paging options require generating a page URI


### Filtering
**Filters select subsets of collections based on resource attributes.**

Filters (only) change [application state](https://www.safaribooksonline.com/library/view/restful-web-services/9780596529260/ch04s05.html#id3189296).

#### Defined by Hydra
- availability of filters
- conditions for applying a filter
- the effect of a filter
- how a filter maps input values to a selection

#### Dependencies
- on Collections, since they are being filtered
- on URI Templates, since some filters require generating a page URI
- on Fields, since they relate the filter to its effect


### Actions
**Actions express manipulations of resources through representations.**

Actions change [resource state](https://www.safaribooksonline.com/library/view/restful-web-services/9780596529260/ch04s05.html#id3189296).

#### Defined by Hydra
- availability of actions
- conditions for executing an action
- the effect of executing an action

#### Dependencies
- on Resources, since actions can be executed on them
- on Collections, since actions can be executed on them
- on Fields, since they relate the action to its effect
- on Entity Bodies, since some actions require sending a request body
95 changes: 95 additions & 0 deletions drafts/diagram/hydra-architecture-diagram.tex
@@ -0,0 +1,95 @@
\documentclass{article}
\usepackage[utf8]{inputenc}

% Page setup
\usepackage[a4paper,landscape,margin=2cm]{geometry}

% Typography
\usepackage[scaled]{helvet}
\let\familydefault\sfdefault

% Graphics
\usepackage[usenames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}

\begin{document}
\pagestyle{empty}

\tikzstyle{package} = [
rectangle, draw,
font = {\Large\bf}, align=left,
minimum height=13em, text width=54em, inner sep=1em,
]
\tikzstyle{subpackage} = [
rectangle, draw,
font = {\large\it}, align=left,
minimum height=8em, text width=11em, text height=-5em, inner sep=1em,
]
\tikzstyle{component} = [
rectangle, draw, fill=Khaki!50,
font = {\large\bf},
minimum width=10em, rounded corners, minimum height=4em,
]
\tikzstyle{arrow} = [
draw, -latex', line width=1pt,
]

\begin{tikzpicture}[
node distance = 2em, auto
]

% Packages
\node[package, fill=CornflowerBlue!50]
(modeling) {API Modeling};
\node[package, fill=DarkOrange!50, above=of modeling, minimum height=21em]
(hypermedia) {Hypermedia\\Controls};
\node[subpackage, above left=of hypermedia.south east, anchor=south east, align=right]
(unsafe) {Unsafe};
\node[subpackage, left=of unsafe.south west, anchor=south east, text width=23em]
(safe) {Safe};
\node[subpackage, above=of unsafe.north east, anchor=south east, text width=38em]
(forms) {Forms};

% Nodes
\node[component, above left=of modeling.south, anchor=south, xshift=6.4em]
(resources) {Resources};
\node[component, above=of resources]
(collections) {Collections};
\node[component, left=of collections]
(api) {Web API};
\node[component, right=5.5em of resources]
(errors) {Errors};
\node[component, above right=of safe.south west, anchor=south west]
(paging) {Paging};
\node[component, right=of paging]
(filtering) {Filtering};
\node[component, above right=of forms.south west, anchor=south west]
(templates) {URI Templates};
\node[component, above left=of forms.south east, anchor=south east]
(bodies) {Entity Bodies};
\node[component, right=of templates]
(fields) {Fields};
\node[component, above right=of unsafe.south west, anchor=south west]
(actions) {Actions};

% Arrows
\path[arrow] (api) -- (collections);
\path[arrow] (api.south east) -- (resources.north west);
\path[arrow] (collections.south) -- (resources);
\path[arrow] (resources) -- (errors);
\path[arrow] (paging.south) -- (collections);
\path[arrow] (paging.north) -- (templates.south);
\path[arrow] (filtering.south) -- (collections);
\path[arrow] (filtering.north) -- (templates.south);
\path[arrow] (filtering.north) -- (fields);
\path[arrow] (actions.south) -- (collections.east);
\path[arrow] (actions.south) -- (resources.east);
\path[arrow] (actions.north) -- (bodies);
\path[arrow] (actions.north) -- (fields);
\path[arrow] (templates) -- (fields);
\path[arrow] (bodies) -- (fields);

\end{tikzpicture}

\end{document}