Skip to content

[Feature]: Add Full-Text Search Across All Notes with Instant Results Using Next.js API Route #363

Description

@divyanshim27

Summary

openCSE is a documentation and notes platform for CSE subjects. Currently, there is no search functionality anywhere on the site. A student looking for a specific topic (e.g., "binary search tree", "TCP handshake", "process scheduling") has no way to search across subjects — they must manually navigate to the right subject and scroll to find what they need.

For a knowledge base platform, search is arguably the most important navigation tool.

Problem

  • The app/ directory (Next.js pages) contains no search component or search page.
  • There is no API route for querying note content.
  • Notes live under notes/dsa/arrays/ and similar paths — structured content that is entirely unsearchable from the UI.
  • Without search, the platform's usability degrades as more subjects and topics are added.

Proposed Solution

I will implement a full-text search feature using Next.js's built-in capabilities — no external search service required:

Step 1 — Build a search index at build time (lib/search-index.ts):

// Reads all markdown files from /notes at build time and builds a searchable index
export function buildSearchIndex(): SearchEntry[] {
  // Walk /notes directory, parse frontmatter + content
  // Return array of { title, subject, topic, slug, excerpt }
}

Step 2 — API Route (app/api/search/route.ts):

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url);
  const query = searchParams.get('q') || '';
  const results = searchIndex.filter(entry =>
    entry.title.toLowerCase().includes(query.toLowerCase()) ||
    entry.content.toLowerCase().includes(query.toLowerCase())
  );
  return Response.json(results.slice(0, 10));
}

Step 3 — Search UI Component (app/components/SearchBar.tsx):

  • Debounced input field (300ms) that calls /api/search?q=...
  • Dropdown showing top results with subject label, topic title, and a matching excerpt
  • Keyboard navigation (arrow keys + Enter to navigate)
  • Added to the global navbar so it's accessible from every page

This is all TypeScript/Next.js and uses zero new dependencies beyond what's already in package.json.

Please assign this to me. I'll share a component design before submitting a PR.

Labels: enhancement, feature-request, ux, help wanted, GSSoC 2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions