Skip to content
/ eye Public

👁 Personal website built with Rust (actix, diesel) and Typescript (SolidJS, vanilla-extract), running on a single-board computer with low memory footprint.

Notifications You must be signed in to change notification settings

thibautRe/eye

Repository files navigation

Eye

Personal self-hosted website aimed to be run on an Olimex Board (OlinuXino A20).

Architecture

The backend of the web service is running a compiled program written in Rust. This language was chosen for its lower memory footprint compared to other interpreted languages such as Python and Javascript. The main libraries used are Actix (web server framework) and Diesel (query builder).

The API used to communicate with the web clients is a REST API. Authentication is handled via JWT.

The frontend of the web service is a TypeScript webapp using the SolidJS framework, and bundled using Vite. SolidJS was chosen for its lower network footprint, compared to other frameworks such as React. The styling of the app is handled using vanilla-extract as a CSS-in-JS utility. The color theme is using colors from the Radix-UI Colors project.

The images placeholders are generated and presented using Blurhash.

Install

Install postgresql, and libpq-dev. On Fedora, run sudo dnf install libpq-devel.

Install diesel-cli:

cargo install diesel_cli --no-default-features --features postgres
# edit the .env values as needed
cp .env.example .env

# create the "extract from" folder
mkdir .extract-from

# run migration
yarn db:migrate

# extract the pictures in the "extract from" folder.
#
# Note: It is recommended to add the `-r` (release) flag, which makes thumbnail extraction
# much faster and can be worth the overhead of extra compilation time.
cargo run -r extract-pictures

# start api server
yarn start:rs

# start frontend server
yarn start

Create a new migration:

diesel migration generate <name-of-migration>
# run migration
yarn db:migrate
# redo last migration
yarn db:migrate:redo

Generate a JWT secret

Run this in a shell

node -p "require('crypto').randomBytes(100).toString('base64')"

Put the result in the JWT_SECRET env variable in .env. Run the server with cargo run serve --unsafe-no-jwt-checks, and go to http://localhost:5750/admin/jwt_gen#force-admin to get a valid admin JWT and hit the "use" button. You can then restart the cargo server without the flag.

Troubleshooting

Postgres issues after Fedora major version update

Updates on major versions can cause issues with postgres. Here are the steps that I followed:

  • If the database isn't up, restart with sudo systemctl restart postgres.service
  • If that fails, checks the logs with journalctl -xeu postgres.service
  • If the logs mention an update, run sudo postgresql-setup --upgrade

If the database is up but the user postgres cannot be logged in as, edit the file /var/lib/pgsql/data/pg_hba.conf as root and change the 2 lines that mention localhost connections from ident to md5.

About

👁 Personal website built with Rust (actix, diesel) and Typescript (SolidJS, vanilla-extract), running on a single-board computer with low memory footprint.

Topics

Resources

Stars

Watchers

Forks

Languages