Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Forward Deployed

A Next.js App Router scaffold with TypeScript, Tailwind CSS v4, ESLint, and the shadcn/ui base primitives already installed.

Stack

Piece Choice
Framework Next.js 16 (App Router, src/ directory)
Language TypeScript
Styling Tailwind CSS v4
Components shadcn/ui (base-nova style, neutral base color)
Icons lucide-react
Linting ESLint (eslint-config-next)
Testing Vitest (jsdom environment, jest-dom matchers)
Import alias @/* → src/*

Getting started

Use Node 24, the version pinned in .nvmrc and used by CI (nvm use picks it up).

npm install
npm run dev

The dev server defaults to http://localhost:3000. Pass -p <port> to pick a different one, e.g. npm run dev -- -p 43127.

Scripts

Command Description
npm run dev Start the dev server
npm run build Production build
npm run start Serve the production build
npm run lint Run ESLint
npm run typecheck Generate Next.js route types, then run tsc --noEmit
npm test Run the Vitest suite once
npm run test:watch Run Vitest in watch mode
npm run db:start Start the local Supabase stack
npm run db:stop Stop the local Supabase stack
npm run db:reset Rebuild the local database from the migrations
npm run db:test Run the database tests in supabase/tests/
npm run db:status Show local URLs and keys
npm run db:seed Fill the database in .env.local with demo data
npm run db:types Regenerate src/lib/supabase/database.types.ts from the local database
npm run db:bootstrap-admin Create the organization or make someone its admin

Contributing

Rule Detail
Branch protection main is protected. No direct pushes; all changes go through a pull request.
CI Checks must pass before a PR can merge.
Approvals Not required. Once checks are green, authors can merge their own PR.
Code owners .github/CODEOWNERS auto-requests reviewers for visibility only. Approval is not required.
Branch naming Generally <type>/<short-description>, e.g. feature/add-search-bar. Treat this as a guideline, not a strict rule.

Project layout

The codebase is organized by feature, not by technical layer. Each domain owns its own api, components, hooks, schemas, and types directories.

src/
  app/                  Next.js App Router routes (thin router glue only)
  features/             Domain-isolated feature modules
    auth/
    volunteers/
    events/
    crm/
    settings/
    reports/
    dashboard/
      api/              Server calls for this domain
      components/       UI owned by this domain
      hooks/            Stateful logic for this domain
      schemas/          Validation schemas
      types/            Domain types
      index.ts          Public barrel — the only supported import path
    team/
      api/              Server calls for this domain
      types/            Domain types
      index.ts          Public barrel — the only supported import path
  components/
    ui/                 Base atomic shadcn primitives
    common/             Un-opinionated composed patterns
      data-table/
      forms/
      navigation/
      metrics/
      states/           Shared LoadingState / EmptyState / ErrorState
  lib/
    adapters/           Repositories: contracts, Supabase and mock versions, and the switch
    supabase/           Generated database types
    utils.ts            Re-exports the `cn` class-name helper
components.json         shadcn/ui CLI configuration

Import rules

Import a feature only through its barrel, never by reaching into its internals:

import { VolunteerTable } from "@/features/volunteers"   // yes
import { VolunteerTable } from "@/features/volunteers/components/volunteer-table" // no

Anything not exported from a feature's index.ts is private to that feature. Code shared across two or more features belongs in src/components/common or src/lib instead.

Environment variables

Copy .env.example to .env.local and fill in the values. .env.local is gitignored; never commit real keys. Ask the Supabase owner for the values through the team's secure channel, not Slack plaintext.

Variable Where it runs Notes
NEXT_PUBLIC_SUPABASE_URL Browser and server Project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY Browser and server Holds the publishable key (sb_publishable_...)
SUPABASE_SECRET_KEY Server-only scripts Secret key (sb_secret_...); bypasses RLS
SEED_USER_PASSWORD npm run db:seed Password for every seed login; dev data only
NEXT_PUBLIC_DATA_SOURCE Server supabase (default) or mock for in-memory demo data

Local development

Local development runs against a local Supabase stack in Docker, not the shared hosted project. Install Docker Desktop and make sure it's running before any db:* command; on Windows, enable the WSL 2 backend (Settings → General → "Use the WSL 2 based engine"), since the Supabase CLI needs it. The CLI itself comes from the supabase devDependency and the lockfile, so local and CI always run the same version.

Daily workflow:

npm run db:start   # start the local stack (first run pulls Docker images)
npm run db:reset   # rebuild the database from supabase/migrations
npm run db:seed    # add demo data (see "Database" below)
npm run dev
npm run db:stop    # when you're done

db:reset wipes and rebuilds the local database from the migrations, so any local test data is lost — re-run db:seed afterwards if you need it back.

Set the variables listed in "Environment variables" above for local use, using the URL and keys printed by npm run db:status rather than the hosted project's.

Studio and Mailpit also run locally; get their URLs from npm run db:status. Local auth emails render from the templates in supabase/templates/ — see "Auth emails" below.

Accounts & ownership

Service Owners Other members
Supabase (org "UW Blueprint", Blueprint-controlled account) Allan Yang, Rishab (TL) Samay, Ethan, Angus (Developer)
GitHub (uwblueprint/forward-deployed) TBD TBD
Vercel Samay None (Hobby plan, single-user)

Secrets (Supabase keys, database password) live in: TBD.

To transfer ownership of an account:

  1. An existing owner invites the new owner with the Owner role.
  2. The new owner accepts the invite and confirms they can open the project settings.
  3. Only then may the old owner leave or be downgraded. Every account must keep at least two owners.
  4. Update the table above in the same pull request.

Database

All schema changes go in migration files under supabase/migrations/. Never change tables from the Supabase dashboard. New tables and functions start with no API access, so each migration grants what it needs. Who can read or change what is described in docs/role-model.md.

Merged migrations deploy to the hosted database automatically. Setup, and what to do when a deploy fails, are in docs/database-migrations.md.

See "Local development" above for starting and stopping the local stack.

npm run db:test                # run the database tests in supabase/tests/
supabase/tests/concurrency.sh  # race two sessions for the last spot and an event delete
npm run db:types               # regenerate src/lib/supabase/database.types.ts after a reset

Seed data:

npm run db:seed

The seed targets the project in .env.local and needs SUPABASE_SECRET_KEY. It creates admin logins with a shared password, so never run it against a project with real users. The project runs in single-organization mode, so the seed makes one organization with 12 users (an admin, a manager, and 10 volunteers) and 10 volunteers, applications, events, registrations, and invitations. One event is full, one has registration closed, and the invitations are open, expired, or revoked. The organization gets example event categories and skill options, and a placeholder rejection message until the real wording is approved. The audit log fills in from the changes. All logins use SEED_USER_PASSWORD. Re-running replaces only the seed's own rows, including those from older seeds; the audit log keeps the old history. It stops if the project has another organization. Needs Node 22.18 or newer.

A new project with no seed data has no organization or admins. Create the organization before anyone signs up, then promote the first admin after they sign up (see "Setting up a new project" in docs/role-model.md):

npm run db:bootstrap-admin -- --org "Org name"
npm run db:bootstrap-admin -- --email person@example.com

Authorization

Pages and layouts call requireRole from @/features/auth; route handlers call requireRoleForRoute instead, since redirect/notFound don't fit an API response. It returns a typed { ok: true, user } / { ok: false, response } result instead of throwing.

Every server component that reads protected data must call requireRole itself before reading that data, even inside a protected layout. Layouts render in parallel with their pages, so a layout-level check can't gate what a page returns.

src/proxy.ts is a convenience redirect for signed-out visitors, not the security gate, and is not a substitute for requireRole/requireRoleForRoute at each server boundary.

Roles are read per request from the user's row in public.memberships (see docs/role-model.md), deduplicated per request with React's cache(). A user who hasn't joined an organization yet counts as a volunteer; a failed lookup or unknown role is denied. Never read roles from app_metadata, user_metadata, or JWT claims.

Data access

Server code reads and writes volunteers and events through volunteerRepo and eventRepo from @/lib/adapters. With NEXT_PUBLIC_DATA_SOURCE=mock they serve in-memory demo data (two organizations, 12 volunteers, 6 events) after a simulated 200 ms delay, so screens work without a database. Otherwise they go through Supabase with the signed-in user's permissions. Changing the variable switches every caller; no component code changes.

@/lib/adapters is server-only, since the Supabase repositories use the request's cookies. Client components call a Server Action or route handler that uses it.

import { eventRepo } from "@/lib/adapters"

const events = await eventRepo.getAll()

Auth emails

In the Supabase dashboard, under Authentication:

Setting Value
Site URL https://forward-deployed.vercel.app
Redirect URLs http://localhost:3000/auth/callback**, https://forward-deployed.vercel.app/auth/callback**, https://forward-deployed-*-forward-deployed.vercel.app/auth/callback**
Confirm signup template link {{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email&next=/dashboard
Reset password template Show the code with {{ .Token }} instead of a link

Redirect URLs are limited to /auth/callback because that's the only path the app passes as a redirect. /auth/confirm is reached through the email template's {{ .SiteURL }}, not redirect_to, so it isn't affected. If a new flow redirects elsewhere, add its path here.

The preview entry matches Vercel's per-deployment preview domains. src/lib/allowed-origin.ts checks the same origins in code before any redirect URL is built, since Origin/Host headers can be spoofed. If the Vercel project or team name changes, update both the dashboard Redirect URLs and allowed-origin.ts.

Until the confirm signup template is changed from its default, those emails still work, but only through /auth/callback, and only in the browser the user signed up in.

Local Supabase uses the templates in supabase/templates/, configured in supabase/config.toml. Template changes need npx supabase stop then npx supabase start to take effect. Local emails don't actually get sent — they appear at http://127.0.0.1:54324. Local signup confirmation is off (enable_confirmations = false), so only the reset flow can be tested locally; signup confirmation is tested against a hosted project.

Site URL / Redirect URLs by environment

Environment Site URL Redirect URLs Configured in
Local http://127.0.0.1:3000 http://127.0.0.1:3000/auth/callback**, http://localhost:3000/auth/callback** supabase/config.toml ([auth]), this repo
Production https://forward-deployed.vercel.app https://forward-deployed.vercel.app/auth/callback** Supabase dashboard, owner-applied
Preview (any PR) n/a — previews share the production project's Site URL https://forward-deployed-*-forward-deployed.vercel.app/auth/callback** Supabase dashboard, owner-applied

Local and hosted are separate Supabase projects with independently configured auth settings — the local one only needs to know about localhost, since it's never reachable from a preview or production deployment.

Google sign-in

In the Supabase dashboard, under Authentication > Providers:

Setting Value
Google provider Enabled
Client ID From the Google Cloud OAuth client; entered in the dashboard, never in code
Client Secret From the Google Cloud OAuth client; entered in the dashboard, never in code

In Google Cloud Console, add https://<project-ref>.supabase.co/auth/v1/callback as an authorized redirect URI on the OAuth client.

Not configured for local Supabase; test against a hosted project.

Installed UI primitives

accordion, alert, aspect-ratio, badge, button, card, checkbox, collapsible, command, dialog, dropdown-menu, hover-card, input, input-group, label, navigation-menu, popover, scroll-area, select, skeleton, table, tabs, textarea, tooltip. All are exported from src/components/ui/index.ts.

tooltip needs a TooltipProvider ancestor before use.

Not installed on purpose: sidebar. The admin and volunteer shells are hand-rolled on one AppShell in src/components/common/navigation/ and already match the Figma Sidebar page (see FOR-102, FOR-115); don't add shadcn's sidebar alongside it.

Loading, empty, and error UI comes from @/components/common/states (LoadingState, EmptyState, ErrorState). Route groups use them in loading.tsx, error.tsx, and not-found.tsx; error boundaries log the thrown error and never render its message.

The original ten are rendered together at /showcase (src/app/showcase/page.tsx) when running the dev server.

Add more with:

npx shadcn@latest add <component>

shadcn/ui components are copied into src/components/ui, so they are normal source files — edit them directly instead of overriding them from the outside.

Note that this shadcn style is built on Base UI, not Radix. Composition uses the render prop rather than asChild:

<DialogTrigger render={<Button>Open</Button>} />

Proposed design tokens (colors, radius, fonts) and Base UI conventions are in DESIGN_TOKENS.md (draft, pending design sign-off).

The shadcn package is a dev dependency: the CLI only runs at authoring time, and src/app/globals.css imports shadcn/tailwind.css at build time. Do not remove it outright — the build fails, and dropping the import silently breaks the data-horizontal/data-vertical variants the Tabs primitive relies on.

Dependency advisories

Check what ships to users with:

npm audit --omit=dev

Never run npm audit fix --force. It was found to downgrade shadcn to 1.0.0. Plain npm audit fix (no --force) is safe.

Accepted dev-only advisories

Advisories that come only through dev tooling — the shadcn CLI and the eslint-config-next toolchain — never reach the production bundle. They are accepted: patch them with npm audit fix when a fix lands, but they do not block a merge.

Currently open (as of 2026-11-03; npm audit --omit=dev reports none). No non-breaking fix exists yet; npm audit fix --force would downgrade eslint to 4.0.0 and shadcn to 1.0.0.

Package Severity Reached through Advisories
minimatch moderate eslint, eslint-config-next plugins, typescript-eslint, shadcn → ts-morph GHSA-g3hv-75wg-m249
deepmerge low shadcn → @shadcn/registry GHSA-gcqx-w48m-w2h4

Historical record: the table below lists the dev-only advisories found on 2026-10-25. All of them were cleared that day by npm audit fix.

Package Severity Reached through Advisories
undici high shadcn CLI GHSA-4qv8-2p9j-2685, GHSA-f72v-6w45-q472, GHSA-xjj6-f33q-929c
zod (v3 copies) high shadcn, @shadcn/registry GHSA-mrhx-c7xc-m3w5
body-parser high shadcn → @modelcontextprotocol/sdk → express GHSA-27r3-jxmh-p828
fast-uri moderate shadcn → @modelcontextprotocol/sdk → ajv GHSA-w74x-v6f9-j3xg, GHSA-xhq7-xmqj-769h, GHSA-wjr9-j795-jxcr, GHSA-333x-w4r6-6crp
ip-address moderate shadcn → socks / express-rate-limit GHSA-rxp7-6hxx-x8q5
@shadcn/registry high shadcn inherits the zod advisory
shadcn high direct (dev) inherits the zod advisory

Runtime advisories (anything npm audit --omit=dev reports) are never accepted here — fix them. For example, next and eslint-config-next were bumped off the vulnerable 16.4.0 baseline (to 16.4.3, then 16.4.5) for GHSA-2464-fhr4-w9xw, GHSA-p3m5-59mp-jv5r, and GHSA-673q-mjm6-r5xr, all fixed in 16.4.1. Keep the two versions in lockstep.

Deployment

Hosted on the Vercel project forward-deployed, owned by Samay Kapadia.

Pushes to main deploy to production. Every pull request gets a preview deployment, with the URL posted as a comment on the PR.

Deployments run through .github/workflows/vercel.yml using the Vercel CLI, authenticated with the GitHub Actions secrets VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID.

To update environment variables, change them in the Vercel project settings, then redeploy — either by re-running the latest main workflow run in the Actions tab, or by pushing a new commit. Changes only apply to new deployments.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages