feat(backend): implement global search api#148
Open
a7hu-15 wants to merge 7 commits into
Open
Conversation
Owner
|
Thanks for opening this PR. The description is currently incomplete. Please update it with: A clear summary of the changes made. Once the PR description is updated, I'll proceed with the review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
backend/app/routers/search.py): Added a/search/GET endpoint that accepts a query stringq.backend/app/services/search_service.py): Implemented fuzzy search (ilike) using SQLAlchemy to match the query against:backend/app/schemas/search.py): CreatedSearchResultmodels 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
How Has This Been Tested?
pytestconfigurations inbackend/tests/conftest.pyusingfastapi.testclient.TestClient.backend/tests/test_search.pyto verify the search endpoint handles queries correctly and returns the expected structured data.