Skip to content

Backend

Randy edited this page Jul 3, 2024 · 1 revision

Backend

Before you start:

Epsilon uses 3 different types of backends within two repos.

https://github.com/stuysu/epsilon-database <- SQL files, database functions, configuration

https://github.com/stuysu/epsilon-functions <- API Routes

How is the backend maintained?

For the database, it's maintained by just running a few files into the supabase SQL editor. This isn't the greatest way, but the database is usually managed by the IT-directors anyways, and it's manageable when 1 or 2 people quickly add tables and RLS instead of 1 or 2 people slowly adding tables and security due to boilerplate.

For edge functions, you simply need to push to the main branch of the edge functions repository and a webhook on our server will automatically update the backend. The way supabase edge functions work is they run a Deno server. Deno is an anagram of node. Instead of downloading packages, it imports packages from urls at run time. When you edit a deno file and save it, it automatically updates the route, as if you were running an express server with nodemon. For edge functions, there is a _shared folder which contains all our utility functions. If you want to create a route, just create a new folder. That folder will be the name of the edge function and inside have an index.ts that copies the format of existing routes.

For edge functions, you simply act as if the route was another client. You can skip some validation because validation already exists via RLS.

If you want to interact with the backend, supabase has automatically generated docs you can find via the CMS (IT directors will know the password), but you can look at existing calls.

It's a scrappy operation, but it's fast and it only takes 1-2 people. You can create tables very quickly, and even edit them.

Clone this wiki locally