template_backend

module
v0.0.0-...-345a40a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: MIT

README

template_backend

This is a template application I use frequently to spin simple applications up quickly. The stack is essentially:

  • DB: Sqlite (schema managed by Atlas, entities managed by Ent)
  • Backend: Go
  • Frontend: Svelte (in Typescript)
  • RPC API: Twirp

The golang backend implements the twirp API server and also serves static FE files (index.html, css, js, etc). The protocol buffer API definition generates both go code for the server implementation and the client-side typescript code the frontend to use. The sqlite db is replicated to S3 (in production) by litestream.

How to deploy

TODO

Things I'd like to improve

  1. Serve static files via the go static file server without giving up Hot Module Replacement, so that you don't have to use the node webserver in development.
  2. Split the one_time_setup script into 2 different scripts: onetime/rename_repo.sh and onetime/verify.sh, so that the latter can be used when changes need to be made to this (template) repo but you want to try out the working demo before comitting changes.

Steps

  1. git clone https://github.com/cameront/template_backend [your_directory]
  2. ./scripts/one_time_setup.sh
  3. (source env_dev.sh && air)
  4. pushd _ui && npm run dev

Optional Additional Steps

Rename ish

Rename the "count" service to the name of the service ([servicename]) you want to build.

  1. replace rpc/count/countservice.proto package names with references to [servicename]
  2. replace scripts/protogen.sh with references to [servicename]
  3. mv rpc/count/countservice.proto rpc/[servicename]/[servicename]service.proto
  4. mv rpc/count -> rpc/[servicename]
  5. rm -rf rpc/count
  6. ./scripts/protogen.sh
  7. optionally replace the server port (5001) and the UI dev port (5000) with those of your liking

Directories

Path Synopsis
cmd
ent
rpc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL