All Projects → adnaan → gomodest-starter

adnaan / gomodest-starter

Licence: MIT license
A complex SAAS starter kit using Go, the html/template package, and sprinkles of javascript.

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
Svelte
593 projects
Dockerfile
14818 projects
Makefile
30231 projects
SCSS
7915 projects

Projects that are alternatives of or similar to gomodest-starter

gomodest-template
A template to build dynamic web apps quickly using Go, html/template and javascript
Stars: ✭ 77 (+13.24%)
Mutual labels:  bulma, sveltejs, stimulusjs
Stimulus reflex
Build reactive applications with the Rails tooling you already know and love.
Stars: ✭ 1,928 (+2735.29%)
Mutual labels:  server-side-rendering, stimulusjs
http-interceptors
The Web apps in this monorepo make HTTP requests and require uniform consistency in how they are executed and handled. This monorepo demonstrates the same app written with Angular and with Svelte. Each app uses HTTP interceptors. The Angular app uses HttpClient and its interceptors while the Svelte app uses Axios and its interceptors.
Stars: ✭ 46 (-32.35%)
Mutual labels:  bulma, sveltejs
stimulus todomvc
[WIP] An implementation of TodoMVC using Ruby on Rails and StimulusJS
Stars: ✭ 14 (-79.41%)
Mutual labels:  server-side-rendering, stimulusjs
sveltekit-starter
Sveltekit starter project created with sveltekit, typescript, tailwindcss, postcss, husky, and storybook. The project has the structure set up for the scaleable web application.
Stars: ✭ 482 (+608.82%)
Mutual labels:  server-side-rendering, sveltejs
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+630.88%)
Mutual labels:  server-side-rendering, sveltejs
stimulus reflex todomvc
An implementation of TodoMVC using Ruby on Rails, StimulusJS, and StimulusReflex
Stars: ✭ 50 (-26.47%)
Mutual labels:  server-side-rendering, stimulusjs
mathesar
Web application providing an intuitive user experience to databases.
Stars: ✭ 95 (+39.71%)
Mutual labels:  sveltejs
pushtape-cassette
A lightweight framework for building static music apps. Make a cassette.json of your music and render a complete music site in seconds, featuring a persistent music player.
Stars: ✭ 22 (-67.65%)
Mutual labels:  webapp
scruffy-server
Scruffy micro web server to have your own UML class/sequence diagram page like yUML and even more lean.
Stars: ✭ 44 (-35.29%)
Mutual labels:  webapp
plugins
Elder.js plugins and community plugins.
Stars: ✭ 80 (+17.65%)
Mutual labels:  sveltejs
svelte3-translation-ru
Russian translation of the official Svelte resources
Stars: ✭ 49 (-27.94%)
Mutual labels:  sveltejs
fastify-example
Example webapp with Fastify
Stars: ✭ 18 (-73.53%)
Mutual labels:  webapp
ReplCustoms
A database of users, posts, and comments from the ReplTalk API
Stars: ✭ 17 (-75%)
Mutual labels:  webapp
ssr-starter-pack
Moved to https://github.com/Brigad/ssr-starter-pack
Stars: ✭ 12 (-82.35%)
Mutual labels:  server-side-rendering
theme-bulma
🎈 Customization of Oruga components with Bulma CSS framework
Stars: ✭ 88 (+29.41%)
Mutual labels:  bulma
hr-time
High Resolution Time
Stars: ✭ 43 (-36.76%)
Mutual labels:  webapp
medellinjs
MedellinJS
Stars: ✭ 61 (-10.29%)
Mutual labels:  server-side-rendering
staticfuzz
Memories which vanish
Stars: ✭ 15 (-77.94%)
Mutual labels:  webapp
restaurant-finder-featureReviews
Build a Flask web application to help users retrieve key restaurant information and feature-based reviews (generated by applying market-basket model – Apriori algorithm and NLP on user reviews).
Stars: ✭ 21 (-69.12%)
Mutual labels:  webapp

