Database for nonprofit organizations to visualize relationships between NPOs
Before starting development, make sure you have these tools installed:
- Node.js 20.19+, 22.12+, or 24.0+ (required by Prisma 7.x; avoid Node 23)
- Npm - this is our package manager
- Postman - helpful for testing API routes
- Supabase CLI - database (postgres)
Add the .env.frontend and .env.backend from the project Google Drive to their respective directories (frontend/ and backend/). Copy to .env in each directory when running the app, or rename. Use backend/.env.backend.example and frontend/.env.frontend.example as templates.
- Use Node 20.19+, 22.12+, or 24.0+ (e.g.
nvm usein project root — there’s an.nvmrc). - Install dependencies:
cd backend && npm installthencd ../frontend && npm install. - Add
.envinbackend/andfrontend/from Google Drive (see Environment). - Generate Prisma client:
cd backend && npx prisma generate - Sync database (optional):
cd backend && npx prisma migrate dev(requiresDIRECT_URLin.env). - Seed dummy organizations (optional):
cd backend && npx prisma db seed— populates theorganizationstable with dummy data for testing (e.g. GET/organizations). Safe to run multiple times; skips if data already exists. - Start backend:
cd backend && npm run start
Start frontend:cd frontend && npm run dev
cd backend- Run
npm installto install all dependencies npm run startto start the backend
cd frontend- Run
npm installto install all dependencies npm run devto start development server
We're using Postgres (through supabase) for our project instead of MongoDB
- Pull latest code with
git pull - Sync your database with
npx prisma migrate dev - Update your client with
npx prisma generate
- To update the database schema, modify
prisma/schema.prisma - Run a migration in development:
npx prisma migrate dev --name <describe_your_change> - Commit the generated SQL migration file to Git
Note when running npx prisma migrate: If you get a message saying that the database needs to be reset and that your changes will be lost, it usually means you made some changes but your local database is out of sync. The safest option is usually to say yes so that you're in sync with everyone, unless the changes you made were important. Ideally this should not happen.
To populate the organizations table with dummy data for local testing (e.g. GET /organizations), run npx prisma db seed from the backend/ directory. The seed is configured in prisma.config.ts and is idempotent (skips if data already exists).
Run npx prisma studio for a GUI to view the database
You need DATABASE_URL and DIRECT_URL in your backend env. Follow these steps:
-
Sign in to Supabase
Go to supabase.com and sign in. Use the project’s Supabase account (or create a project if you’re setting up a new one). -
Open your project
Select the project for this app (or create one). -
Go to Project Settings → Database
In the left sidebar: Project Settings (gear) → Database. -
Find the connection strings
In the Dashboard, go to Connect → Connection string (or Project Settings → Database). You’ll see:- Transaction (port 6543), host
aws-0-[region].pooler.supabase.com→ use asDATABASE_URL.
Add?pgbouncer=trueif you use it for the app (serverless). - Session (port 5432), host
aws-0-[region].pooler.supabase.com→ use asDIRECT_URLfor Prisma migrations. - Direct (port 5432), host
db.[project-ref].supabase.co→ also 5432, but IPv6-only; many networks can’t reach it.
Use the Session pooler string (pooler host + 5432) for
DIRECT_URL, not the Direct string, unless you know your network has IPv6. Replace[YOUR-PASSWORD]with your database password (reset under Database → Database password if needed). - Transaction (port 6543), host
-
Ports vs hosts
- 6543 = Transaction pooler →
DATABASE_URL - 5432 = use Session pooler (
...pooler.supabase.com:5432) forDIRECT_URLto avoid “Can’t reach” (IPv6) issues.
Directdb....supabase.co:5432is correct in theory but often unreachable from Mac/home networks.
- 6543 = Transaction pooler →
-
Add to
backend/.env
Copy.env.backend.exampleto.env(or.env.backendthen copy to.env). Set:APP_PORT=3000 FRONTEND_ORIGIN=http://localhost:3000 DATABASE_URL=<transaction-pooler-6543> DIRECT_URL=<session-pooler-5432>Never commit
.envor.env.backend; they are gitignored. -
Verify
Runcd backend && npx prisma migrate dev(and optionallynpx prisma studio) to confirm Prisma can connect usingDIRECT_URL.
Prisma uses DIRECT_URL for migrations. The Direct connection (db.[project-ref].supabase.co:5432) is IPv6-only; many networks (including typical Mac/home) can’t reach it, so you get P1001 even with the right port.
Fix: Use the Session pooler for DIRECT_URL instead of Direct:
- Host:
aws-0-[region].pooler.supabase.com(same as Transaction, different port) - Port: 5432
- Example:
postgresql://postgres.[project-ref]:[PASSWORD]@aws-0-[region].pooler.supabase.com:5432/postgres
Keep Transaction (port 6543, same pooler host) for DATABASE_URL. Ports 5432 vs 6543 are correct; the important change is using the pooler host for DIRECT_URL, not db....supabase.co. Optionally add ?connect_timeout=30 to the URL if you hit timeouts.