GRV-BackEnd/README.md
kirukib 97730f2f2d Remove hard-coded domains; default to localhost and env config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:02:38 +03:00

3.2 KiB
Raw Permalink Blame History

GRV Backend

One API for the GRV Summit: startup applications, website inquiries, ticket sales and discounts, merch, and the event game (booth / startup / mystery-investee QR scans, points, raffles). Used by the site (GRVSummit), the admin portal (GRV-Admin) and the attendee app (GRV-Application).

Contract: API.md. Swagger UI runs at /docs.

Stack: NestJS 12, Prisma 7 + Postgres, zod, jose (JWT), Resend (email over HTTP), qrcode.

Run locally

pnpm install
cp .env.example .env          # set JWT_SECRET and ADMIN_EMAILS to your email
docker compose up -d          # Postgres on :5432
#   no Docker? `pnpm db:dev` (PGlite on :5433), then in .env:
#   DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5433/postgres and DATABASE_POOL_MAX=1
pnpm db:migrate
pnpm db:seed                  # sectors + ticket tiers; `pnpm db:seed --demo` adds sample checkpoints, merch and a raffle
pnpm start:dev                # http://localhost:4000
pnpm test                     # discounts, orders, scans, raffle (in-memory Postgres, no setup needed)

With RESEND_API_KEY empty, every email, including sign-in codes, is printed to the console instead of sent.

Rules worth knowing

  • Money: integer minor units (cents). Times: UTC.
  • Logins: email OTP for everyone. Role comes from ADMIN_EMAILS / STAFF_EMAILS on each login; everyone else is an ATTENDEE. Removing an email from the list demotes them at their next login.
  • Points are never stored. They are SUM(scans.points_awarded), and each user/checkpoint pair is unique, so a repeat scan can't earn twice. A mystery investee awards points × 2.
  • Discount uses are counted from PAID/FULFILLED orders, so abandoned orders don't burn a code.
  • Payments: ticket orders are created PENDING with manual/bank instructions (PAYMENT_INSTRUCTIONS). Staff confirm with Mark paid in the admin, which issues one QR ticket per seat and emails them. A gateway webhook should call CommerceService.markPaid.
  • QR codes: they encode SITE_URL/q/<token> for checkpoints and SITE_URL/t/<token> for tickets, so a normal phone camera opens the site, and the app scans the same URL.
  • Applications: the field definitions and validation in src/shared/ are copied from the site (GRVSummit/content/apply.ts, lib/apply-validation.ts). Keep both copies in sync when the form changes. Step answers outside step 1 and documents are stored as JSON, so new questions need no migration.

Moving the site's existing applications

cd ../GRVSummit && npx wrangler d1 export grv-summit --remote --no-schema --output d1.sql
cd ../GRV-Backend && pnpm db:import-d1 ../GRVSummit/d1.sql   # safe to re-run

Deploy (VPS)

pnpm install --frozen-lockfile && pnpm build && pnpm db:migrate && pnpm db:seed
pm2 start dist/src/main.js --name grv-backend   # NODE_ENV=production, env from .env

Put it behind HTTPS. Set CORS_ORIGINS to the site and admin origins and ADMIN_URL to the admin's URL (used in staff emails).

Not built yet

  • Payment gateway (Chapa/Telebirr/Stripe): add it when the provider is chosen.
  • Push notifications and SMS.
  • Document uploads: applications still take Drive/Dropbox links.