Skip to content

bossbadi-web/perceptron

Repository files navigation


Perceptron

Convert your handwritten notes into an interactive study guide
https://perceptron.gopubby.com

Tip

The following commands are designed for a Linux environment. You may need to adjust them for your operating system.

Installation

  1. Clone the repository

    git clone https://github.com/bossbadi/perceptron
  2. Install the dependencies

    npm install
  3. Create a Supabase project

  4. Add environment variables

    cp .env.example .env
    # and fill in .env with your environment variables
  5. Run the application in development mode

    npm run dev

    or in production mode

    npm run build
    npm run preview

Hosting

Vercel is the obvious choice here, but keep in mind that Vercel functions have a 10 second timeout limit. If the images you upload are too large, the question generation will be stuck on the loading screen.

Therefore, I recommend hosting the app on a private server. I'm currently using Fly.io and everything works great.

Fly.io

To automatically redeploy the app on Fly.io every time you push changes, add the following action secrets to your repository:

  • ENV_FILE = Copy and paste the contents of .env
  • FLY_API_TOKEN = Create a Fly.io access token and add it here

Backup

  1. Install PostgreSQL

    sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
    sudo apt update
    sudo apt install -y postgresql-15
  2. Set environment variables

    export PGPASSWORD="YOUR_DATABASE_PASSWORD"
    export CONNECTION_STRING="YOUR_DATABASE_CONNECTION_STRING"
  3. Backup the schema (structure of the database)

    pg_dumpall -f backups/schema.sql -d $CONNECTION_STRING --schema-only --no-owner --clean
  4. Backup the data (contents of the database)

    pg_dumpall -f backups/data.sql -d $CONNECTION_STRING --data-only --disable-triggers

Restore

You can restore to a hosted Supabase project or a local one.

  1. Install PostgreSQL

    sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
    sudo apt update
    sudo apt install -y postgresql-15
  2. Set environment variables

    export PGPASSWORD="YOUR_DATABASE_PASSWORD"
    export CONNECTION_STRING="YOUR_DATABASE_CONNECTION_STRING"
  3. Restore the schema

    psql -d $CONNECTION_STRING -f backups/schema.sql
  4. Restore the data

    psql -d $CONNECTION_STRING -f backups/data.sql
  5. If you're restoring to a hosted Supabase project, you may need to manually update some configurations, such as enabling auth providers.

Run Supabase Locally

  1. Install Docker

    sudo apt install -y docker.io
  2. Start Supabase

    npm exec supabase start
  3. Stop Supabase

    npm exec supabase stop
  4. Reset Supabase to a clean state

    npm exec supabase db reset