Question library
Explained questions for the decisions developers make.
How do you optimize without hurting quality?
Establish a quality/security baseline, measure the expensive stages, and experiment with routing, context reduction, batching, or caching. Release only when held-out outcomes, tail latency, and privacy requirements remain acceptable.
Five agent steps became fifty after a change. What happens?
A strict step/time/token budget stops the run and reports a supported fallback. I inspect progress and repeated calls, compare prompt/tool changes, and track long-tail cost rather than allowing an expensive loop to continue.
Python
Beginner — Why learn Python as a MERN engineer?
Why learn Python as a MERN engineer?
Many AI, document, numerical, and evaluation libraries are strongest there. I need enough Python to build and operate those services, but hosted model APIs and business orchestration can remain in Node.
Do type hints validate runtime input?
No. They help developers and type checkers. I use Pydantic or explicit validation for external data and carefully configure coercion/strictness where field values affect business behavior.
How do you make notebook experiments production-ready?
Move reusable logic into explicit modules and services, pin dependencies, remove hidden notebook state, inject clients, add meaningful boundary tests, and implement logging, resource limits, and deployment reproducibility.
An async endpoint freezes during OCR. Why?
The OCR library may be synchronous or CPU-heavy, so it blocks the event loop. I offload suitable work to threads/processes or queued workers and keep the HTTP boundary responsive with durable job status.
FastAPI
Beginner — What is FastAPI's role?
What is FastAPI's role?
It provides a Python HTTP service boundary with declared routes and data schemas. Pydantic validates input/output, while application dependencies and services enforce identity, permissions, and business rules.
When should a route be async?
When it awaits compatible nonblocking I/O. Async does not make CPU work fast or turn a synchronous SDK into an async one. I choose client and execution boundaries deliberately.
Where should long extraction run?
In bounded workers with durable jobs, retries, status, and resource isolation. FastAPI can start/check tasks or expose fast specialized operations; it should not keep arbitrary multi-minute processing alive solely through an open request.
Node can call the LLM already. Why add FastAPI?
Only for a concrete Python library, local model, numerical workload, or scaling boundary. Otherwise another service adds authentication, deployments, networking, contracts, and failures without meaningful benefit.
MERN and AI
Beginner — Where does the LLM call belong?
Where does the LLM call belong?
In a server-side AI service behind authenticated Node/Next.js routes. React sends bounded input and receives safe text/events; provider secrets and trusted instructions stay on the backend.
How do MongoDB, Redis, and a vector index differ?
MongoDB stores application documents and canonical records where appropriate. Redis provides scoped caching/counters/queue backing. A vector index serves derived retrieval representations; none should silently replace authoritative claim-service truth.
How do you structure the backend?
Separate identity/validation, AI context and provider adapters, retrieval, safe tools, and domain services. Add queues or a graph only when state/recovery demands them. Keep business contracts independent of whichever framework coordinates the conversation.
A React chat UI renders malicious generated HTML. What changes?
Render model content as escaped text or a sanitized restricted Markdown subset. Do not trust generated HTML or links automatically. Review XSS, source URLs, attachment access, and leaked internal events alongside the backend controls.
AI system design
Beginner — What questions come before architecture?
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.