I created this tool for my parents so they can keep track of all the food stuffs they have in their house as they always seemed to forget what they have and ended up buying lots of extra things. The idea was to have a self-hosted website they could access at any point from their tablets or computers to check for anything that's about to expire or if they need to buy anything extra.
The whole UI was designed to be simple to use and clean, and accessible on large screens, as well as tablets. I have not implemented a proper view for mobile as this wasn't a requirement they needed, but I welcome any pull requests to add this.
This project is built using SvelteKit and Prisma (using Sqlite).
Run npm i
first to install necessary dependencies
To initialize the database, run:
npm run init-db
To view a development preview, run npm run dev
To build a production deployment, run npm run build
- The Pi OS has to be 64 bit
- Install
nodejs
versionv18.18
usingnvm
- Delete the
.sveltekit
andbuild
directories in the project npm run build
- Copy over the
build
directory,package.json
, andpackage-lock.json
over to the Pi - Run
npm i --production
on the Pi - Move over the
prisma
directory inside thebuild
directory on the Pi- Example path:
app/build/prisma
- Example path:
- Run
npx prisma generate --schema build/prisma/schema.prisma
on the Pi - Now it's ready to run with
node build
The ORIGIN
and PORT
environment variables can be used to change the port it runs on.
For example, using port 1234
:
ORIGIN=http://localhost:1234 PORT=1234 node build
Note that localhost
can be swapped out for the hostname.local
URL instead.
See here for details on how to access the pi via the hostname up and running.
Firstly, iptables
is required for this, so install it with apt-get
.
The script to run the app in the background on port 80 is the following:
#!/bin/sh
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
ORIGIN=http://localhost/ PORT=3000 nohup node build &