Discourse Architecture . Client and Server?

(Jens) #1


first of all, discourse is great!

However I have a question. Looking at the source (GitHub - discourse/discourse: A platform for community discussion. Free, open, simple.), I was not able to find a clean seperation (as I would have expected it), between the client and the server ( for example like a directory with “server” and one with "client). Or am I missing here something completely?

What I am looking for is the code for the “Client” side. Where can I find this code, is the only the JS Stuff?

And one architectural question: The code that renders the "Base HTML Page (Containing the JS/CSS Scriptfiles, Preloade-Store, HTML), do you consider this as a server component or is this a client component? Where can I find this code?

Dont know if I manage it , but i would be interested to see, if this can be easyly implemented/ported to another proramming language to directly and “fully” embedd discourse into another application.

Thanks very much!

(Benjamin Kampmann) #2

Discourse is a huge Ember-App (Javascript) with a postgresql backend and some rails as a bridge in between. So, yes, the only “client”-code (I don’t think this is a particular good naming though) is Javascript. If you check the git out, you can find it in the folder “jsapp” which is linked to app/assets/javascript/discourse. This is how Rails (the “server” in your naming) serves these kind of files – and it is considered common practice to put it there.

Unless you are talking of a different “client” (I have seen an Android-App around), in which case you might want to check their repo. That probably contains its own chunk of “client”-code talking to the Rails-Servers via the REST-JSON-API.

I hope this clears things up.

(Jens) #3

Hello Benjamin, thanks very much for your help!

And just in case someones knows: Where is the “REST API” (Server side) code located?
And where is the code located, that renders the “HTML Pages” in which the ember JS is embedded. Is this also mixed with the REST-API Code? (From my understanding the REST API is the pure server and the HTML Page rendering should already be some Client Side Code…)


(Jens Maier) #4

There is no difference between API code and other code. This is part of RESTful design: if you ask an API to give you a website, you get rendered HTML; if you ask the API to give you serialized JSON, well, that’s exactly what you get.

You can try it yourself: pick any Discourse URL, then append .json. For example, you can get a summary of your recent activity, formatted as a JSON object, from https://meta.discourse.org/users/disscourse/activity.json.


Facsinating. I just pegged a .json to the number 3 (which is your discussion spot), and BAM…I got json stuff all over the place.

I had no clue you could do that.