|
| 1 | +# Local Development and Full Test |
| 2 | + |
| 3 | +This runbook gives you one reliable path to boot the stack and verify GraphQL flows end to end. |
| 4 | + |
| 5 | +## 1) Runtime and install |
| 6 | + |
| 7 | +```bash |
| 8 | +nvm use |
| 9 | +# or: asdf shell nodejs 20.19.6 |
| 10 | + |
| 11 | +yarn install |
| 12 | +``` |
| 13 | + |
| 14 | +Node version targets: |
| 15 | +- `.nvmrc`: `20.19.6` |
| 16 | +- `.node-version`: `20` |
| 17 | + |
| 18 | +## 2) Start dependencies |
| 19 | + |
| 20 | +Start PostgreSQL + Elasticsearch first: |
| 21 | + |
| 22 | +```bash |
| 23 | +docker compose up -d postgres elasticsearch |
| 24 | +``` |
| 25 | + |
| 26 | +Check health: |
| 27 | + |
| 28 | +```bash |
| 29 | +docker compose ps |
| 30 | +``` |
| 31 | + |
| 32 | +Both services should be `healthy` before launching the app. |
| 33 | + |
| 34 | +## 3) App environment variables |
| 35 | + |
| 36 | +Set these variables in your shell (or `.env`) before starting the app. |
| 37 | + |
| 38 | +```bash |
| 39 | +export NODE_ENV=development |
| 40 | +export PORT=5000 |
| 41 | +export DATABASE_URL='postgresql://advisors:advisors@localhost:55432/advisors?schema=public' |
| 42 | +export DISABLE_AUTOMATION=true |
| 43 | + |
| 44 | +export AUTH_SECRET='local-dev-secret' |
| 45 | +export AUTH_AUDIENCE='event-test-2025' |
| 46 | + |
| 47 | +export UPLOADER_BASE='http://localhost:3000' |
| 48 | +export UPLOADER_SECRET='local-dev-secret' |
| 49 | +export GOTENBERG_BASE='http://localhost:3001' |
| 50 | + |
| 51 | +export EMAIL_HOST='localhost' |
| 52 | +export EMAIL_PORT='1025' |
| 53 | +export EMAIL_USER='local' |
| 54 | +export EMAIL_PASS='local' |
| 55 | +export EMAIL_FROM='local@example.com' |
| 56 | + |
| 57 | +export TWILIO_ACCOUNT_SID='AC00000000000000000000000000000000' |
| 58 | +export TWILIO_AUTH_TOKEN='local-dev-secret' |
| 59 | +export TWILIO_PHONE='+15555555555' |
| 60 | +``` |
| 61 | + |
| 62 | +Notes: |
| 63 | +- `AUTH_SECRET` and `AUTH_AUDIENCE` must match what your local token/test scripts use. |
| 64 | +- `DATABASE_URL` should use `localhost:55432` when running the app outside Docker. |
| 65 | + |
| 66 | +## 4) Build and start app |
| 67 | + |
| 68 | +```bash |
| 69 | +yarn build |
| 70 | +yarn dev |
| 71 | +``` |
| 72 | + |
| 73 | +GraphQL endpoint: |
| 74 | +- `http://localhost:5000/graphql` |
| 75 | + |
| 76 | +## 5) Seed test data |
| 77 | + |
| 78 | +In another terminal: |
| 79 | + |
| 80 | +```bash |
| 81 | +yarn seed-dummy |
| 82 | +``` |
| 83 | + |
| 84 | +This creates deterministic local test records, including: |
| 85 | +- advisor id `advisor-alice-test` |
| 86 | +- advisor id `advisor-bob-test` |
| 87 | +- request id `request-test-2025` |
| 88 | + |
| 89 | +## 6) Run full local end-to-end test |
| 90 | + |
| 91 | +With the app running, execute: |
| 92 | + |
| 93 | +```bash |
| 94 | +yarn test-local |
| 95 | +``` |
| 96 | + |
| 97 | +This runs: |
| 98 | +1. `yarn seed-dummy` |
| 99 | +2. Public GraphQL query |
| 100 | +3. Admin-auth query (`submittedRequests`) |
| 101 | +4. Advisor-auth query (`getRequest`) |
| 102 | +5. Advisor mutation (`respondRequest`) |
| 103 | +6. Verification query (`getRequestAssignment`) |
| 104 | + |
| 105 | +If all pass, your local backend path is working end to end. |
| 106 | + |
| 107 | +## 7) Quick troubleshooting |
| 108 | + |
| 109 | +- `Prisma` connection errors: |
| 110 | + - Confirm Postgres is healthy: `docker compose ps` |
| 111 | + - Re-check `DATABASE_URL` host/port (`localhost:55432` outside Docker) |
| 112 | + |
| 113 | +- Auth errors (`Unauthorized`, audience/secret issues): |
| 114 | + - Re-check `AUTH_SECRET` |
| 115 | + - Re-check `AUTH_AUDIENCE` |
| 116 | + |
| 117 | +- GraphQL upload typing/build issues: |
| 118 | + - Re-run `yarn install` |
| 119 | + - Re-run `yarn build` |
| 120 | + |
| 121 | +- Seed/test query failures: |
| 122 | + - Ensure app is running on port `5000` |
| 123 | + - Re-run `yarn seed-dummy` |
0 commit comments