Originally created by: jobenjada
Originally owned by: anjy7
Client-side filtering doesnt scale well
Describe the solution you'd like
Description:
We are embarking on an important transition in Formbricks: moving from frontend-based filtering logic to a scalable server-side approach. As our data volume grows, loading and processing all responses on the frontend becomes increasingly impractical. Your task is to conceptualize and implement a server-side filtering mechanism for the getResponses ( packages/lib/response/service.ts) service. This concept is crucial, as it will set the stage for similar implementations in other services.
Objective:
Create a scalable and efficient server-side filtering concept for the getResponses service. This concept should handle a variety of filter configurations and provide paginated results. Your work will be foundational, setting a pattern for extending this logic to other services.
Tasks:
- Research and Conceptualization:
- Familiarize yourself with our current frontend filtering logic, particularly on the survey summary page. You can create a link survey at https://app.formbricks.com/ , submit a few responses and play with the filter options.
- Develop a concept to transition these filtering options to server-side logic. How can we find a universal approach that has a great developer experience, easily let’s the developer get all responses or only the responses that match a certain filter.
- Include essential filters such as question values, response completion status, and tags in your concept.
- Design the Filtering Logic:
- Ensure the filtering logic is adaptable and can be easily applied to other services like surveys and teams.
- Propose a flexible mechanism for managing filters.
- Implementation in
getResponses:
- Implement your designed filtering logic in the
getResponses service.
- The service should efficiently handle paginated requests.
- Performance Optimization:
- Construct performant Prisma queries for the filtering process.
- Maintain effective caching that complements the new server-side filtering.
- Documentation:
- Thoroughly document your filtering concept and its implementation process.
- Provide clear guidelines for applying this pattern to other services.
- Collaboration and Feedback:
- Initially, discuss your approach with Matti for alignment and valuable insights.
- Ensure your concept aligns with our architecture and scalability goals.
Expected Outcomes:
- A detailed and practical concept for server-side filtering.
- Successful implementation in the
getResponses service.
- Comprehensive documentation for future reference and expansion.
Additional Notes:
- The significance of your contribution cannot be overstated; this concept will be a cornerstone for future development in Formbricks.
- As you work, keep in mind the need for scalability and adaptability in your design to meet our evolving needs.
Describe alternatives you've considered
No response
Additional context
No response
Originally posted by: anjy7
I would like to take this one :)
Originally posted by: jobenjada
you got it :) Pls make sure to talk it through with GPT first and then Matti before getting to the implementation 🤓