2026-08-12 13:39:36 +02:00
# Nxtgauge — Live Server Runbook
Steps that **require a running database and/or server** to complete.
Run these on the server where Postgres + Redis are already up.
---
2026-08-13 21:32:48 +02:00
## ✅ Completed — Database migrations (applied to prod, 2026-08-13)
All four DB tasks below are done and confirmed against the live production DB.
| Migration | What | Status |
|---|---|---|
| `20260627030000_wallet_full.up.sql` | Re-enabled (was mistakenly `.skip` -ed); `tracecoin_holds` + `tracecoin_buckets` now live | ✅ Applied |
| `20260703210000_ai_credits_wallet.up.sql` | Rewrote as idempotent (`IF NOT EXISTS` ); `ai_reservation_holds` + `ai_credit_ledger` now live | ✅ Applied |
| `20260813000000_fix_ai_credits_timestamp_types.up.sql` | 9 TIMESTAMP → TIMESTAMPTZ columns across AI tables; data intact and UTC-correct | ✅ Applied |
| `nxtgauge_test` DB | Dedicated test database created, schema mirrored from prod, wired into Forgejo CI via `TEST_DATABASE_URL` secret | ✅ Done |
`/wallet/me/holds` returns real data. All 8 backend integration tests pass in CI.
---
## 1. Deploy backend changes
2026-08-12 13:39:36 +02:00
```bash
cd nxtgauge-backend-rust
cargo build --release
```
Then restart the affected services:
```bash
2026-08-13 21:32:48 +02:00
# Restart all profession services (wallet/me/holds route)
2026-08-12 13:39:36 +02:00
systemctl restart nxtgauge-photographers nxtgauge-developers nxtgauge-tutors \
nxtgauge-makeup_artists nxtgauge-fitness_trainers nxtgauge-catering_services \
nxtgauge-video_editors nxtgauge-graphic_designers nxtgauge-social_media_managers
2026-08-13 21:32:48 +02:00
# Restart job_seekers (printpdf upgrade)
2026-08-12 13:39:36 +02:00
systemctl restart nxtgauge-job_seekers
```
---
2026-08-13 21:32:48 +02:00
## 2. Run security checks (no DB needed)
2026-08-12 13:39:36 +02:00
```bash
cd nxtgauge-backend-rust
# CVE scan
cargo audit
# Policy check (licenses, bans, CVE with acknowledged ignores)
cargo deny check advisories bans
```
Both should exit 0. If a new CVE appears, add it to `deny.toml` under `[advisories] ignore` with a comment explaining the risk.
---
2026-08-13 21:32:48 +02:00
## 3. Set up schemathesis API fuzzing
2026-08-12 13:39:36 +02:00
Schemathesis fuzzes your real API from an OpenAPI spec. It needs:
- The server running (with DB connected)
- An OpenAPI spec (`openapi.json` )
2026-08-13 21:32:48 +02:00
### 3a. Install schemathesis
2026-08-12 13:39:36 +02:00
```bash
pip install schemathesis
2026-08-13 21:32:48 +02:00
# or with uv:
2026-08-12 13:39:36 +02:00
uv tool install schemathesis
```
2026-08-13 21:32:48 +02:00
### 3b. Generate the OpenAPI spec
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
> **Note:** The axum services don't yet have utoipa annotations. Until then, use
> the manually maintained spec in `docs/openapi.wallet-holds.json` or skip to 3c.
2026-08-12 13:39:36 +02:00
>
> To add utoipa: add `utoipa` and `utoipa-axum` to each service's `Cargo.toml`,
> annotate handlers with `#[utoipa::path]`, and mount a `/openapi.json` endpoint.
2026-08-13 21:32:48 +02:00
### 3c. Run the fuzzer
2026-08-12 13:39:36 +02:00
```bash
schemathesis run openapi.json \
--base-url http://localhost:3000 \
--auth "Bearer < admin_or_test_jwt > " \
--checks all \
--hypothesis-settings max_examples=200
2026-08-13 21:32:48 +02:00
# Quick smoke-check:
2026-08-12 13:39:36 +02:00
schemathesis run openapi.json \
--base-url http://localhost:3000 \
--auth "Bearer < jwt > " \
--checks not_a_server_error
```
---
2026-08-13 21:32:48 +02:00
## 4. Run Playwright end-to-end tests
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
Playwright tests live in `nxtgauge-frontend-solid/tests/` . Need full stack running.
2026-08-12 13:39:36 +02:00
```bash
cd nxtgauge-frontend-solid
2026-08-13 21:32:48 +02:00
npx playwright install --with-deps chromium # one-time
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
export PLAYWRIGHT_BASE_URL=https://nxtgauge.com
2026-08-12 13:39:36 +02:00
npx playwright test
2026-08-13 21:32:48 +02:00
npx playwright test --grep @smoke # smoke only
npx playwright show-report # view results
2026-08-12 13:39:36 +02:00
```
2026-08-13 21:32:48 +02:00
> **Note:** A few e2e test files still have `localhost:3001` URLs — pending cleanup,
> update to the staging/prod URL before running against live.
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
---
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
## 5. Backend integration tests (CI — already wired)
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
The `nxtgauge_test` DB and Forgejo CI secret are already set up.
To run locally:
2026-08-12 13:39:36 +02:00
```bash
export TEST_DATABASE_URL=postgres://user:pass@localhost:5432/nxtgauge_test
cd nxtgauge-backend-rust
cargo test --test ai_credits -- --test-threads=1
```
---
2026-08-13 21:32:48 +02:00
## 6. Frontend linter
2026-08-12 13:39:36 +02:00
```bash
cd nxtgauge-frontend-solid
npm run lint
```
---
2026-08-13 21:32:48 +02:00
## 7. TypeScript check
2026-08-12 13:39:36 +02:00
```bash
cd nxtgauge-frontend-solid
npx tsc --noEmit --skipLibCheck
```
2026-08-13 21:32:48 +02:00
Should exit 0.
2026-08-12 13:39:36 +02:00
---
2026-08-13 21:32:48 +02:00
## Summary
2026-08-12 13:39:36 +02:00
2026-08-13 21:32:48 +02:00
| Task | Needs DB | Needs server | Status |
2026-08-12 13:39:36 +02:00
|---|---|---|---|
2026-08-13 21:32:48 +02:00
| DB migrations | ✅ | ✅ | ✅ Done (prod) |
| Build + deploy backend | — | — | Pending next release |
| `cargo audit` / `cargo deny` | — | — | Run anytime |
| Schemathesis fuzzing | ✅ | ✅ | Pending OpenAPI spec |
| Playwright e2e | ✅ | ✅ | Pending URL cleanup |
| Backend integration tests | ✅ | — | ✅ Green in CI |
| `npm run lint` | — | — | ✅ Passing |
| `tsc --noEmit` | — | — | Run anytime |