Fully dockered starter kit for Elm with Hasura

Overview

elm-hasura-dockered

This repo contains a Elm-Hasura starter kit for rapid+typesafe web application development on open source foundations.

Elm is great! But what do you run server-side? Server-side updates may change the API and therefor break your app. Using elm-graphql and Hasura we can generate an Elm GraphQL client that exactly fits your data model. After changing the database schema simply regenerate the client code. Any errors resulting from your change show up as errors in your IDE.

Stop writing/debugging layers of error-prone boilerplate and focus on cranking out features!

Highlights:

  • Strong typesafety from database schema, through GraphQL API to frontend (with generated GraphQL client code).
  • Define database schema with a UI that creates migrations! (to aid collaboration and deployments)
  • Hot code reloading in development mode.
  • Optimized (pre-gzipped) production builds, served by Nginx in production mode.
  • And everything runs from containers:
    • No need to install any tooling on the local machine except for docker, docker-compose and make.
    • All versions are pinned, so it should work anywhere (if not please raise an issue).
    • Uninstalls cleanly.

Ingredients

This repo contains the following parts:

  • Dockered Postgres database
  • Dockered Hasura which provides:
    • a GraphQL frontend to Postgres
    • an API gateway with (row based) authorization
    • a UI for schema changes that also manages migrations (see /hasura/metadata and /hasura/migrations)
    • a basic UI for CRUD operations on data
  • Dockered type-safe Elm GraphQL API client generator
  • Dockered Webpack based setup providing:
    • hot code reloading in development
    • production builds (with pre-gzipped artifacts)
  • Dockered Nginx serving pre-gzipped production builds (to show the setup on full speed)
  • Container orchestration with docker-compose
  • A minimal demo Elm app that uses the generated GraphQL client (see /frontend)
  • Some migrations, seed data and basic role definitions (all Hasura managed)
  • A self-documenting Makefile for common tasks (run make help)
  • This README explaining what's inside and how it works

Get going

Assuming you have docker, docker-compose and make installed, let's go!

Start by running Postres and Hasura with:

docker-compose up hasura

Once the hasura docker service is running, start Hasura's console with:

make hasura-console 

This console is only for local development use. To use it point your browser to:

http://localhost:9695

Any changes you make using the console may become migrations (in the /hasura/migrations directory) or may lead to changes to the metadata (in /hasura/metadata). By checking these folders into version control you will always keep the the schema definitions with your code. Hasura can help you in running/managing migrations.

The /hasura/migrations and /hasura/metadata directories are not empty. They contain a simple schema modelling posts that have tags with a many-to-many relationship over a join table. The posts also have a status that is modelled with what Hasura calls an "enum table".

The following command is used to generate the 100% type safe GraphQL client:

make generate-elm-client 

The code will be put in /frontend/src/HasuraClient which is not checked into version control, as it can be re-generated at any time (and needs to be regenerated on schema changes) using the command above.

The following command runs development-mode Webpack in the /frontend container:

docker-compose up hasura 

It proxies request for the hasura container (/v1/graphql) and watches filesystem on the host for changes in the /frontend directory which will be hot-reloaded to the browser on:

http://localhost:3000

Production builds are made with:

make frontend-run-prod

Which compiles/copies/gzips artifacts to /frontend/dist/, from there the production setup may pick it up:

docker-compose up nginx

Point your browser to:

http://localhost:3030

Now check the response times and rejoice!

Moving forward

Interesting ways to extend this setup?

Collaboration is encouraged. Feel free to fork, submit PRs and/or open issues (even if it is to discuss how to improve this setup)!

Caveats

  • Files on the host filesystem are owned by root when created from docker containers. Fix it with: chown $USER:$USER -R .

  • For integration with your IDE you may need to run some local tooling (like node, elm and elm-format).

You might also like...

A starter kit for scaffold-eth projects

🧰 scaffold-eth-cli As simple as running this in your terminal: npx scaffold-eth Clones scaffold-eth into the current folder as fast as possible âšĄïž ⁉

Jun 11, 2022

starter kit for interacting with zora api, protocol, and creator toolkit

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Oct 20, 2022

Web Starter Kit - a workflow for multi-device websites

Web Starter Kit - a workflow for multi-device websites

Overview Web Starter Kit is an opinionated boilerplate for web development. Tools for building a great experience across many devices and performance

Dec 31, 2022

Simple lazy responsive starter kit for CraftCMS 4 Projects.

