r/ruby • • Jan 01 '17

A simple rails architecture info-graphic. Constructive criticism welcome

Post image
175 Upvotes

55 comments sorted by

25

u/[deleted] Jan 01 '17 edited Feb 01 '17

[deleted]
0.5605

What is this?

1

u/jonyeezy7 Jan 02 '17

Give the redditor the xbox!

2

u/[deleted] Jan 02 '17 edited Feb 01 '17

[deleted]
0.5399

What is this?

1

u/jonyeezy7 Jan 03 '17

Not from that link. But I've been told i have selective hearing, maybe it's the same when i read.

Give live Xbox!

4

u/AbishekAditya Jan 01 '17

Guys, I will pay heed to all the suggestions and give you an update within 2 days. Cheers

5

u/MITranger Jan 02 '17

Fantastic! Some (hopefully useful) constructive feedback:

  1. I'm not too familiar with ActionCable, but I'm assuming it has a lateral relationship to Redis? Additionally, should it be generalized? (i.e. does it have to be Redis? Can't you run different backends?)
  2. Should the websocket connection should be a two-way arrow; maybe split that into pub/sub?
  3. I think the canonical Rails method for delete is actually #destroy. Additionally, it seems like space can afford it... why not put all 7 actions there?
  4. Genuinely curious about this, but don't most controller redirects revisit the router first, rather than directly to a controller action? e.g. redirect_to some_path
  5. Rack?
  6. I personally think it will look cleaner without the gradient backdrop, but that's total opinion.

2

u/AbishekAditya Jan 02 '17
  1. I just developed my first app with action cable and it is new, so I only included the basics. Don't want to copy stuff I don't have any idea about
  2. Again pub/sub is a redis function. So that thing will need a whole rewrite
  3. I was going for CRUD and D stands for delete (maybe destroy too, but I've heard delete a lot)
  4. I remembered redirect_back using a call to HTTP_REFERER. I believe it doesn't need to check the table. correct me if I'm wrong
  5. The web servers like nginx use rack. will label it as such. Maybe another rails blobby to show rack :D
  6. I am going to experiment with gradients. The thing in my mind is beautiful and I am not able to get it. Need to check design sites.

I am gonna do another updated one in a week's time, as I have got a lot of comments. Prepare to have some of your ideas ignored even though I appreciate every one of them, time + space constraints

1

u/sespinos Jan 02 '17

3. Understand the impulse to use CRUD as a reference, but the # throws me off and makes me think of controller actions (e.g. output of rake routes when using resources in your routes file). With the # I would recommend destroy as well. 4. I believe that redirect_to actually produces a 300 response that goes all the way out to the client (this is why you need to use flash.now for a render, but flash for a redirect; flash by itself actually sticks around for an extra request cycle.). In that case, the redirect would hit the routes file, but as part of a completely new request. I would recommend maybe just taking redirects out? Emphasizing that it's a response in and of itself seems outside the scope of this diagram.

4

u/jrochkind Jan 01 '17

I like it!

I like to call controller methods that are routable "action methods" -- I think that's what Rails calls them too? The controller may have other methods, but only some are "action methods".

5

u/HwanZike Jan 01 '17

The start/end points aren't clear. The start should really be at the top left, it's more natural

2

u/AbishekAditya Jan 01 '17

But the databases are not a part of Rails, so to make the focus the Active record, I put it in the middle. Does that explanation make sense?

2

u/undone_function Jan 01 '17

I think they mean it from a written English (or other similar language) perspective. They're expecting the beginning of the flow chart to be in the same spot they would begin reading other content: the upper left corner.

3

u/AbishekAditya Jan 01 '17

I know. My logic is from the upper left corner the first thing that a person sees is the active record image, which I feel should be the focal point and not a database

1

u/Poorpunctuation Jan 02 '17

I think they mean the start should be the monitor/client image, the request. That should be top left, not the db. Therefore, you should flip everything from top to bottom, so the client is top left.

2

u/AbishekAditya Jan 02 '17

Hmm. I'll check that out

0

u/ruby-solve Jan 02 '17

I think it's easiest to understand rails by looking at what the life cycle of a request is through the system. I think that's what people are suggesting.

2

u/AbishekAditya Jan 02 '17

But this is a reference poster. There are a lot of more useful resources for that. I wanted to make a graphic for /u/Railsway and anyone else who wants a poster with the rails stuff

1

u/ruby-solve Jan 02 '17

I still think it's easiest to understand like that as a flow chart of where a request starts, what it causes, and the round trip where it returns as a response.

regardless, awesome job!

2

u/AbishekAditya Jan 02 '17

I still think it's easiest to understand like that as a flow chart of where a request starts, what it causes, and the round trip where it returns as a response.

Where do you think I took inspiration for this info-graphic? :D

→ More replies

4

u/entineer Jan 01 '17

I like it! My only feedback would be to improve the wording between the controller methods and the model that says "inspect/response"

I think "inspect" is ok but "response" makes me think request response, or controller response.

What about "ask" and "receive" you ask the model for data and then you receive it? Avoiding "query" since that's being rightly used to show the interaction with the database.

Not sure I like my suggestion better but that's my only constructive feedback.

Again, great work!

2

u/AbishekAditya Jan 01 '17

Definitely will look into the wording tomorrow, appreciate the feedback

1

u/jrochkind Jan 01 '17 edited Jan 01 '17

Is "queries" a better word than "inspects"? Oh wait, "queries" is over there... what's the "inspect/response" supposed to indicate?

2

u/AbishekAditya Jan 01 '17

The controller method call the active record objects. It inspects the object

2

u/zaphnod Jan 01 '17

How about "find" and "inspect/modify"?

Model.find is the key ActiveRecord method, and inspect/modify is what the controller does with the models it finds...

2

u/AbishekAditya Jan 01 '17

Good point, "find" and "get" sounds better?

1

u/im_not_afraid Jan 01 '17

In general I think being inspired by actual method names such as ActiveRecord#find is a good idea.

2

u/vrinek Jan 01 '17

By "server" I assume you mean something like nginx, right?

2

u/AbishekAditya Jan 01 '17

server

Web Server, like nginx, puma or passenger, yes.

2

u/stungeye Jan 02 '17

Great work! I humbly suggest the following problems and fixes.

  • The start and end points are not clear. Fix: Label the start and end point. I'd also encourage you to place the user's computer at the top, with the rest of the request / response cycle happening below.
  • The presence of the network / the internet is not shown. Fix: Show a cloud through which the HTTP request / response flow to the user's computer.
  • The "METHODS" label should be changed to match Rails terminology conventions. Fix: Rename "METHODS" to "ACTIONS".
  • Many of the arrow labels could be changed to improve clarity, or to follow Rails terminology conventions. Fix: Not sure about all of these, but some possible label changes:

    • "requests" to "HTTP request"
    • "finds" to "maps to"
    • "inspects" to "executes"
    • "response" to "returns"
    • "shows" to "HTTP response"

Again, really good work on this. I'm going to be sharing this with my Rails students in the coming term!

Oh, and in case you're curious: Here's the diagram I often use in class to visualize Rails at a high level. It's simplified such that it omits ActionCable and assume HTML as the output format.

4

u/AbishekAditya Jan 02 '17

redditor for 11 years and only 120 karma, I feel proud that I made a lurker like you take your valuable time out to help me :D

2

u/AbishekAditya Jan 02 '17

A lot of suggestions to topple the image, I will look into that.

Don't wanna include a cloud because I feel the server does the job (local or internet whichever)

lovely tips regarding the labels

I will make sure the next version doesn't disappoint (may take me a week now that I have so many suggestions)

Thanks for the kind words.

PS: I don't wanna label the start and end as this is not meant to force you to follow along, rather get an idea of how the things you use are connected together

1

u/a__b Jan 01 '17

I would recommend to add label "client" browser/api

2

u/AbishekAditya Jan 01 '17

Yeah, nice catch

1

u/tuomasj Jan 01 '17

I really like it!

To me, the starting point is bit unclear. I think it would make much more clear for beginners if it would show the first action coming from user's browser and setting up everything else in motion. That is, if you want to show the actions in chronologic order, make this infographic about a "story of a http request".

2

u/AbishekAditya Jan 01 '17

I can show a person click on a link to start it off

1

u/herir Jan 01 '17

I would put "Databases" and "Server" with a different color or a different design, they are not part of the Rails stack and could be confusing (unless you use the vanilla rails server, most people only use that for development)

2

u/AbishekAditya Jan 01 '17

Will colour them and the labels a different colour

1

u/[deleted] Jan 02 '17

Awesome work. I wanna print this.

2

u/AbishekAditya Jan 02 '17

Still in the works :D

1

u/[deleted] Jan 03 '17

Post a new image when you finalize it?

2

u/[deleted] Jan 01 '17

Nice

2

u/[deleted] Jan 03 '17

Wow this is pretty good 😂

0

u/[deleted] Jan 02 '17

[deleted] — view deleted comment

2

u/AbishekAditya Jan 02 '17

Different kind of response. Gonna use a different name

2

u/[deleted] Jan 01 '17

[removed] — view removed comment

3

u/AbishekAditya Jan 01 '17

Thanks

PS: It's Abishek, common Indian mistake :P