Skip to content

Technical guide · Public product

Page status: Active

Full archive search

NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.

Visual overview

Primary diagram

System map

NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.

Render the repository-owned system map when you need it.

Diagram is not rendered yet.

View as text
Full archive search

NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.

flowchart TD
  accTitle: Full archive search
  accDescr {
    NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.
  }
  A[User enters search query] --> B[Frontend calls /api/search]
  B --> C[Backend executes Postgres full-text search]
  C --> D[Search weights apply by title, summary, source, category]
  D --> E[Return ranked results + nextPage metadata]
  E --> F[Web home feed renders search mode]
  F --> G[User taps result]
  G --> H[Open story detail]
  G --> I[User taps Clear]
  I --> J[Return to normal feed and infinite scroll]

Full archive search

Fullscreen diagram view.

NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.

The migration adds:

  • articles.search_vector, a generated tsvector column
  • articles_search_vector_idx, a GIN index for fast search
  • articles_search_published_idx, an index for published story ordering
  • public.search_articles(search_query, page_size, page_offset), an RPC function used by the web API

Search weights:

  • Title: A
  • AI summary: B
  • Source: C
  • Category: C

The API route is:

GET /api/search?q=dogs&page=0&limit=20

Response shape:

{
"articles": [],
"nextPage": null,
"query": "dogs",
"page": 0,
"pageSize": 20,
"languageCode": "en"
}

The search box is built into the existing home feed component:

web/app/components/ArticleFeed.tsx

When a user searches, the home page switches from normal feed mode to archive search mode. The clear button returns to the normal feed and infinite scroll.

Terminal window
cd /Users/ramideltoro/WebstormProjects/nutsnews3/web
npm run build
npm run dev

Then:

Terminal window
curl -s "http://localhost:3000/api/search?q=dogs&limit=5" | python3 -m json.tool
curl -I "http://localhost:3000/api/search?q=dogs&limit=5"

Open:

http://localhost:3000

Search for dogs, community, science, and a nonsense query like zzzzzzzzzz.