Simple lazy responsive starter kit for CraftCMS 4 Projects.

Lazy Craft CMS 4 Boilerplate Simple lazy responsive starter kit for CraftCMS 4 Projects. Requirements RTFM Craft CMS 4 Requirements Configs Duplicate

Sep 2, 2022

This project is based on my nodejs starter kit. Simple CRUD project.

nodejs-crud-project Author - Akhil Sharma This project uses the nodeJS-starter project on my github. Just a demo to show you could build any project w

Dec 16, 2022

This is a starter templete for svelte kit and maplibre.

This is a starter template for maplibre and svelte Clone this application by running git clone https://github.com/Thuhaa/svelte-maplibre-starter.git A

Nov 28, 2022

Minimal, SEO-focused website starter kit powered by Notion, GitHub, and Vercel.

Minimal, SEO-focused website starter kit powered by Notion, GitHub, and Vercel.

wr8 wr8 lets you create a website in Notion with better SEO. It is a customized version of nextjs-notion-starter-kit, based on NotionX. Introduction T

Dec 22, 2022

NextJS E-commerce starter kit with Sanity.io and Stripe API 🛍

🛍 Next.js Sanity E-commerce Starter Kit A Next.js E-commerce app with Sanity.io and Stripe API. Built with TailwindCSS framework & SASS CSS extension

Dec 29, 2022

NFT Game Starter Project: https://github.com/buildspace/buildspace-nft-game-starter

Running React on Repl.it React is a popular JavaScript library for building user interfaces. Vite is a blazing fast frontend build tool that includes

Feb 11, 2022
Comments
  • Fixes the Setup instructions

    Fixes the Setup instructions

    Cool project! I tried to make it run using the instructions, while not being that comfortable with Docker and makefiles.

    Small important changes in this PR, that I think uses the correct make commands.

    I might try to improve some of the text instructions later, but thats for another PR.

    opened by Strepto 1
  • Hasura pull access denied

    Hasura pull access denied

    Hey Cies,

    thanks for this project!

    After running docker-compose up hasura I got the following error:

    Error response from daemon: pull access denied for graphql-engine, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

    After I changed the location of the hasura image in the docker-compose.yml from image: graphql-engine:v2.5.0 to image: hasura/graphql-engine:v2.5.0 it worked.

    Do you know if the location has changed? Or does it have to do something with my local setup or something (I'm not really familiar with Docker)?

    Thanks again for the project.

    Best regards, Cor

    opened by gorconsola 0
Owner
Cies Breijs
Cies Breijs
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
⚡ A multipurpose meme marketplace and editor for creating, downloading and sharing memes with a ready to use API powered by Hasura GraphQL

Rocketmeme A multipurpose meme marketplace and editor for creating and downloading memes. View meme collection, browse different meme categories, like

Victor Eke 31 Nov 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Node-cli-starter - Basic starter kit for building Node CLI applications with TypeScript.

node-cli-starter Minimal starter kit for building Node CLI applications with TypeScript. Getting Started To get started clone repo locally and run npm

Cory Rylan 7 May 17, 2022
This repository serves as a starter kit for doing simple TDD exercise

This repository serves as a starter kit for doing simple TDD exercise

adylanrff 3 Feb 19, 2022
Remix starter kit with Tailwind CSS family of libraries: Headless UI, Radix UI, VechaiUI, daisyUI, and more

Remix Tailwind Starter Kit Remix starter kit with Tailwind CSS v3 family of libraries. Example demo to combine the best Tailwind-related ecosystem suc

M Haidar Hanif 80 Dec 18, 2022
A starter kit for beginners to obsidian

This is a starter kit for beginners to obsidian. It is a simplified version of my vault with my daily and weekly note templates, the folder structure for my periodic notes (daily, weekly, monthly etc) and the plugin settings I use.

Pamela Wang 53 Dec 21, 2022
âȘ Rewinds – Remix Tailwind Starter Kit with Tailwind CSS, Headless UI, Radix UI, and more

âȘ Rewinds – Remix Tailwind Starter Kit Rewinds is a Remix starter kit with Tailwind CSS v3 family of libraries. This is an example demo to combine the

M Haidar Hanif 81 Dec 24, 2022
Node starter kit for semantic-search. Uses Mighty Inference Server with Qdrant vector search.

Mighty Starter This project provides a complete and working semantic search application, using Mighty Inference Server, Qdrant Vector Search, and an e

MAX.IO LLC 8 Oct 18, 2022