Skip to content
/ rusve Public
forked from mpiorowski/rusve

Open source application build using SvelteKit with Rust as microservices with gRPC.

License

Notifications You must be signed in to change notification settings

liamwh/rusve

 
 

Repository files navigation

Welcome to Rusve!

What is Rusve?

It is a attempt to find the best way to build fast and scalable web applications, while not beeing afraid of new technologies. And I think we are getting there.

Feel free to ask questions and throw new ideas! Any contribution is also welcome, especially some ux/ui redesigns :)

Currently working on...

  • MDX
  • Make it work without js
  • Any other feature You will request :)

Application

https://www.rusve.app

CMS

https://directus-cms.fly.dev | Login: [email protected] | Password: d1r3ctu5

Features

  • Backend
    • Microservices - Splitted into smaller parts, very easy to scale, and allows using any combination of languages and databases.
    • Rust - Most of the logic written in Rust, hard but amazing language. Almost impossible to write code that will not start.
    • Go - One service written in Go, very easy to learn while still having great performance.
    • gRPC - Connection between services using gRPC, which is very fast and gives an option for bi-directional streaming. For Rust using great Tonic create, with first class support of async/await.
    • Typesafety - Thanks to protobuf, amazing typesafety across the whole project, no matter the language (not only for TS, hi tRPC).
    • Sql Pools and Transactions - Using the best practice for the best performance and error handling.
    • Dockerized - Every service is dockerized. Local build ready with one command.
  • Frontend
    • SvelteKit - Once You try it, it's hard to go back to any other framework.
    • Typescript - Fully written in typescript with the strict rules enforced. No any or unknown in code.
    • Form actions - Forms are handled by server, which force You to seperate view and logic. This is a great pattern and makes the logic unaccesible by the browser.
    • Zod validation - Every data if validated. Errors are returned and used by client to view them on forms.
    • Streaming - Important data is loaded and rendered first, after that all the rest are returned as promises and rendered when they resolve.
    • PWA with service workers - Turn off the internet and check how resiliant the app is.
    • Firebase SSR Authentication - Battle-tested OAuth, Magic Link, Phone Number. And by doint it on Svelte server, it's much more secure.
    • TailwindCSS - Used for styling, no other UI library needed.
    • Minimal external libraries - With Svelte animation and stores builing custom components is very easy. Checkout Toast, Drawer, Modal, Dropdown and see for yourself.
  • Deployment
    • Google Cloud Platform - Easy to deploy, easy to scale, easy to maintain, and still cheap.
    • Github Action - Ready to use github actions for deployment, each service is linted and checked. Possible to deploy all services or a single one.
    • Google Cloud Run - Thanks to dockerized application, it's very easy to deploy. Scaling done automatically, can set the min. instances to 1 to reduce cold start.
    • Google Cloud Storage - Working files upload, download and delete.
    • PubSub - Asynchronus data sending.
  • Additional features
    • Stripe - Fully working subscription flow.
    • HeadlessCMS - Headless cms via Directus.
    • WYSIWYG - Wyswig text editor thanks to TipTap.

Architecture

image

Authorization

image

Github action deployment

Release all

image

Release single

image

Aria and PWA with offline service workers

image

Dev deployment

  1. Client setup
cp client/.env.example client/.env
npm i --prefix client
  1. Run proto generation
sh proto.sh
  1. Fill in missing firebase secrets in client/.env
  • STRIPE_API_KEY
  • PUBLIC_API_KEY
  • PUBLIC_AUTH_DOMAIN
  • SERVICE_ACCOUNT

Getting the SERVICE_ACCOUNT key is a bit tricky.

  1. Start docker:
docker-compose up --build
  1. Access:

Application - http:https://localhost:3000
CMS - http:https://localhost:8055 | Login: [email protected] | Password: d1r3ctu5

Production deployment

  1. Go through each deploy-***.yml and change env acording to Your project.

  2. Add secrets to github

  • GCP_CREDENTIALS
  • DB_PASS
  • STRIPE_API_KEY
  • SENDGRID_API_KEY
  • PUBLIC_API_KEY
  • PUBLIC_AUTH_DOMAIN
  • SERVICE_ACCOUNT
  1. Add proper IAM permissions

image

Bonus: Three ways to shows notes. Not implemented in application, but all the code is there to try it.

This project shows how flexible the gRPC + SvelteKit setup is, using the newest SvelteKit streamed feature. There are three ways to display notes:

  1. svelte server calls notes service -> notes service selects all notes -> for each note it calls users service for user -> the note with the user is returned as stream
  2. svelte server calls notes service -> notes service selects all notes and return them -> for each note svelte server calls users service for user -> not waiting for users to resolve, he dispaly the notes, and after that await users as streamed data
  3. svelte server calls notes service -> notes service selects all notes and return them -> for each note svelte server add userId to set -> then, in one request he calls users service for all users -> not waiting for users to resolve, he displays notes and after that await users as streamed data

About

Open source application build using SvelteKit with Rust as microservices with gRPC.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 63.5%
  • Svelte 19.0%
  • TypeScript 14.5%
  • JavaScript 1.1%
  • Go 0.9%
  • Dockerfile 0.4%
  • Other 0.6%