You need to build a product search page with text search, filters and sorting. Walk through the design from the UI to the database.
What the interviewer wants to hear
- Keep search state in the URL query string so it is shareable
- Debounce input and cancel stale requests
- Design a validated API with filters, sort and cursor pagination
- Use suitable indexes or full-text search in the database
- Consider a search engine when needs grow (typos, ranking)
- Cache common queries and measure performance
Model answer
On the frontend I store the search text, filters and sort in the URL query string, so results are shareable, bookmarkable and survive refresh. The input is debounced by around 300 ms, and I cancel stale requests so old responses never overwrite new ones. The API is GET /api/products with parameters like q, category, minPrice, sort and cursor; it validates and allowlists every parameter, especially sort fields, and returns items plus a next cursor. In PostgreSQL I start with full-text search using a tsvector column and a GIN index, plus B-tree indexes on common filter columns, and I check plans with EXPLAIN. Cursor pagination keeps deep pages fast. If we later need typo tolerance, synonyms or ranking tuning, I would sync data to a search engine like Meilisearch or Elasticsearch. Popular queries can be cached briefly at the CDN.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Full Stack Developer questions
- How would you implement login for a web app? Compare server sessions with JWT access tokens and explain what you would choose.
- Users say the orders page is slow. How do you find and fix the problem across frontend, API and database?
- How would you build a feature that lets users upload profile photos and PDF documents up to 100 MB?
- Your API is used by a web app and an older mobile app that users do not update quickly. How do you make a breaking change safely?
- Describe a good CI/CD pipeline for a full stack app. What runs on each pull request and how do you deploy safely?
- How would you add role-based access control (admin, editor, viewer) to an existing full-stack app?
- What is your testing strategy for a full-stack feature such as "invite a teammate by email"?
- Describe the different layers where you can cache in a typical full-stack web app, and how you keep cached data correct.
- You need to show in-app notifications in real time. How do you choose between polling, server-sent events and WebSockets, and how would you build it?