MERN and AI
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn MERN and AI
Beginner — 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.
Intermediate — 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.
Senior — 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.
Scenario — 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.
Adapted from 13_AI.MD · “29.20 MERN and AI”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.