Frontend (/src/web)¶
The frontend is structured as a typical Model-View-Controller (MVC) application, but instead of having Controller-classes, everything is a Web Component (extending from HTMLElement). On top of that, the concept of Services and Helpers are introduced.
The frontend project has two predefined Web Components:
RootComponentCanvasComponent
Flow-wise, this is how things work together:
wwwroot/index.htmlloads thesrc/index.tssrc/index.tsdefines which Web Components are available to the pagewwwroot/index.htmlrenders a<game-root>HTML element, which causessrc/components/RootComponent.tsto be rendered.src/components/RootComponent.tsrenders thesrc/components/CanvasComponent.tsby defaultsrc/components/CanvasComponent.tscommunicates with the backend and renders the result accordingly
Each file tries to adhere to the Single Responsibility principle from SOLID:
- Anything under
wwwrootdetermines what the user will see - Anything under
src/componentshandle how the user can interact with what they will see - Anything under
src/serviceshandle specific tasks for the Web Components, for example communicating to the backend. - Anything under
src/helpersis logic that could be considered static functions.