Skip to content

About

Support SF Schools web site (dev deployment at: https://support-sfusd.vercel.app, Kanban board at: https://github.com/orgs/sfbrigade/projects/7?pane=info

Resources

Stars

13 stars

Watchers

6 watching

Forks

Repository files navigation

About Support SF Schools

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.


Tech Stack

Next.js Typescript React Tailwind CSS HTML CSS


Get Started

To run this project locally, please perform the following steps:

  1. Clone the repository

    git clone https://github.com/sfbrigade/support-sfusd.git
  2. Install dependencies at the root directory

    npm install
  3. Create your environment file

    Create a local .env file from the example env file:

    cp .env.example .env
    

    Then add your Mapbox public token:

    NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_public_token
    
  4. 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.md
    

    After 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/postgres
    

    Then push the Prisma schema to your local database:

    npx prisma db push
    

    Seed the database:

    npx prisma db seed
    
  5. Run the development server

    npm run dev
  6. 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_IP with the IP address of your development server, which can be found inside of the "LAN url" part of the npm run dev log.

Mapbox

You need to sign up for Mapbox to run the project locally.

  1. Goto https://www.mapbox.com and sign up

  2. It will ask you for billing information, but it is pay as you go. You have 500 instances before you are charged.


Prisma

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 build script now runs prisma 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 runs npm run db-reset-and-seed (see Seeding below).

Model changes

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 with db push will never reach production.

Seeding

  • prisma/seed.ts populates the database from prisma/schools.json using create (not upsert), 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 .env at local/Docker Postgres for local testing, or at the Vercel Postgres URLs if you specifically intend to reset production).


Environment File

Create an environment file to pass your default public token from Mapbox and connect Prisma to postgres

  1. Create the local server env file in the main directory (with the README.md file):

    cp .env.example .env
  2. Add your default public token to your .env

    NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_default_public_token
  3. 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 .env file. 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

Further Notes to help you out

Visit our Notion for Engineers

Gotchas

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).

About

Support SF Schools web site (dev deployment at: https://support-sfusd.vercel.app, Kanban board at: https://github.com/orgs/sfbrigade/projects/7?pane=info

Resources

Stars

13 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages