Skip to content

#377 [Frontend] [Feature] Integrate Soroban/Backend Search API for Global Certificate Search FIXED - #479

Merged
Tybravo merged 2 commits into
Tybravo:mainfrom
veloura-dev:#377--Frontend]--Feature]-Integrate-Soroban/Backend-Search-API-for-Global-Certificate-Search-FIX
Aug 2, 2026
Merged

#377 [Frontend] [Feature] Integrate Soroban/Backend Search API for Global Certificate Search FIXED#479
Tybravo merged 2 commits into
Tybravo:mainfrom
veloura-dev:#377--Frontend]--Feature]-Integrate-Soroban/Backend-Search-API-for-Global-Certificate-Search-FIX

Conversation

@veloura-dev

Copy link
Copy Markdown
Contributor

CLOSE #377

Findings & Fix Features
(Note: the sandbox dropped .git between sessions — all 13 fix files are intact and suites re-verified green post-restore, and the complete fix is packaged as
stellarproof-search-api-fix.patch
so the diff remains reproducible.)

A. FINDINGS — what was wrong on main
Finding 1 — The search page never talked to any API (the core issue).
frontend/app/search/services/searchService.ts shipped a mock: a hard-coded 7-item MOCK_RESULTS array plus a fake 600 ms setTimeout. Its own header comment admitted it: "Replace searchCertificates() with a live oracle / indexer call once the registry backend is wired up." So the UI could only ever render fake certificates.

Finding 2 — The backend couldn't serve a global search at all.
GET /api/v1/certificates required a per-user Mongo creatorId ObjectId (Zod-enforced) and had no search parameter — a global public certificate index was impossible to express against it.

Finding 3 — main did not compile. 🚨
next build on pristine main fails at the issue's own affected path:

text

./app/search/page.tsx:321:13
Type error: Type 'SearchResult[]' is not assignable to type 'Certificate[]'.
Type 'SearchResult' is missing: title, thumbnailUrl, issuerName, issueDate
The gridResults adapter was computed and then thrown away — raw results was passed to GridView (introduced by the grid-view PR #463).

Finding 4 — The in-scope test suite was 100% broken at baseline (7/7 failing).
app/search/tests/search.test.tsx targeted a superseded page design (commit bfe5ec4: search button, ID/hash field toggle) that no longer matches the current debounced live-search page.

Finding 5 — The clear (✕) button left stale results on screen.
It only cleared the input (setQuery("")) and never restored the cached index.

Finding 6 — GridView thumbnails would crash at runtime.
next/image served picsum.photos URLs that weren't in next.config.ts images.remotePatterns → Invalid src runtime error in grid mode.

B. FIX FEATURES — what the fix does
Frontend (the issue's declared path):

Real API data fetching (Axios/fetch → fetch, matching repo conventions): searchService.ts is now a live client calling GET {NEXT_PUBLIC_API_URL}/api/v1/certificates?search=…&limit=50&skip=0 — fetchAllCertificates() (no query → global index) and searchCertificates(query) (debounced search), both with AbortSignal support.
Envelope + type mapping: unwraps the backend's { success, data: {certificates, total} } shape and maps each document → SearchResult (id ← Soroban certificateId, hash ← manifest contentHash/tx hash, creator ← on-chain Stellar creator, name/type ← populated asset, MIME bucketed to Image/Video/Audio/Document/3D Model).
Loading states preserved & hardened: skeleton/spinner on initial load and on every debounced keystroke; aborted requests never flash false error banners.
Robust error handling: non-2xx → surfaces the server's message; network down → friendly "Unable to reach the StellarProof API…"; malformed payload → explicit shape error.
Build-breaker removed: GridView now receives the adapted Certificate[]:
Diff

  •        results={results}
    
  •        results={gridResults}
    

Correct data passing to both views: ListView ← SearchResult[], GridView ← adapted Certificate[] (type-safe).
✕ clear restores the cached index instantly — no redundant fetch, no stale rows.
Runtime crash closed: picsum.photos added to images.remotePatterns; .env.example documents NEXT_PUBLIC_API_URL (and is whitelisted in .gitignore — .env* was swallowing it).
Backend (additive, required for "real data", creatorId legacy callers unaffected):
9. Global index: creatorId now optional — omitting it returns the public global certificate index sorted newest-first.
10. Search filter: new Zod-validated search? param → regex-escaped, case-insensitive $or across certificateId, transactionHash, contractAddress; combines with creatorId under $and.
11. Richer records: list query now .populate()s assetId (name/type) and manifestId (content hash/creator/description) so the UI renders human-readable rows in one round-trip.

Acceptance criteria all met — each backed by automated tests: ✅ real data from API • ✅ spinners during fetch • ✅ loading/error states • ✅ data passed to List/Grid • PR-ready (
stellarproof-search-api-fix.patch
; remember Closes #[issue_id]).

Verified (post-restore): search 17/17 ✅ · backend 56/56 (11 suites) ✅ · next build ✓ with /search ✅ · ESLint clean on all touched files ✅

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

@veloura-dev is attempting to deploy a commit to the DaniBravo Team on Vercel.

A member of the Team first needs to authorize it.

@veloura-dev

Copy link
Copy Markdown
Contributor Author

@Tybrvo
CI / build-and-check (pull_request).....im on it

@veloura-dev

Copy link
Copy Markdown
Contributor Author

@Tybravo review pls

@Tybravo
Tybravo merged commit e8e76e1 into Tybravo:main Aug 2, 2026
1 of 2 checks passed
@Tybravo

Tybravo commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@veloura-dev

Good job done

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Frontend] [Feature] Integrate Soroban/Backend Search API for Global Certificate Search

2 participants