Skip to content

feat: decompose index.js routes (#744), daily streaks (#947), range-proof stub (#940), view-key stub (#943) - #1085

Merged
joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
CelestinaBeing:feat/issues-744-940-943-947
Jul 29, 2026
Merged

feat: decompose index.js routes (#744), daily streaks (#947), range-proof stub (#940), view-key stub (#943)#1085
joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
CelestinaBeing:feat/issues-744-940-943-947

Conversation

@CelestinaBeing

Copy link
Copy Markdown
Contributor

Summary

  • Backend: Decompose monolithic index.js (~1450 lines) into route/service/repository layers #744 — Begin decomposing the monolithic backend/src/index.js. Extracted two self-contained modules:

    • backend/src/routes/health.jscreateHealthRoutes() factory encapsulating GET /health, /ready, /health/rpc, /health/indexer, and GET /metrics. All dependencies (rpcPool, metrics, eventIndexer, jobRunner, etc.) are injected; index.js becomes pure wiring for these endpoints.
    • backend/src/routes/adminKeys.jscreateAdminKeyRoutes() factory with POST/GET/DELETE /admin/api-keys and PUT /admin/api-keys/:id/rotate|rate-tier. Handles validation, audit logging, and error responses; index.js passes apiKeyRepository + middleware.
    • Unit tests in routes/health.test.js (9 cases: healthy/degraded states, cache hit, shutdown detection, indexer null, metrics content/format).
  • Daily streaks and login rewards #947 — Daily streak tracking and login rewards:

    • backend/src/services/streakService.jscreateStreakService() tracks consecutive UTC-day activity per identity, applies escalating point bonuses (10/15/25/50 pts at day 1/3/7/14 thresholds), enforces one-credit-per-day anti-abuse, and accumulates lifetime total points. Streak resets on any missed calendar day.
    • backend/src/routes/streaks.jsPOST /:identity/activity (record login/activity), GET /:identity (read current streak), DELETE /:identity (admin reset). Returns alreadyCredited: true when called multiple times on the same day.
    • Unit tests in services/streakService.test.js — 16 cases covering all thresholds, day boundaries, same-day deduplication, cross-day accumulation, reset, and multi-identity isolation.
  • Range-proof library for confidential reward amounts #940docs/RANGE_PROOFS.md: design stub defining the Bulletproofs-based approach, verify_range_proof() API surface, threat model (forgery, replay, overflow), and acceptance criteria for the on-chain implementation.

  • Selective disclosure / view keys for compliance #943docs/SELECTIVE_DISCLOSURE.md: design stub defining per-record HKDF-derived view keys, scoped disclosure package format (record_id, expires_at, authorized_to, user signature), threat model (scope creep, forged packages, expiry bypass), and acceptance criteria.

Test plan

  • cd backend && npx vitest src/routes/health.test.js — 9 health route tests pass
  • cd backend && npx vitest src/services/streakService.test.js — 16 streak service tests pass

Closes #744, Closes #940, Closes #943, Closes #947

…b range proofs and view keys

- FinesseStudioLab#744: Extract health/observability routes (GET /health, /ready, /health/rpc,
  /health/indexer, GET /metrics) into backend/src/routes/health.js as a
  createHealthRoutes() factory accepting rpcPool, metrics, eventIndexer, etc.
  Extract admin API-key management (create/list/revoke/rotate/rate-tier) into
  backend/src/routes/adminKeys.js as createAdminKeyRoutes(). Both modules are
  drop-in mounts for index.js wiring. Unit tests: routes/health.test.js (9 cases
  covering healthy/degraded/shutdown/metrics content).

- FinesseStudioLab#947: Add backend/src/services/streakService.js — createStreakService() tracks
  consecutive UTC-day activity per identity, applies escalating point bonuses
  (10/15/25/50 pts at day 1/3/7/14 thresholds), enforces one-credit-per-day
  anti-abuse, and accumulates total points. Add backend/src/routes/streaks.js
  with POST/:identity/activity, GET/:identity, DELETE/:identity (admin reset).
  Unit tests: services/streakService.test.js (16 cases across all code paths).

- FinesseStudioLab#940: Add docs/RANGE_PROOFS.md — design stub with Bulletproofs approach,
  verify_range_proof() API surface, threat model table, and acceptance criteria.

- FinesseStudioLab#943: Add docs/SELECTIVE_DISCLOSURE.md — design stub with HKDF-derived per-record
  view keys, scoped disclosure package format, threat model, and acceptance criteria.

Closes FinesseStudioLab#744, Closes FinesseStudioLab#940, Closes FinesseStudioLab#943, Closes FinesseStudioLab#947
@joelpeace48-cell
joelpeace48-cell merged commit f6419be into FinesseStudioLab:main Jul 29, 2026
5 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants