Design a full-stack AI playground web application similar to a chat product, but with one document-like component that interleaves user prompts and model responses in the same view.
The component should support:
-
Inserting a prompt at any cursor position inside the editor
-
Sending that prompt to an AI model
-
Rendering the streamed or final response directly below the prompt that triggered it
-
Saving individual prompts or entire sessions
-
Sharing saved prompts with other users
-
Enforcing privacy and access control for private content, shared links, and team-visible content
Describe the frontend architecture, editor data model, backend APIs, persistence layer, and sharing model. Also explain how you would handle privacy, secure sharing, response streaming, and the user experience of editing and submitting prompts from arbitrary positions in the same component.