# yeyu2/youtube_demos architecture

> Architecture diagram of the GitHub repository yeyu2/youtube_demos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yeyu2/youtube_demos
- Repository: https://github.com/yeyu2/youtube_demos

## Overview

1. This repository is a collection of mostly independent AI demo applications, not a single unified product. The top-level structure groups experiments by capability: realtime multimodal chat, agent orchestration, RAG, workflow building, mobile clients, browser extensions, and document-generation pipelines.

2. The dominant architecture pattern is “client UI + thin backend + model/service providers.” In many demos, the browser or mobile app captures audio, video, screen, or text input, sends it to a Python or Node backend, and receives streamed model output back. WebSocket-based realtime streaming is especially common.

3. The realtime multimodal family is the largest subsystem cluster. Folders like `gemini20-realtime`, `gemini20-screen`, `gemini20-voicetext`, `gemini20-canvas`, `gemini20-longmem`, `ADK-live-demo`, `adk-gemini3`, `Livekit-dev`, and `gemini_api_update_042025` all follow a similar flow: frontend audio/video/screen capture, backend session coordination, model inference via Gemini Live or similar APIs, and streamed audio/text responses. Browser-side PCM/audio worklets and audio players are a recurring implementation detail.

4. These realtime demos usually separate responsibilities into three layers: presentation UI, media transport, and AI orchestration. The UI handles controls and display; transport code manages WebSocket or realtime session state; backend agent code transforms user signals into model requests and post-processes responses. Some projects also include special-purpose processors for audio encoding/decoding or screen-share frames.

5. The agent-orchestration demos form another major subsystem. `CrewAI`, `AutoGen_API`, `AgentKit`, `Swarm_adv`, `context-aware`, `adk-graph`, and parts of `adk-rag` all focus on multi-agent coordination, tool calling, planning, and delegation. Their architecture usually centers on an orchestrator or supervisor agent that routes work to specialist agents and tools, then merges results for the user.

6. In these agent demos, the important boundary is between orchestration logic and tool implementations. Tool modules encapsulate search, retrieval, browsing, file access, graph access, or structured output generation, while agent files define behavior, roles, and handoff logic. This separation is visible across projects such as `CrewAI/crewai_orche.py`, `AutoGen_API/autogen_api.py`, and `adk-rag/custom-rag-streaming-ws/rag_agent/orchestrator.py`.

7. The workflow-builder subsystem is the clearest full-stack app in the repo. `Workflow-builder/simple-ai-workflow` is a Next.js/TypeScript application with API routes, a visual workflow editor, node definitions, validation, execution logic, and reusable UI components. Its architecture is centered on workflow definitions flowing from the editor into a runtime executor, with model/tool selection abstracted behind shared library modules.

8. The RAG-focused projects share a retrieval pipeline architecture: document ingestion, indexing, query-time retrieval, and answer generation. Examples include `adk-rag/custom-rag-streaming-ws`, `auto-rag-optimizer`, `Swarm_adv`, and `Workflow-builder/simple-ai-workflow/lib/tools/*` for external search sources. The key boundary is between data preparation/indexing and retrieval-time orchestration.

9. `auto-rag-optimizer` is a more research-oriented pipeline than the interactive demos. It combines an evaluator, orchestrator, RAG pipeline, experiment runner, and visualizer to systematically improve retrieval settings. That makes it a closed-loop optimization system: run experiments, score results, store the best config, and inspect outputs via generated artifacts and charts.

10. Several projects are output-generation pipelines rather than conversational apps. `Storybook-Gen` is structured around orchestration, image generation, PDF building, schema checking, and cost tracking; `Genai-processors` contains utilities for generating blog images or podcast-like outputs from source material. These projects emphasize staged content transformation rather than live interaction.

11. There is a strong provider abstraction layer across the repo, but it is not centralized in one shared package. Different demos target Gemini/Gemini Live, OpenAI, AutoGen, CrewAI, ADK, Fireworks, OpenRouter, local Llama/Gemma/Phi models, Whisper, Kokoro, and LiveKit. In the architecture diagram, these should be shown as external model/service dependencies behind each demo’s backend, not as a common platform service.

