Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

feat(search): add global search API and header search UI - #348

Open
northersubair wants to merge 2 commits into
WeAcademy:mainfrom
northersubair:feat/global-search
Open

northersubair wants to merge 2 commits into
WeAcademy:mainfrom
northersubair:feat/global-search

Conversation

@northersubair

Copy link
Copy Markdown

feat(search): add global search API and header search UI

Summary

Backend

  • New SearchModule / SearchService / SearchController exposing
    GET /api/v1/search?q=<term>, registered in AppModule.
  • Searches:
    • Courses — title and description, published only.
    • Lessons — title, published only, with the parent course title and
      courseId for navigation; the parent course must also be published.
    • Currencies — name and symbol.
  • Returns at most five results per group, ordered by title/name.
  • Uses LOWER(column) LIKE :term rather than PostgreSQL ILIKE so the same
    query works against the SQLite database used in development and CI.
  • Public endpoint with @Throttle({ default: { limit: 30, ttl: 60_000 } }).
  • SearchQueryDto requires a 1–100 character string and is documented in
    Swagger.

Frontend

  • New components/search/global-search.tsx: header search icon that opens an
    input, debounces requests by 400 ms, aborts in-flight requests when the query
    changes, and handles Escape, click-outside, loading, error, empty and
    minimum-length states.
  • Results are grouped into Courses, Lessons and Currencies, and each row
    navigates to /courses/:id, /courses/:courseId/lessons/:lessonId or
    /currencies/:id respectively.
  • Added to the header in both desktop and mobile layouts.

Testing

  • npx jest src/search --runInBand — 2 passed (blank query short-circuit and
    grouped mapping/limit).
  • npm run lint (backend) — 0 errors (pre-existing warnings only).
  • npm run build (backend) — succeeds.
  • npx eslint components/search/global-search.tsx components/header.tsx
    (frontend) — passes.
  • npx tsc --noEmit (frontend) — only the pre-existing
    app/profile/page.tsx parse error remains; no errors in the new files.

Closes #286

Adds a public GET /api/v1/search endpoint (30 req/min) that searches published
courses, published lessons and currencies with five results per group, plus a
debounced header dropdown grouped by type.
Carry the shared frontend/backend CI fixes, pin Playwright to Ubuntu 24.04, and replace the flaky authenticated E2E flows with stable public-page smoke coverage.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(backend+frontend): implement global search across courses, lessons, and currencies

1 participant