Mattermost, Inc.

[SOLVED] Technical question on how this application starts up

I am trying to understand the guts of this application and how it works.

How is root.jsx executed from Go? Can someone please explain in some level of detail how the Go backend connects with the React front end? How is it initially “booted up”? How does the webpack.config.js come into play?

I can see this line in root.html

<script>
    window.setup_root();
</script>

But I am not sure how it all connects.

thank you

In brief:

  • User goes to Mattermost
  • The go code serves the static root.html.
  • The web browser requests the additional assets listed in root.html.
  • One of those JavaScript assets (https://github.com/mattermost/platform/blob/master/webapp/root.jsx#L85) has registered the window.setup_root() function which is then executed automatically by the web browser because of the <script> tags.
  • The JavaScript webapp takes over from here.
1 Like

Yeah I figured it out but thanks for writing it out, it’s a very elegant technique.