From 4794060cd0009888e0d98c21a8d12a59bcad95c4 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 25 May 2023 04:44:00 +0200 Subject: [PATCH] tex: add more stuff on app architecture --- tex/text.tex | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tex/text.tex b/tex/text.tex index fa861ab..770c181 100644 --- a/tex/text.tex +++ b/tex/text.tex @@ -815,8 +815,37 @@ similar applies to the database client. These are passed around as a pointer, so the underlying data stays the same. As a rule of thumb, every larger \texttt{struct} that needs to be passed around is passed around as a pointer. -Authentication logic is relatively simple and the author would like to isolate -it into a custom \emph{middleware} but that is a future work. +The authentication logic is relatively simple and the author would like to +isolate it into a custom \emph{middleware}. + +An important thing to mention is embedded assets and templates. Go has multiple +mechanisms to natively embed arbitrary files directly into the binary during +the regular build process. A built-in \texttt{embed} package was used to bundle +all template files and web assets, such as images, logos and stylesheets at the +package level, and these are also the passed around the application as needed. +There is also a toggle in the application configuration, which can instruct the +program at start to either rely entirely on embedded assets or pull live files +from the filesystem. The former option makes the application more portable, +while the latter allows for flexibility not only during development. Basically +any important value in the program has been made into a configuration value, so +that the operator can customise the experience as needed. Sane configuration +details were chosen, which results in the configuration file from essentially +only containing secrets. + +Templates used for rendering of the web pages are created in a composable +manner and split into smaller, reusable parts, such as \texttt{footer.tmpl} and +\texttt{head.tmpl}. An Echo renderer interface has been implemented, so that +the rendering can be performed ergonomically and directly using Echo's built-in +facilities. The application constructs the web pages entirely server-side and +it runs without a single line of JavaScript, of which the author is especially +proud. It improves load times, decreases attack surface, increases +maintainability and reduces cognitive load that is required when dealing with +JavaScript. Of course that requires extensive usage of \texttt{POST}s in forms +and frequent full-page refreshes, but that still is not enough to warrant the +use of JavaScript. + +The author experimented with WebAssembly though, but has ultimately scrapped +the functionality in favour of the entirely server-side rendered. \n{1}{Implementation}