Hello! Thanks for checking out Support SF Schools. We started this project in summer 2022 to solve a big problem in San Francisco. Schools need help. And people who live or work in SF want to support local schools, but they don’t know how. We are building a website to help solve that.
To run this project locally, please perform the following steps:
-
Clone the repository
git clone https://github.com/sfbrigade/support-sfusd.git
-
Install dependencies at the root directory
npm install
-
Create your environment file
Create a local
.envfile from the example env file:cp .env.example .envThen add your Mapbox public token:
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_public_token -
Set up the database
This project uses Prisma with Postgres. To set up for local development, you can run a local Postgres database using Docker. Follow the Docker setup instructions here:
docker/README.mdAfter Docker is installed and the local database container is running, make sure your .env file points Prisma to the local database.
POSTGRES_PRISMA_URL=postgresql://postgres:supersecret@localhost:5432/postgres POSTGRES_URL_NON_POOLING=postgresql://postgres:supersecret@localhost:5432/postgresThen push the Prisma schema to your local database:
npx prisma db pushSeed the database:
npx prisma db seed -
Run the development server
npm run dev
-
Open http://localhost:3000 with your browser to see the result
- Alternatively, you can open http://[LAN_IP]:3000 on another device, such as a phone on the same network. Replace
LAN_IPwith the IP address of your development server, which can be found inside of the "LAN url" part of thenpm run devlog.
- Alternatively, you can open http://[LAN_IP]:3000 on another device, such as a phone on the same network. Replace
You need to sign up for Mapbox to run the project locally.
-
Goto https://www.mapbox.com and sign up
-
It will ask you for billing information, but it is pay as you go. You have 500 instances before you are charged.
We're using Prisma as our ORM. If you're unsure of what it is or what it does here is a link to the prisma documentation regarding how it works and why its used
Production no longer resets on every deploy. The
buildscript now runsprisma migrate deploy, which only applies migrations that haven't been applied yet — it never drops or wipes existing data. A full wipe + reseed only happens when someone explicitly runsnpm run db-reset-and-seed(see Seeding below).
Prisma documentation on prototyping schema
-
If you want to make changes to any model in prisma, the schema file within the prisma folder is where those changes will take place
-
For local prototyping only, you can push schema changes straight to your local database without creating a migration file:
npx prisma db push
-
Once you're happy with the model changes, create a real migration so the change is tracked and can reach production via
prisma migrate deploy:npx prisma migrate dev --name <describe-the-change>
This writes a new folder under
prisma/migrations/— commit it along with your schema change.migrate deploy(run automatically on every production build) only applies migrations from this folder, so a schema change that was only ever pushed withdb pushwill never reach production.
-
prisma/seed.tspopulates the database fromprisma/schools.jsonusingcreate(notupsert), so it only works against an empty database — it's not safe to run against a database that already has data in it. -
Production keeps its data across deploys now. To intentionally wipe the database and reseed it from scratch (e.g. after a model change, or to reset stale data), run:
npm run db-reset-and-seed
This is destructive — it drops all data, reapplies every migration, then reseeds from
prisma/schools.json. Only run it against a database you're fine erasing (point.envat local/Docker Postgres for local testing, or at the Vercel Postgres URLs if you specifically intend to reset production).
Create an environment file to pass your default public token from Mapbox and connect Prisma to postgres
-
Create the local server env file in the main directory (with the README.md file):
cp .env.example .env
-
Add your default public token to your
.envNEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_default_public_token
-
For the prisma configuration you're going to need the vercel postgres URLs. For security, please ask an existing developer for this information. Add both of these to your
.envfile. Alternatively, you can follow these instructions to set up a local Postgres instance in a Docker container.POSTGRES_PRISMA_URL=ask_a_dev POSTGRES_URL_NON_POOLING=ask_a_dev
Visit our Notion for Engineers
For Tailwind CSS, do not use h-screen as it is broken on mobile Safari. Instead, use our custom class h-dvh-with-fallback until which time the official h-dvh alone suffices (fallbacks are not needed).