12. Platform-specific client implementations are also important boundaries. `gemini20-android` and `gemini20-android-serverless` are Android frontends paired with backend entrypoints; `GeminiChrome` is a browser extension with content scripts, background logic, and a side panel; `CrewAI_Panel_Update`, `CrewAI_Taipy`, `CrewAI_Streamlit.py`, and `AutoGen_API/react_mini_app` are alternate UI shells for similar agent capabilities. These are interchangeable presentation layers over different backend logic.

13. The repository contains some memory- and context-aware variants that add stateful conversation behavior. `gemini20-longmem` includes a React/Vite frontend with WebSocket handling and screen-share support, while `context-aware/context_demo` and parts of `adk-graph` focus on maintaining and querying context over time. In diagram terms, these introduce a state or memory service between the user session and the model call path.

14. Overall, the architecture to diagram is a set of repeated reference implementations: input-capture clients, transport/session layers, orchestration or retrieval logic, and external AI/model services. The repo’s real “system boundary” is the pattern library of demos themselves, not a shared runtime or monolithic backend.

Main entry points: [`Workflow-builder/simple-ai-workflow/lib/workflow/executor.ts`](https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/lib/workflow/executor.ts) (Workflow runtime), [`gemini20-realtime/main2.py`](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/main2.py) (Session backend), [`gemini20-realtime/index.html`](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/index.html) (Realtime UIs), [`CrewAI/crewai_orche.py`](https://github.com/yeyu2/youtube_demos/blob/main/CrewAI/crewai_orche.py) (Agent supervisor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_realtime["Realtime multimodal"]
  node_realtime_ui["Realtime UIs<br/>demo suite<br/>[index.html]"]
  node_realtime_backend["Session backend<br/>python websocket backend<br/>[main2.py]"]
  node_realtime_media["Audio worklets<br/>media transport<br/>[pcm-processor.js]"]
  node_screen_demo["Screen share demo<br/>multimodal demo<br/>[main.py]"]
  node_longmem_app["Long memory app<br/>stateful demo<br/>[App.tsx]"]
  node_longmem_backend["Memory backend<br/>python backend<br/>[main-longmem.py]"]
  node_adk_live_demo["ADK live demo<br/>adk streaming app<br/>[main.py]"]
end

subgraph group_agents["Agent orchestration"]
  node_agent_supervisor["Agent supervisor<br/>orchestrator<br/>[crewai_orche.py]"]
  node_agent_tools["Tools layer<br/>tool modules<br/>[crewai_tools.py]"]
  node_context_agent["Context agent<br/>stateful agent<br/>[agent.py]"]
end

subgraph group_rag["Retrieval apps"]
  node_adk_orchestrator["RAG orchestrator<br/>agent coordinator<br/>[orchestrator.py]"]
  node_file_search["File search<br/>retrieval tool"]
  node_rag_optimizer["RAG optimizer<br/>experiment pipeline<br/>[orchestrator.py]"]
end

subgraph group_workflow["Workflow builder"]
  node_workflow_editor["Workflow app<br/>nextjs app<br/>[page.tsx]"]
  node_workflow_runtime["Workflow runtime<br/>executor<br/>[executor.ts]"]
  node_workflow_tools["Search tools<br/>tool adapters<br/>[index.ts]"]
end

subgraph group_generation["Content pipelines"]
  node_story_pipeline["Story pipeline<br/>content generation<br/>[orchestrator.py]"]
  node_media_generators["Media generators<br/>generation tools"]
end

subgraph group_clients["Platform clients"]
  node_mobile_client["Android client<br/>mobile frontend<br/>[MainActivity.kt]"]
  node_mobile_backend["Mobile backend<br/>python backend<br/>[main_for_mobile.py]"]
  node_browser_extension["Chrome extension<br/>extension ui<br/>[background.js]"]
end

node_model_services[("Model services<br/>external ai providers")]

node_realtime_ui -->|"captures audio"| node_realtime_media
node_realtime_ui -->|"streams session"| node_realtime_backend
node_realtime_backend -->|"calls models"| node_model_services
node_screen_demo -->|"shares transport"| node_realtime_backend
node_longmem_app -->|"websocket"| node_longmem_backend
node_longmem_backend -->|"model calls"| node_model_services
node_adk_live_demo -->|"agent runtime"| node_model_services
node_adk_orchestrator -->|"retrieves docs"| node_file_search
node_adk_orchestrator -->|"generates answers"| node_model_services
node_rag_optimizer -->|"evaluates RAG"| node_model_services
node_rag_optimizer -->|"benchmarks retrieval"| node_file_search
node_workflow_editor -->|"executes graphs"| node_workflow_runtime
node_workflow_runtime -->|"invokes tools"| node_workflow_tools
node_workflow_runtime -->|"LLM steps"| node_model_services
node_agent_supervisor -->|"delegates work"| node_agent_tools
node_agent_supervisor -->|"multi-agent calls"| node_model_services
node_context_agent -->|"contextual chat"| node_model_services
node_mobile_client -->|"api calls"| node_mobile_backend
node_mobile_backend -->|"live inference"| node_model_services
node_browser_extension -->|"sidepanel chat"| node_model_services
node_story_pipeline -->|"creates assets"| node_media_generators
node_story_pipeline -->|"orchestrates generation"| node_model_services
node_media_generators -->|"source transforms"| node_model_services

click node_realtime_ui "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/index.html"
click node_realtime_backend "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/main2.py"
click node_realtime_media "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/pcm-processor.js"
click node_screen_demo "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-screen/main.py"
click node_longmem_app "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-longmem/Frontend/src/App.tsx"
click node_longmem_backend "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-longmem/main-longmem.py"
click node_adk_live_demo "https://github.com/yeyu2/youtube_demos/blob/main/ADK-live-demo/adk-streaming-ws/app/main.py"
click node_adk_orchestrator "https://github.com/yeyu2/youtube_demos/blob/main/adk-rag/custom-rag-streaming-ws/rag_agent/orchestrator.py"
click node_file_search "https://github.com/yeyu2/youtube_demos/blob/main/adk-rag/custom-rag-streaming-ws/rag_agent/file_search_tool.py"
click node_rag_optimizer "https://github.com/yeyu2/youtube_demos/blob/main/auto-rag-optimizer/orchestrator.py"
click node_workflow_editor "https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/app/page.tsx"
click node_workflow_runtime "https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/lib/workflow/executor.ts"
click node_workflow_tools "https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/lib/tools/index.ts"
click node_agent_supervisor "https://github.com/yeyu2/youtube_demos/blob/main/CrewAI/crewai_orche.py"
click node_agent_tools "https://github.com/yeyu2/youtube_demos/blob/main/CrewAI/crewai_tools.py"
click node_context_agent "https://github.com/yeyu2/youtube_demos/blob/main/context-aware/context_demo/agent.py"
click node_mobile_client "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-android/Android/GeminiLiveDemo/app/src/main/java/com/example/geminilivedemo/MainActivity.kt"
click node_mobile_backend "https://github.com/yeyu2/youtube_demos/blob/main/gemini20-android/Backend/main_for_mobile.py"
click node_browser_extension "https://github.com/yeyu2/youtube_demos/blob/main/GeminiChrome/background.js"
click node_story_pipeline "https://github.com/yeyu2/youtube_demos/blob/main/Storybook-Gen/src/orchestrator.py"
click node_media_generators "https://github.com/yeyu2/youtube_demos/blob/main/Genai-processors/blog_image_generator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_realtime_ui,node_realtime_backend,node_realtime_media,node_screen_demo,node_longmem_app,node_longmem_backend,node_adk_live_demo toneBlue
class node_agent_supervisor,node_agent_tools,node_context_agent toneAmber
class node_adk_orchestrator,node_file_search,node_rag_optimizer toneMint
class node_workflow_editor,node_workflow_runtime,node_workflow_tools toneRose
class node_story_pipeline,node_media_generators toneIndigo
class node_mobile_client,node_mobile_backend,node_browser_extension toneTeal
class node_model_services toneNeutral
```

## Components

### Realtime multimodal

Browser, mobile, and desktop demos for live audio/video/screen sessions

- [Realtime UIs](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/index.html): demo suite · Browser and desktop frontends that capture mic, screen, and chat input · `gemini20-realtime/index.html`
- [Session backend](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/main2.py): python websocket backend · Coordinates live sessions and streams model responses · `gemini20-realtime/main2.py`
- [Audio worklets](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-realtime/pcm-processor.js): media transport · PCM capture/playback and browser audio processing · `gemini20-realtime/pcm-processor.js`
- [Screen share demo](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-screen/main.py): multimodal demo · Realtime screen-capture variant with backend coordination · `gemini20-screen/main.py`
- [Long memory app](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-longmem/Frontend/src/App.tsx): stateful demo · React/Vite client with websocket, chat, and screen-share memory flow · `gemini20-longmem/Frontend/src/App.tsx`
- [Memory backend](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-longmem/main-longmem.py): python backend · Backend entrypoint for longer-lived session state and responses · `gemini20-longmem/main-longmem.py`
- [ADK live demo](https://github.com/yeyu2/youtube_demos/blob/main/ADK-live-demo/adk-streaming-ws/app/main.py): adk streaming app · Streaming demo with specialist agents and browser audio UI · `ADK-live-demo/adk-streaming-ws/app/main.py`

### Agent orchestration

Multi-agent demos, tool calling, and supervisor patterns

- [Agent supervisor](https://github.com/yeyu2/youtube_demos/blob/main/CrewAI/crewai_orche.py): orchestrator · Representative multi-agent control flow across CrewAI, AutoGen, and ADK demos · `CrewAI/crewai_orche.py`
- [Tools layer](https://github.com/yeyu2/youtube_demos/blob/main/CrewAI/crewai_tools.py): tool modules · Search, retrieval, file, and structured-output tools used by agent demos · `CrewAI/crewai_tools.py`
- [Context agent](https://github.com/yeyu2/youtube_demos/blob/main/context-aware/context_demo/agent.py): stateful agent · Maintains conversation context over time with helper tools · `context-aware/context_demo/agent.py`

### Retrieval apps

RAG pipelines, context stores, and retrieval optimization

- [RAG orchestrator](https://github.com/yeyu2/youtube_demos/blob/main/adk-rag/custom-rag-streaming-ws/rag_agent/orchestrator.py): agent coordinator · Routes retrieval requests and streams answers in the ADK RAG demo · `adk-rag/custom-rag-streaming-ws/rag_agent/orchestrator.py`
- [File search](https://github.com/yeyu2/youtube_demos/blob/main/adk-rag/custom-rag-streaming-ws/rag_agent/file_search_tool.py): retrieval tool · Upload, index, and search files for query-time retrieval · `adk-rag/custom-rag-streaming-ws/rag_agent/file_search_tool.py`
- [RAG optimizer](https://github.com/yeyu2/youtube_demos/blob/main/auto-rag-optimizer/orchestrator.py): experiment pipeline · Closed-loop evaluator, runner, and visualizer for tuning retrieval settings · `auto-rag-optimizer/orchestrator.py`

### Workflow builder

Visual workflow editor and execution runtime

- [Workflow app](https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/app/page.tsx): nextjs app · Visual workflow editor, chat UI, and workflow pages · `Workflow-builder/simple-ai-workflow/app/page.tsx`
- [Workflow runtime](https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/lib/workflow/executor.ts): executor · Validates and executes workflow graphs and messages · `Workflow-builder/simple-ai-workflow/lib/workflow/executor.ts`
- [Search tools](https://github.com/yeyu2/youtube_demos/blob/main/Workflow-builder/simple-ai-workflow/lib/tools/index.ts): tool adapters · External search and knowledge tools used by workflows · `Workflow-builder/simple-ai-workflow/lib/tools/index.ts`

### Content pipelines

Document, story, and media generation pipelines

- [Story pipeline](https://github.com/yeyu2/youtube_demos/blob/main/Storybook-Gen/src/orchestrator.py): content generation · Orchestrates storybook creation, image generation, PDF building, and cost tracking · `Storybook-Gen/src/orchestrator.py`
- [Media generators](https://github.com/yeyu2/youtube_demos/blob/main/Genai-processors/blog_image_generator.py): generation tools · Blog-image and podcast-style generators from source material · `Genai-processors/blog_image_generator.py`

### Platform clients

Mobile, browser-extension, and alternate UI shells

- [Android client](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-android/Android/GeminiLiveDemo/app/src/main/java/com/example/geminilivedemo/MainActivity.kt): mobile frontend · Android Gemini Live demo paired with a mobile backend entrypoint · `gemini20-android/Android/GeminiLiveDemo/app/src/main/java/com/example/geminilivedemo/MainActivity.kt`
- [Mobile backend](https://github.com/yeyu2/youtube_demos/blob/main/gemini20-android/Backend/main_for_mobile.py): python backend · Backend entrypoint used by the Android live demo · `gemini20-android/Backend/main_for_mobile.py`
- [Chrome extension](https://github.com/yeyu2/youtube_demos/blob/main/GeminiChrome/background.js): extension ui · Content script, background, and sidepanel for Gemini Live in-browser · `GeminiChrome/background.js`

### Other components

- **Model services**: external ai providers · Gemini, OpenAI, ADK, CrewAI, LiveKit, OpenRouter, Fireworks, Whisper, Kokoro, and local models

## Connections

- Realtime UIs → Audio worklets: captures audio · Browser UI uses PCM worklets and players for mic and speaker streaming
- Realtime UIs → Session backend: streams session · Frontend sends live media and receives streamed responses
- Session backend → Model services: calls models · Session orchestration delegates inference to external AI providers
- Screen share demo → Session backend: shares transport · Screen-demo variant follows the same live session pattern
- Long memory app → Memory backend: websocket · Stateful client connects to long-memory backend over realtime transport
- Memory backend → Model services: model calls · Backend forwards prompts, memory, and screen-share context to providers
- ADK live demo → Model services: agent runtime · Live demo is driven by ADK-based agent orchestration
- RAG orchestrator → File search: retrieves docs · Query-time retrieval is handled by file upload and search tools
- RAG orchestrator → Model services: generates answers · Orchestrator combines retrieved context with model responses
- RAG optimizer → Model services: evaluates RAG · Optimizer runs experiments against model-backed retrieval configurations
- RAG optimizer → File search: benchmarks retrieval · Experiment loop scores retrieval settings and stores best config
- Workflow app → Workflow runtime: executes graphs · Editor-defined workflows flow into the runtime executor
- Workflow runtime → Search tools: invokes tools · Workflow nodes call external search and knowledge adapters
- Workflow runtime → Model services: LLM steps · Workflow execution can route steps through model providers
- Agent supervisor → Tools layer: delegates work · Supervisor agents hand tasks to specialized tools
- Agent supervisor → Model services: multi-agent calls · CrewAI, AutoGen, and related demos use provider-backed agents
- Context agent → Model services: contextual chat · Context-aware demos maintain state around provider calls
- Android client → Mobile backend: api calls · Android frontend relies on a backend entrypoint for orchestration
- Mobile backend → Model services: live inference · Mobile backend bridges the app to model providers
- Chrome extension → Model services: sidepanel chat · Extension UI talks to live model/session services
- Story pipeline → Media generators: creates assets · Storybook pipeline stages content through image and PDF generation
- Story pipeline → Model services: orchestrates generation · Pipeline uses model providers for planning and narrative generation
- Media generators → Model services: source transforms · Generators depend on providers for image and text synthesis
