Sivoph Hi, welcome to Flarum! The general gist of the frontend system is as follows:
Flarum is an SPA, so for the most part the backend is just a REST API, and all frontend functionality is done through the Mithril JS based frontend code. When you connect to a flarum site, your browser downloads and runs a few files that contain all this code.
Extensions register their frontend code with Flarum via the Frontend
extender, essentially giving a directory that contains bundled and minimized code. Flarums backend then combines all extension code together to get the assets served to users. We minimize/bundle code as part of development so that:
- code can be split into multiple files
- code can be minimized
- TypeScript can be used
- some import mechanics can be supported
Among other reasons. Essentially, if you look at most extensions, they have a js folder with src and dist subdirectories. Source code lives in src, and then whenever changes are pushed to GitHub an automatic GitHub actions script rebuilds the dist bundled js.
As for the structure of code itself, there's nothing too fancy: the src folder has subdirs for admin code and forum code; each of those has an index.js file that executes when the user accesses the corresponding frontend. Often though frontend code depends on the global application object being loaded, so we wrap it it in a closure and put that into a global array of initializers so that it's run at the correct time.
If you haven't yet done so, I'd heavily recommend taking a look at our extension development docs: https://docs.flarum.org/extend/frontend