-
Notifications
You must be signed in to change notification settings - Fork 602
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 sequence diagram to show overall initial flow #1253
Conversation
… of the various pieces.
Ideally we would use something like GraphViz or a similar tool (I'm not sure GraphViz actually supports sequence diagrams) that would allow us to have source files for the diagrams in the repo vs. the generated SVGs/PNGs. That would also make changes easier as we could change individual parts of the diagram without having to replace the whole generated file (and we could comment on individual changed lines). |
https://github.com/knsv/mermaid looks like something that could work very well I guess? In general this is a great addition 🎉 - I think we'll just have to find a good way for keeping source files in the repo and have a good way of regenerating the diagram reliably. |
That package is inspired by the tool I used to generate this, so the raw source file for the diagram will work unchanged! There's even an ember-mermaid addon! What's the best way to embed this? |
So ember-mermaid doesn't work in current Ember, but I can fix it if we want to use it. |
I don't think we need ember-mermaid as we don't need to render the diagram on the fly in an Ember app. I guess adding mermaid as a |
I added the source for the sequence diagram. We can use mermaid as a devDependency. Should I trigger the SVG generation from the ember-cli-build.js? For 'production' only? Perhaps with a separate entry in package.json "scripts", as well? |
I think building from |
How's this? You need to do Mermaid doesn't have a continuous mode that I could find. The CLI wrapper already existed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool!
Also the fact that we now have the source file for the diagram in the repo allows commenting on individual things in the diagram which is pretty awesome I think.
I left a few comments regarding the content of the diagram.
Do you think we need both the SVG and the PNG or would the PNG alone be sufficient? I guess the PNG is certainly valuable for seeing the effects of the changes to the diagram's source on PR pages but maybe we can use it in the guide as well?
package.json
Outdated
@@ -19,7 +19,8 @@ | |||
"test": "ember try:each", | |||
"test:node": "mocha node-tests node-tests/blueprints", | |||
"test:fastboot": "mocha fastboot-tests", | |||
"lint": "eslint app addon blueprints config server test-support tests *.js" | |||
"lint": "eslint app addon blueprints config server test-support tests *.js", | |||
"diagrams": "node node_modules/mermaid/bin/mermaid.js --svg --png -o guides/assets guides/assets/esa-initial-flow.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
"diagrams": "mermaid --svg --png -o guides/assets guides/assets/esa-initial-flow.txt"
should work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Works well. Nice to know.
guides/assets/esa-initial-flow.txt
Outdated
participant GitHub | ||
participant Token Exchanger | ||
User->>App: Use https://git-tool.com | ||
App->>Application Route: transitionTo(application) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transitionTo
doesn't actually happen. Instead this is the application route's beforeModel
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This assumes the Application Route uses the ApplicationRouteMixin
and is a deliberate simplification. Is there a better way to indicate the use of the mixin?
Do you think
App->>Application Route: beforeModel
Application Route->>Application Route: transitionTo(application)
would be more accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think App->>Application Route: beforeModel
is good? I guess the ApplicationRouteMixin
is already covered in the text anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to maintain some brevity in the actor labels, but in the process turned the mixins into implicit actors and the routes into unnamed entities that are almost pieces of data. Should I just be more verbose in the actor names, e.g. Index Route (AuthenticatedRouteMixin)
?
I think the points you're raising highlight that the diagram doesn't really stand on its own with the simplifications I made. It either requires embedding in an explanatory context or more elaboration in the diagram itself. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just be more verbose in the actor names, e.g. Index Route (AuthenticatedRouteMixin)?
I think that sounds like a good idea.
I think the points you're raising highlight that the diagram doesn't really stand on its own with the simplifications I made. It either requires embedding in an explanatory context or more elaboration in the diagram itself. What do you think?
I think we'll probably never be able to make the diagram stand on its own as it just includes so much information that it will always need some context I guess. I don't think that's a problem though as long as it works well in combination with the text? My main point was really only that a few things in there are slightly different from what actually happens in reality (e.g. there is no transitionTo
when the user boots the app on the index route) and thus might be misleading.
guides/assets/esa-initial-flow.txt
Outdated
User->>App: Use https://git-tool.com | ||
App->>Application Route: transitionTo(application) | ||
Application Route->>Application Route: subscribeToSessionEvents() | ||
App->>Authenticated Route: transitionTo(index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transitionTo
also doesn't really happen, instead the app boots up in that route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar. The actor name is meant to imply the use of the corresponding mixin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but what happens is actually that the index
route's beforeModel
method is invoked.
guides/assets/esa-initial-flow.txt
Outdated
Unauthenticated Route->>Unauthenticated Route: beforeModel() | ||
Unauthenticated Route->>Session Service: isAuthenticated? | ||
Session Service-->>Unauthenticated Route: false | ||
Unauthenticated Route->>Unauthenticated Route: render(loginTemplate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the loginTemplate
here as that seems to indicate this is something that is configurable inside of ESA which isn't really the case. Instead, the route simply renders its own template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this transition went back to User instead? It definitely isn't ESA, but it ties the Ember behavior to what the user sees in a more concrete way, although with a little hand-waving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed some proposed changes.
guides/assets/esa-initial-flow.txt
Outdated
Session Service-->>Unauthenticated Route: false | ||
Unauthenticated Route->>Unauthenticated Route: render(loginTemplate) | ||
User->>App: Login | ||
App->>Unauthenticated Route: login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe say click "Login"
or so here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the User->>App
transition? Good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed changes.
guides/assets/esa-initial-flow.txt
Outdated
App->>Unauthenticated Route: login | ||
Unauthenticated Route->>Unauthenticated Route: controller.login() | ||
Unauthenticated Route->>Session Service: authenticate('authenticator:torii', 'github') | ||
Session Service->>Torii Provider: authenticate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be 2 separate items for the Torii authenticator and the Torii provider that this uses under the hood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated how much detail to go into for the Torii Provider. Do you think some internal details of the interaction with the torii API would be appropriate?
I think this is more accurate and addresses your concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
I left a few comments on the diagram.
I'd also remove the SVG and always use the PNG maybe as we don't really need both formats.
guides/assets/esa-initial-flow.txt
Outdated
Login Route (UnauthenticatedRouteMixin)->>Login Route (UnauthenticatedRouteMixin): beforeModel() | ||
Login Route (UnauthenticatedRouteMixin)->>Session Service: isAuthenticated? | ||
Session Service-->>Login Route (UnauthenticatedRouteMixin): false | ||
Login Route (UnauthenticatedRouteMixin)-->>App: render(loginTemplate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd remove this as it might cause confusion. This is something that happens internally in Ember and that is also in no way overridden or hooked into by ESA so I don't think this needs to be shown at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I took it out, it left a gap in the flow of control that seemed strange to me. As you'll see in the next commit, I left it in but gave it informal wording rather than making it look like a function. The reference to loginTemplate
isn't really necessary with the actor relabeling.
guides/assets/esa-initial-flow.txt
Outdated
App-->>User: Login screen | ||
User->>App: Click "Login" | ||
App->>Login Route (UnauthenticatedRouteMixin): login | ||
Login Route (UnauthenticatedRouteMixin)->>Login Route (UnauthenticatedRouteMixin): controller.login() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really what actually happens - the route calling the login
method on the controller. Instead it might make sense to add the Login
controller to the diagram and replace this and line 24 above with App->>Login Controller: login action
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. This was a brevity/accuracy trade off. The larger message I'm hearing is that you prefer accuracy over brevity, which makes sense in this context. Brevity made more sense in the presentation I originally developed this for.
guides/assets/esa-initial-flow.txt
Outdated
App->>Login Route (UnauthenticatedRouteMixin): login | ||
Login Route (UnauthenticatedRouteMixin)->>Login Route (UnauthenticatedRouteMixin): controller.login() | ||
Login Route (UnauthenticatedRouteMixin)->>Session Service: authenticate('authenticator:torii', 'github') | ||
Session Service->>Torii Provider: authenticate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be open()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. This is accurate if it's the ToriiAuthenticator
but then omits some torii interactions. I've differentiated between ToriiAuthenticator
and Torii Provider
now.
guides/assets/esa-initial-flow.txt
Outdated
Token Exchanger-->>Torii Provider: access_token | ||
Torii Provider-->>Session Service: access_token | ||
Session Service-->>Login Route (UnauthenticatedRouteMixin): isAuthenticated=true | ||
Login Route (UnauthenticatedRouteMixin)-->>Index Route (AuthenticatedRouteMixin): transitionTo(routeIfAlreadyAuthenticated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this and the above line we could replace Login Route (UnauthenticatedRouteMixin)
with Login Controller
if we added that to the diagram as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked this considerably to be more accurate, I think.
Especially with the additional actors, I find the PNG too small unmagnified and fuzzy magnified. I prefer the scalable representation, which, along with the size, is why I linked it from the guide instead of embedding it. Of course, the SVG has the problems that not all browsers handle it and markdown can't embed it. Let me know if you still prefer the PNG after looking at the latest revision. |
@srvance: can't we make the PNG bigger though? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one last comment - sorry for the back and forth…
Also I think if we can make the PNG much larger I think we can drop the SVG?
guides/assets/esa-initial-flow.txt
Outdated
App-->>User: Login screen | ||
User->>App: Click "Login" | ||
App->>Login Route (UnauthenticatedRouteMixin): login | ||
Login Route (UnauthenticatedRouteMixin)->>Login Controller: login action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think line 26 and 27 could actually be combined into one:
App->>Login Controller: login action
The route isn't actually involved in this at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
…tor text doesn't overflow the boxes. Remove SVG generation.
It took a combination of CSS styling, a config file, and adjusting the generation command, but I think we have a result we can both approve. Thank you for all the great feedback! I think we have a result that really supplements the documentation nicely and that we can use to create additional diagrams. |
Do you think the extra configs for the graph are necessary? I feel the more we add the more we have to maintain in the long run. If we can simply make the graph larger but use the standard layout we'd save ourselves a bunch of LOC that then don't become part of the codebase? |
The CSS is the only way to control the font, which gets otherwise resized when the diagram width is changed. The config is the only way to control the actor box size, which ensures the actor text doesn't overlap when the size increases and that the text fits within the box. Unfortunately, it doesn't accept incremental CSS and configs. If you supply them, it omits its own. I'm not thrilled with the number of pieces, either. |
@srvance: this config seems to be sufficient actually: {
"width": 275,
"height": 65,
"boxMargin": 10,
"boxTextMargin": 5
} I'm not sure we need to control the font at all actually. I produced this with changing the
|
I investigated the CSS before finding the config settings and didn't go back to re-evaluate the styling. Thanks for digging into this. It seems the larger rendering clears up some of the font legibility issues I was trying to solve with the styling. I didn't use any, obviously, but we can also add notes if there are areas that could use more explanation. I forgot about that when we were discussing some of the representations earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay 🎉
This is certainly a great addition to the guide!
I added a sequence diagram to the ESA Torii GitHub guide showing the overall flow. I'd love a review. I can easily make derived versions with more detail or showing other scenarios, but I wanted to start here.
This is meant to be high level, so there are some details that are left out. Please let me know if you feel I skipped any important ones or included any that confuse for the target level.
If I pay, I could generate a higher resolution PNG or an SVG that we could possibly change the styling on. Let me know if that's desirable. I can also export the raw text description if you'd find that useful.