Q1
When designing a full-stack + mobile AI application, why should LLM API calls stay on the Node.js backend rather than directly in React or React Native?
Embedding provider API keys in client JS or mobile APKs allows trivial reverse-engineering and quota theft. Routing through Node/Express lets you guard secrets, enforce per-user rate limits, stream SSE tokens safely, and log usage.
Q2
How do you prevent long-running LLM generation requests from hitting API gateway 30s timeouts?
Stream partial responses incrementally via Server-Sent Events (SSE) or WebSockets, or offload multi-step tasks to an async job queue (BullMQ/SQS) returning an immediate 202 Accepted job ID.
Q3
Why can React Native apps freeze on Android during heavy JSON parsing or flatlist scrolling—and how do you fix it?
Running expensive work on the JS thread drops animation frames. Use FlatList/FlashList with keyExtractor and memoized rows, paginate API responses cleanly, and keep animations on the native UI driver (useNativeDriver: true).
Q4
In AWS full-stack deployment, why does storing uploaded user files inside EC2 local disk fail when Auto Scaling launches a second instance?
Local EBS storage belongs only to one EC2 instance, breaking uploads across load-balanced servers and wiped autoscaled nodes. Always store user media in shared S3 buckets via pre-signed URLs.
Q5
How do JWT Access Tokens + Refresh Tokens balance stateless speed with instant session revocation?
Keep Access Tokens short-lived (5–15 min) verified statelessly, while storing Refresh Tokens hashed inside MongoDB/Redis so compromised sessions can be revoked immediately at refresh time.
Q6
Why does CORS succeed in Postman while failing in Chrome when calling your Express API from React?
CORS is enforced exclusively by browsers (Origin headers and OPTIONS preflight checks), never by non-browser tools like Postman/curl. Explicitly whitelist allowed origins, methods, and headers (Authorization, Content-Type) in Express.
Q7
What causes N+1 query bottlenecks in MongoDB REST APIs—and how do .populate() vs $lookup compare?
Querying parent records then issuing an individual DB query inside a .map() loop per item kills latency. Batch fetch with $in, use Mongoose .populate(), or aggregate server-side via $lookup.
Q8
Why should MongoDB ObjectId validation (mongoose.Types.ObjectId.isValid) happen before querying /api/users/:id?
Passing a malformed string directly to findById() throws an unhandled CastError 500 response. Validating IDs upfront cleanly returns a 400 Bad Request without polluting error logs.
Q9
How do you secure MongoDB and Express against NoSQL operator injection ({ $ne: null } inside req.body)?
Sanitize keys starting with $ or ., enforce strict Zod/Joi schemas rejecting unexpected objects where strings are expected, and never pass raw req.body into .findOne().
Q10
Why is idempotency crucial when a mobile client retries failed checkout or booking API requests on spotty 4G?
Network drops can cause the client to retry an already-processed POST. Require a client-generated Idempotency-Key header persisted in DB/Redis so retries return the original outcome without double-charging.