Build a user directory application that fetches user data from an API and allows users to search and filter the results.
Intermediate
- Estimated Time: 90-120 minutes
- Technologies: React, TypeScript, TanStack Query, Tailwind CSS, Next.js
- Concepts: API integration, state management, filtering, data transformation
By completing this problem, you will learn:
- How to integrate with REST APIs using React Query
- Data modeling and TypeScript type design
- Client-side filtering and search implementation
- Custom hooks for business logic
- Component architecture and composition
- localStorage for persistence
- Responsive design with Tailwind CSS
- Framework: Next.js 14+ (App Router)
- Language: TypeScript
- State Management: React Query + useState
- Styling: Tailwind CSS
- API: Random User API (https://randomuser.me/api/?results=50)
- Fetch 50 users from Random User API
- Display users in a responsive grid
- Show: profile image, name, email, nationality
- Search by first OR last name (case-insensitive, real-time)
- Filter by nationality using dropdown
- Show loading state while fetching
- Show error state on failure
- Show "no results" when filters return empty
- Favorites feature with persistence (localStorage)
- Tab navigation between "All Users" and "Favorites"
- Responsive design (mobile, tablet, desktop)
- Proper TypeScript types throughout
- Debounced search for large datasets
- Skeleton loaders
- Animations/transitions
- Accessibility features
-
Interview Simulation (90 min)
- Read requirements, try solving yourself
- Time yourself
- Review solution after
-
Guided Learning (4-6 hours)
- Follow ARCHITECTURAL_GUIDE.md step by step
- Deep dive into each decision
- Build with full understanding
-
Tutorial Mode (2-3 hours)
- Follow IMPLEMENTATION_GUIDE.md
- Build along with instructions
- Rebuild from memory after
REQUIREMENTS.md- Detailed requirements breakdownARCHITECTURAL_GUIDE.md- How to think about this problemIMPLEMENTATION_GUIDE.md- Step-by-step build instructionssolution/- Complete working implementationvariations/- Alternative implementationstests/- Test cases and testing guideresources/- API samples, designs, etc.
You should be comfortable with:
- React basics (components, hooks, state)
- TypeScript fundamentals
- Basic API integration
- CSS/Tailwind basics
If you're not comfortable yet, consider starting with beginner problems first.
Click to reveal hints (try without first!)
- Use React Query for server state (users from API)
- Use useState for client state (search, filter, favorites)
- Use useMemo for derived state (filtered users)
- Separate smart (container) and dumb (presentational) components
- Extract filtering logic into custom hook
- Keep UserCard component simple and reusable
- Create separate types for API response and domain objects
- Transform API data at the boundary
- Use email as unique identifier
- Handle API failures gracefully
- Validate localStorage data on load
- Handle empty search and filter states
- Make sure images have alt text
- Test with keyboard navigation
Your solution should:
- Meet all P0 requirements
- Be fully typed with TypeScript (no
any) - Have no console errors or warnings
- Handle loading and error states
- Be responsive on all screen sizes
- Be keyboard accessible
- Have clean, organized code
- Follow React best practices
- API integration with React Query
- TypeScript type modeling
- Custom hooks design
- Component architecture
- State management patterns
- localStorage integration
- Requirement analysis (explicit vs implicit)
- Data structure design
- State management decisions
- Component responsibility boundaries
- Performance considerations
- Edge case analysis
- Problem decomposition
- Systematic implementation
- Communication while coding
- Trade-off analysis
- Time management
After completing the base problem, try these variations:
- State Management: Rebuild with Zustand or Redux
- Styling: Rebuild with styled-components or CSS modules
- Features: Add sorting, pagination, or detail modal
- Performance: Add virtualization for 1000+ users
- Testing: Add comprehensive test suite
- Easier: Simple Todo List
- Similar: Product Catalog with Filters
- Harder: Dashboard with Multiple Data Sources
After completing, reflect on:
- What was the hardest part?
- What would you do differently?
- What trade-offs did you make?
- How would you scale this for 10,000 users?
- What would you add given more time?
Ready to start? Choose your approach and dive in!
Need help? Check the guides or open a discussion.
Finished? Compare with solution and try a variation!