Getting Started
Prerequisites
Install Node.js
. This allows you to run JavaScript on your computer (outside of a browser).
This is best done with a version manager that allows you to easily switch between
Node.js versions based on the requirements of different projects.
Try using any of the following:
- nvm - node-version-manager
- fnm - fast-node-manager
- nvm-widows - node-version-manager for Windows machines
If none of those work for any reason, you can defer to your Operating System's package manager or the downloads from the official website. We will be using the latest LTS version of Node.
Install pnpm
. This is our package manager of choice for this project.
It's responsible for installing, uninstalling, and keeping track of the app's dependencies.
Make sure to have docker
installed, which can be installed from the official website. It will allow you to:
- Run the local postgres database required for backend functions
- Run backend tests that rely on Testcontainers
Developing
Clone the ZotMeal repository from GitHub:
Navigate to the root directory and change your node version to the one specified in the .nvmrc by running nvm use
or fnm use
.
While still in the root directory, install the dependencies by running cd ZotMeal && pnpm install
.
To start a local Postgres container database, run the docker compose up
in the root directory. This will automatically set up and run a test database using docker.
Create a .env
in the root directory based on the example given in .env.development
.
Run pnpm db:push
to push the schema to the docker database.
Start local development by running pnpm dev:next
in the root directory.
The tRPC procedures are available on http://localhost:3000/router.procedure?input={field: value}
Pull the latest CampusDish data into your local database by cd
'ing into the apps/server
directory and running pnpm run test:daily
or pnpm run test:weekly
.
View the local website at http://localhost:8080 As you make changes to the Next.js application, those changes will be automatically reflected on the local website.
Troubleshooting
Sometimes, you may run into errors when trying to run some of the commands listed above. Here are some things that can help fix this:
Ensure Node is Correct Version
Check by running node -v
(v20).
- If not, download/switch to v20, by running:
OR
Structure Overview
The following directory tree outlines the major folders in the ZotMeal repository:
The node_modules
folder contains all Node.js packages that the repository uses.
The apps
folder contains major endpoints that ZotMeal uses:
apps/next
contains all of the frontend components and scripts used to build the web app, written in Next.js.apps/server
contains the scripts used to connect backend functions to AWS Lambda Serverless procedures.
The packages
folder contains all the functionality of the backend of ZotMeal.
packages/api
contains all the *tRPC procedures usedpackages/db
contains the database schema (written using DrizzleORM)packages/validators
contains information used for type verification of API schemas used in the backend (written using Zod)
Testing
Run turbo test
at the root of the project.
Database
Run the following commands to pull data into your local database. Your local website may display no meals without this step.
If you want to check the contents of the database, run the following command (while the server is not running).
Adding Workspaces
To add a new package run turbo gen workspace
and follow the prompts.