The steps below will walk you through setting up your own instance of the project.
To set up the development environment for this website, you'll need to install the following on your system:
- Node (see version in .nvmrc) (To manage multiple node versions we recommend nvm)
- pnpm
- GDAL
- PostgreSQL
The data files are hosted in Google Drive. The recommended approach to download them is:
- Install the Google Drive desktop app for your operating system
- In the Google Drive app, sync the Food Twin 2.0/Version3 folder
- Copy the files to your local seed data directory using rsync to resolve symlinks:
# Replace SOURCE_PATH with your Google Drive folder path
# TARGET_PATH should match SEED_DATA_PATH in your .env file
rsync -av --copy-links "SOURCE_PATH/Food Twin 2.0/Version3/" TARGET_PATH/
The project uses environment variables, which are set by default in the .env file. To customize these variables (e.g., to use a custom database), create a .env.local
file at the root of the repository (cp .env .env.local
) and modify as needed.
For more detailed instructions on working with environment variables in Next.js, please consult the Next.js Environment Variables documentation.
Note: The .env.local
file is configured to be ignored by Git to prevent accidental exposure of sensitive information.
If you use nvm
, activate the desired Node version:
nvm install
Install Node modules:
pnpm install
Apply migrations and ingest seed data:
pnpm db:seed
Start development server:
pnpm dev
✨ You can now access the app at http://localhost:3000
The seed command executes an ETL process, transforming model output files for PostgreSQL ingestion, and optimizing with indexes and foreign keys for efficiency. It is not recommended to run this process on a cloud database as it is resource-intensive and can be performed locally.
The recommended steps are:
- Follow the steps in the previous section to populate the local database
- Generate a dump file with
pnpm db:dump
- Update
DATABASE_URL
in.env.local
with the remote database connection string - Restore the remote database with the generated dump file:
pnpm db:restore