riven
GitHub Repo stars GitHub Repo stars Issues License Contributors Discord

Riven Frontend

This repository contains the frontend for Riven. It is build with SvelteKit.


Table Of Contents

Running the frontend

To run the frontend, you need to have the backend running. You can find the backend here

Make sure you have docker and docker-compose installed on your system.

Edit the docker-compose.yml (make sure to replace the environment variables with your own) file to match your setup:

Then run the following command:

docker-compose up -d

It will start the frontend container called riven-frontend on port 3000.

Manual installation

Make sure you have pnpm installed on your system.

Install the dependencies:

pnpm install

Then run the following command:

pnpm run build

It will build the frontend in the build directory.

Then run the following command:

ORIGIN=http://localhost:3000 node build

It will start the frontend on port 3000.

Environment variables

Refer to the .env.example file for the list of environment variables required to run the frontend.


Developing

First install dependencies with pnpm install. Then create .env with same content as .env.example and fill in the values. Then start the development server:

[!NOTE]
It is recommended to use latest LTS version of Node.js. If using pnpm you can run pnpm env use --global lts to switch to the latest LTS version.

pnpm run dev

Generating API schema & types

To update Backend API schema & types, run:

pnpm run generate-api

To update TMDB/TVDB provider types, run the commands in /src/lib/providers/index.ts.

To update Trakt provider types, run the commands in /scripts/trakt-b2s.ts. Optionally if remote trakt spec is updated, replace /scripts/trakt.apib with the latest from Trakt API description document

Database schemas and migrations & Authentication

We use Better-Auth for authentication and user management, and Drizzle ORM for database management. Better-Auth is also configured to use Drizzle ORM as its database layer.

The database schemas are defined in src/lib/server/schema and migrations are in /drizzle.

Drizzle config is in drizzle.config.ts and db connection is in src/lib/server/db.

Better-Auth config is duplicated at better-auth.config.ts for CLI usage and src/lib/server/auth.ts for runtime usage. This is due to the limitation of Better-Auth CLI not being able to read SvelteKit's environment variables.

This codebase uses the "Runtime Migrations" approach (option 4) of Drizzle ORM, which means migrations are run automatically on server start (ran in init function of src/hooks.server.ts).

Now, schema for auth is generated by Better-Auth CLI and output to src/lib/server/schema/ba-auth.ts. To update the schema file after changing Better-Auth config, run:

pnpm run ba:generate

Then to create a new migration file based on the updated schema, run:

pnpm run db:generate

Now, to apply the migration to the database, simply restart the server and it will run the migration automatically.

If you edit schema files or add new schema files (not auth related), you can run the following command to generate a new migration file based on schema changes:

pnpm run db:generate

Again, to apply the migration to the database, simply restart the server.

It's not recommended to use pnpm run db:pull, since it outputs migration along with single schema & relation file, which are moved to src/lib/server/schema managed by the /scripts/drizzle_pull.sh script. This overwrites the schema & relation files (not the better-auth schema file) every time it's run.


Contributing

We welcome contributions from the community! To ensure a smooth collaboration, please follow these guidelines:

Submitting Changes

  • Open an Issue: For major changes, start by opening an issue to discuss your proposed modifications. This helps us understand your intentions and provide feedback early in the process.

  • Pull Requests: Once your changes are ready, submit a pull request. Ensure your code adheres to our coding standards and passes all tests.

Code Formatting

  • Frontend: We use Prettier for code formatting. Run prettier on your code before submitting. You can use the following command:
pnpm run format
  • Line Endings: Use CRLF line endings unless the file is a shell script or another format that requires LF line endings.

Contributors

Thanks goes to these wonderful people


Star History

Star History Chart

Top categories

Loading Svelte Themes