Skip to content
hgbcworkforcePublic

About

This is a simple form built with html, css and js to collect HGBC first timers information for proper follow up.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

HGBC First-Timer Portal

The portal helps HGBC staff manage first-time guest submissions and follow-up. It consists of a React dashboard and public intake form, an Express API, and a Supabase PostgreSQL database.

Architecture

  • src/: React/Vite frontend; deployed as static files to cPanel by GitHub Actions.
  • backend/: Node.js 22+ Express API; connects to Supabase with the server-only service-role key and issues its own versioned JWTs.
  • shared/: role definitions used by both frontend and backend.
  • supabase/migrations/: ordered, versioned database history and the source of truth for schema changes.
  • backend/schema.sql: reference snapshot of the final schema; use the migration workflow below to initialize databases.

The API is deployed to Render. The frontend calls it using VITE_API_BASE_URL; when omitted, it uses /api.

Requirements

  • Node.js 22 or newer and npm.
  • Docker, for the Supabase local database and migration checks.
  • Supabase project credentials for running the API against a hosted database.

Local setup

Install dependencies from the repository root:

npm ci
npm ci --prefix backend

Start the local Supabase stack and apply the migration chain to its development database:

npm run db:start
npm run db:reset
npm run db:status
npm run db:test

db:reset recreates the local database and applies every migration. It deletes local database contents; do not use it to reset a hosted project. db:stop stops the local stack.

To run the application against the local Supabase stack, copy backend/.env.example to backend/.env, use the local URL and service-role key shown by npx supabase status, and set a unique JWT_SECRET of at least 32 bytes. Create a root .env.local for Vite:

VITE_API_BASE_URL=http://localhost:5000/api

Then start the API and frontend in separate terminals:

npm run dev --prefix backend
npm run dev

Vite runs on port 3000 and the API defaults to port 5000. Keep .env, .env.local, database passwords, JWT secrets, and service-role keys out of Git. The backend rejects anon keys and requires SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, and a valid JWT_SECRET. CORS_ORIGIN is not currently consumed by the server.

Database migrations

Create new migrations with npx supabase migration new descriptive_name. Do not edit a migration after it has been applied; add a new forward migration instead. Run npm run db:verify to start a minimal local PostgreSQL stack, reset it from migrations, and run database schema tests. CI runs this check on pull requests and pushes to main.

For production, link the CLI to the intended Supabase project, inspect its migration history, preview pending migrations, and apply only after review:

npx supabase login
npx supabase link --project-ref <project-ref>
npx supabase migration list --remote
npx supabase db push --dry-run --remote
npx supabase db push --remote

Existing projects may have changes applied manually and no migration ledger. Follow the backend database migration guide to compare the live schema before marking verified migrations as applied. Never blindly replay the initial schema or use migration repair to conceal drift. The project does not retain database backups; schema rollback is not data recovery. Migrations should be additive where possible, and recovery from an incompatible change uses a reviewed forward fix.

Tests and quality checks

npm run lint
npm test
npm run build
npm run db:verify

npm test runs backend authorization/API tests and frontend component tests. npm run db:verify requires Docker and validates that a fresh database can be built from the committed migrations.

Deployment

  • Frontend: GitHub Actions builds on pushes and pull requests to main; successful pushes to main deploy dist/ to cPanel. Configure VITE_API_BASE_URL as a GitHub Actions repository variable for the deployed API URL.
  • Backend: Deploy the repository to Render with the repository root as the working directory so the shared role module is available. Use npm ci --prefix backend as the build command and npm start --prefix backend as the start command. Configure the required Supabase URL, service-role key, and JWT secret in Render's secret environment, and use /api/health as the health check.
  • Database: Apply reviewed migrations before deploying code that depends on them. See the backend deployment and database guide.

Privacy and data retention

The portal uses intake details for guest follow-up and outreach analysis. Prayer requests are optional. Administrators and pastors can access all submissions; team members can access only assigned submissions. Submissions and related interaction notes are deleted after 13 months. See the privacy and retention details.

About

This is a simple form built with html, css and js to collect HGBC first timers information for proper follow up.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages