Customers need to import CSV files with up to two million rows into your app. Design the feature end to end.
What the interviewer wants to hear
- Upload directly to object storage with a presigned URL
- Process asynchronously with a job queue and workers
- Stream and parse in batches instead of loading the whole file
- Validate rows, collect errors and make imports resumable and idempotent
- Show progress and results in the UI
- Use bulk inserts or COPY and watch database load
Model answer
A two-million-row file cannot be handled inside one HTTP request. The browser asks the API for a presigned URL and uploads directly to S3, then the API creates an import record with status QUEUED and enqueues a job. A worker streams the file from storage, parses it row by row and processes batches of, say, 5,000 rows, so memory stays flat. Each row is validated with the same schema the API uses; bad rows are written to an error report instead of failing the whole import. Batches are written with bulk inserts or PostgreSQL COPY into a staging table, then merged with upserts keyed on a natural ID, which makes retries idempotent and lets a crashed job resume from its last checkpoint. The worker updates progress on the import record, and the UI polls or subscribes to show it, finishing with a summary and downloadable error file.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Full Stack Developer questions
- You are building a multi-tenant B2B SaaS app. How would you design data isolation between tenants, and what are the trade-offs?
- Your app works well for 1,000 users. Traffic is expected to grow to 1 million users. How would you prepare the system, and in what order?
- An order flow touches your database, a payment provider and an email service. How do you keep the system consistent when any step can fail?
- You need to split a large users table column "name" into "first_name" and "last_name" on a table with 50 million rows, with no downtime. Walk through your plan.
- For a large e-commerce site in Next.js, how would you choose the rendering and caching strategy for the home page, product pages, cart and account pages?
- Design an e-commerce checkout end to end: cart, payment with a provider like Stripe, inventory and order confirmation. What can go wrong and how do you make it reliable?
- Your startup’s Next.js monolith is growing and some engineers want to split it into microservices. How do you decide, and what would you do?
- Ten minutes after a deploy, 500 errors jump from 0.1% to 8% on the main API. Walk through how you handle the incident.
- You are opening your product’s API to outside partners. How do you design authentication, authorization, rate limiting and change management for it?