GOMODEST is a Multi Page App(MPA) starter kit using Go's html/template, SvelteJS and StimulusJS. It is inspired from modest approaches to building webapps as enlisted in https://modestjs.works/.

Motivation

I am a devops engineer who dabbles in UI for side projects, internal tools and such. The SPA/ReactJS ecosystem is too costly for me. This is an alternative approach.

The main idea is to use server rendered html with spots of client-side dynamism using SvelteJS & StimulusJS

The webapp is mostly plain old javascript, html, css but with sprinkles of StimulusJS & spots of SvelteJS used for interactivity sans page reloads. StimulusJS is used for sprinkling interactivity in server rendered html & mounting Svelte components into divs.

Stack

A few things which were used:

  1. Go, html/template, goview,
  2. Authentication: github.com/adnaan/authn
  3. SvelteJS
  4. Hotwire
  5. Bulma CSS

Many more things in go.mod & web/package.json

To run, clone this repo and:

$ make install
# another terminal
$ make run-go

The ideas in this starter kit follow the JS gradient as noted here. I have taken the liberty to organise them into the following big blocks: server-rendered html, sprinkles and spots.

Server Rendered HTML

Use html/template and goview to render html pages. It's quite powerful when do you don't need client-side interactions.

example:

func accountPage(w http.ResponseWriter, r *http.Request) (goview.M, error) {

	session, err := store.Get(r, "auth-session")
	if err != nil {
		return nil, fmt.Errorf("%v, %w", err, InternalErr)
	}

	profileData, ok := session.Values["profile"]
	if !ok {
		return nil, fmt.Errorf("%v, %w", err, InternalErr)
	}

	profile, ok := profileData.(map[string]interface{})
	if !ok {
		return nil, fmt.Errorf("%v, %w", err, InternalErr)
	}

	return goview.M{
		"name": profile["name"],
	}, nil

}

Sprinkles

Use stimulusjs to level up server-rendered html to handle simple interactions like: navigations, form validations etc.

example:

    <button class="button is-primary is-outlined is-fullwidth"
            data-action="click->navigate#goto"
            data-goto="/  "
            type="button">
        Home
    </button>
    goto(e){
        if (e.currentTarget.dataset.goto){
            window.location = e.currentTarget.dataset.goto;
        }
    }

Spots

Use sveltejs to take over spots of a server-rendered html page to provide more complex interactivity without page reloads.

This snippet is the most interesting part of this project:

{{define "content"}}
    <div class="columns is-mobile is-centered">
        <div class="column is-half-desktop">
            <div
                    data-target="svelte.component"
                    data-component-name="app"
                    data-component-props="{{.Data}}">
            </div>
        </div>
    </div>
    </div>
{{end}}

source

In the above snippet, we use StimulusJS to mount a Svelte component by using the following code:

     import { Controller } from "stimulus";
     import components from "./components";
     
     export default class extends Controller {
         static targets = ["component"]
         connect() {
             if (this.componentTargets.length > 0){
                 this.componentTargets.forEach(el => {
                     const componentName = el.dataset.componentName;
                     const componentProps = el.dataset.componentProps ? JSON.parse(el.dataset.componentProps): {};
                     if (!(componentName in components)){
                         console.log(`svelte component: ${componentName}, not found!`)
                         return;
                     }
                     const app = new components[componentName]({
                         target: el,
                         props: componentProps
                     });
                 })
             }
         }
     }

source

This strategy allows us to mix server rendered HTML pages with client side dynamism.

Other possibly interesting aspects could be the layout of web/html and the usage of the super nice goview library to render html in these files:

  1. router.go
  2. view.go
  3. pages.go

That is all.


Attributions

  1. https://areknawo.com/making-a-todo-app-in-svelte/
  2. https://modestjs.works/
  3. https://github.com/foolin/goview
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].