Skip to content

feat(backend): implement global search api#148

Open
a7hu-15 wants to merge 7 commits into
nensii21:mainfrom
a7hu-15:feature/search-api
Open

feat(backend): implement global search api#148
a7hu-15 wants to merge 7 commits into
nensii21:mainfrom
a7hu-15:feature/search-api

Conversation

@a7hu-15

@a7hu-15 a7hu-15 commented Jul 4, 2026

Copy link
Copy Markdown

Description

This PR introduces a Global Search API to the backend, allowing the frontend to search across different entities (Users and Projects) through a single endpoint.

Summary of changes:

  • Search Router (backend/app/routers/search.py): Added a /search/ GET endpoint that accepts a query string q.
  • Search Logic (backend/app/services/search_service.py): Implemented fuzzy search (ilike) using SQLAlchemy to match the query against:
    • Users: username, first name, last name, and headline.
    • Projects: title, description, and tagline.
  • Schemas (backend/app/schemas/search.py): Created SearchResult models to return a unified payload.

How it Works (Example Usage)

Here is an example of what the new API returns when a user searches for a query like q=react:

GET /api/search/?q=react

{
  "users": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "username": "react_developer_99",
      "first_name": "John",
      "last_name": "Doe",
      "headline": "Frontend Engineer | React Enthusiast"
    }
  ],
  "projects": [
    {
      "id": "987fcdeb-51a2-43d7-9012-426614174000",
      "title": "React Dashboard Setup",
      "description": "An open source admin dashboard built with React and Tailwind.",
      "tagline": "Modern React Admin"
    }
  ]
}

(Note: As this is a backend API implementation, there are no frontend UI changes to screenshot yet. The above JSON demonstrates the API behavior.)

Related Issue

No linked issue.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Added pytest configurations in backend/tests/conftest.py using fastapi.testclient.TestClient.
  • Created unit tests in backend/tests/test_search.py to verify the search endpoint handles queries correctly and returns the expected structured data.

@nensii21

nensii21 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Thanks for opening this PR. The description is currently incomplete. Please update it with:

A clear summary of the changes made.
The issue number this PR addresses (e.g. Closes #123).
The type of change.
How you tested the implementation.
Attached video and screenshots of what changes you have made

Once the PR description is updated, I'll proceed with the review.

@nensii21 nensii21 closed this Jul 4, 2026
@nensii21 nensii21 reopened this Jul 4, 2026
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.

3 participants