{
 "schema_version": 1,
 "generated": "2026-10-26",
 "id": "margelo-ai-chat-demo--study-websocket-llm-streaming-in-react-native",
 "repo": "margelo/ai-chat-demo",
 "repo_url": "https://github.com/margelo/ai-chat-demo",
 "repo_slug": "margelo-ai-chat-demo",
 "title": "Study WebSocket streaming for LLM replies in React Native",
 "page_title": "How to study WebSocket streaming for LLM replies in React Native with AI Chat Demo",
 "summary": "Read the protocol, connection, and store code to see how tokens and tool calls stream into the UI.",
 "who": "A React Native engineer building their own streaming AI feature who needs a reference for socket lifecycle and tool-call loops.",
 "problem": "Streaming model output over a socket in a mobile app, with reconnects and tool calls, is easy to get wrong without a working example.",
 "outcome": "The engineer understands how the app prewarms the socket, streams reply text and reasoning summaries, and chains turns with previous_response_id.",
 "steps": [
  "Read `app/src/openai/connectionManager.ts` to see the module-level WebSocket lifecycle and reconnect with backoff.",
  "Read `app/src/openai/protocol.ts` to see how Responses API requests are built and server events are parsed.",
  "Read `app/src/state/chatStore.ts` to follow the streaming state and the tool-call loop.",
  "Run `npm test` to see the existing Jest tests.",
  "Run `npm run lint` to check the code style the repo uses."
 ],
 "agent_prompt": "Review margelo/ai-chat-demo and explain how app/src/openai/connectionManager.ts and app/src/openai/protocol.ts stream Responses API events over react-native-nitro-websockets. Output a short written summary of the event flow and confirm with npm test that the existing tests pass.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "The reference is a demo that keeps keys in the app bundle, so copy the streaming patterns and not the key handling.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "typescript",
 "requirements": [
  "Xcode and CocoaPods for iOS, or the Android setup from the React Native environment guide",
  "Node 22.11 or newer",
  "An OpenAI API key",
  "A Pinecone API key, a populated Pinecone index, and its index host"
 ],
 "risk": "sensitive",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/margelo-ai-chat-demo/study-websocket-llm-streaming-in-react-native/",
 "md": "https://dedupedai.com/use-cases/margelo-ai-chat-demo/study-websocket-llm-streaming-in-react-native/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/margelo-ai-chat-demo--study-websocket-llm-streaming-in-react-native.json",
 "api_version": "v1"
}
