gustavoteixeirah / go-svelte-grpc

Go with SvelteKit using gRPC template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go with SvelteKit using gRPC template

If You have any questions, feel free to ask them in Discussions or Issues. I hope this will be helpful :).

Right now this is a finished template. I run a bigger project, where I use both Go and Rust, and that one I will try to keep updated :). Fell free to check it out Go and Rust with SvelteKit using gRPC

Architecture

Screenshot from 2023-01-08 23-48-07

  • SvelteKit for frontend and for gRPC gateway using nodejs
  • Go for microservices
  • SvelteKit server for page protection and data gateway, nothing is exposed to client, can work without any Javascript
  • Using GCP Bucket for files and Pub/Sub for emails
  • Gateway communicate with go backend using gRPC (nightmare to make it work using Typescript...)
  • Go microservices communicates with each other using also gRPC.
  • So yeah, everything works on gRPC, either as streams or unary, IT IS FAST (locally request can be as fast as 3-10 ms)
  • Everything is deployed using Google Cloud Run
  • Authorization using Auth.js (experimental version for svelte)

Overview

  • User can log in using google account via AuthJs
  • Page protection on hook Handle function, so every request is protected / checked.
  • Can upload/delete files stored on Bucket
  • Can send email asynchronus via Pub/Sub
  • Over engineered functionality of Notes:
    • Adding / deleteing notes as Unary flow, send request, get response
    • Get notes works on stream, gateway starts a stream with notes service
    • Note service get a list of notes, and for each notes, via another stream, ask users service for user data
    • Single combined note is sent to gateway as soon as it's ready
    • When all of the notes are gatehered on gateway, it return it to frontend

Fast dev deployment (without files and email)

npm i --prefix client/
cp docker-compose.yml.dist docker-compose.yml

Fill this docker variables:

docker-compose up

For working email and files, You need a working GCP deployment

Topic for pubsub is called "email" pointing to "/email" service POST as push PUBSUB.

Missing variables for working application:

  • EMAIL_API_KEY - sendgrid api key
  • EMAIL_FROM - address for email (must be verified by sendgrid)
  • EMAIL_NAME - email FROM name, can be whatever You like :)
  • BUCKET - name of the GCP bucket

GCP IAM overview

image

About

Go with SvelteKit using gRPC template

License:MIT License


Languages

Language:TypeScript 52.3%Language:Go 26.9%Language:Svelte 15.1%Language:CSS 2.3%Language:JavaScript 1.9%Language:PLpgSQL 0.8%Language:HTML 0.4%Language:Shell 0.2%