Skip to content

uukelele/fuse-template

Repository files navigation

fastapi uv svelte ephaptic Template

A basic full-stack template for FUSE web applications.

This template uses the FUSE stack:

But it also uses:

  • Docker
  • nginx
  • postgres

... and some more.

Why Use FUSE?

There is a great blog post about it.

But in short:

Don't build APIs. FUSE your frontend and backend together.

The FUSE stack allows you to combine your frontend and backend together, while not having to think about REST, and still enabling things like realtime messages between client and server for apps like messaging platforms, and autogenerated OpenAPI & REST endpoints matching 1:1 with the RPC endpoints.

It's also very performance optimized. It uses FastAPI, based on the Starlette framework, using uvicorn as the primary ASGI server for blazing fast performance1. uv is written in rust and is 10-100x faster than pip2. Svelte is a precompiled frontend framework with much less bloat compared to React. And, of course, making FUSE possible, is Ephaptic. Ephaptic uses Pydantic for validation & serialization (just like FastAPI!) as well as using msgpack over JSON and WebSockets instead of HTTP, for the lowest possible.

If you are worrying about WebSockets breaking compatibility with other clients using your API, don't worry - RPC functions accessible over WebSocket are still accessible, type safe, and are documented in the OpenAPI schema when using HTTP thanks to The Router.

Use the FUSE stack if you care about performance without sacrificing DX.

Setup

To create a FUSE app, click the "Use this template" button on the top right of this page.

Next, clone the repository to your device (or use a GitHub Codespace if you prefer).

After you have done this, simply run ./setup.sh which will automatically configure everything for you. It:

  • Creates your .env file and automatically generates a secure JWT private token stored in the env.
  • Runs npm install in the frontend to ensure you have everything locally.
  • Runs uv sync in the backend to create a venv with the Python packages.
  • Runs a first-time generation of the schema.

Finally, you are ready to build in your IDE of choice!

To run your FUSE app in development mode, run ./watchers.dev.sh in one terminal, to start the automatic watcher that updates the schema on the frontend to match the backend's code.

Then, run ./dev.sh. This runs the dev docker containers, and exposes your app at localhost:4053.

Both the backend and frontend immediately update when you make any code changes to their respective directories, even within Docker, allowing a seamless development experience.

The FUSE stack demo comes with a basic app with nothing but a simple login / register page with it all wired up on the backend and stores the user data in a postgres database.

Here is an example screenshot for when you are logged in:

screenshot


fastapi uv svelte ephaptic

Footnotes

  1. https://fastapi.tiangolo.com/benchmarks/

  2. https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md

About

A basic full-stack template for FUSE web applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors