# tusharbecoding/multi-youtube-agent architecture

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

- Interactive diagram: https://gitdiagram.com/tusharbecoding/multi-youtube-agent
- Repository: https://github.com/tusharbecoding/multi-youtube-agent

## Overview

1. **Overall shape**
   - This repo is a small, single-purpose AI workflow application built around **CrewAI**.
   - The architecture is a **two-stage sequential pipeline**: first research, then writing.

2. **Entry point and orchestration**
   - `crew.py` is the runtime entry point.
   - It assembles the agents, tasks, and tools into a CrewAI execution plan and kicks off the workflow.
   - This file is the main control boundary between configuration and execution.

3. **Agent layer**
   - `agents.py` defines two specialized LLM agents:
     - **Blog Researcher**: focuses on finding and analyzing YouTube content.
     - **Blog Writer**: turns research into a polished blog post.
   - The separation is important: one agent gathers facts, the other synthesizes narrative.

4. **Task layer**
   - `tasks.py` defines the work each agent performs and the expected outputs.
   - The tasks likely encode the handoff between stages: research output becomes the writer’s input.
   - This is the main point where the pipeline enforces order and output structure.

5. **Tooling boundary**
   - `tools.py` configures the external search capability, specifically a **YouTube channel search tool**.
   - This is the repo’s only explicit non-LLM data source.
   - The tool is bound to a channel handle, so the research scope is constrained to a chosen YouTube source.

6. **External services**
   - The system depends on:
     - **OpenAI models** for generation and reasoning
     - **CrewAI** for orchestration
     - **crewai-tools** for YouTube integration
   - The OpenAI API key is provided through environment configuration, so model access is externalized from code.

7. **Data flow**
   - Input begins as a **topic** configured in `crew.py`.
   - The researcher agent queries the YouTube channel via the tool, extracts relevant information, and produces structured research.
   - That research is passed to the writer agent, which generates the final blog post in Markdown.
   - The output is written to `blog_post.md`.

8. **Control flow**
   - The execution model is **sequential**, not parallel.
   - The writer depends on the researcher’s output, so the system behaves like a simple two-step assembly line.
   - The README also indicates **memory and caching** are enabled, which means repeated runs may retain context and reduce redundant calls.

9. **Configuration boundaries**
   - There are three key customization points:
     - topic selection in `crew.py`
     - agent behavior in `agents.py`
     - YouTube channel target in `tools.py`
   - This keeps the repo modular even though it is small.

10. **Runtime and packaging**
   - The project is a Python application managed through `requirements.txt`.
   - Runtime dependencies are minimal and centered on AI orchestration rather than a web server, database, or job queue.
   - There is no evidence of persistent backend state beyond the generated markdown file.

11. **Output boundary**
   - The final artifact is a human-readable **Markdown blog post**.
   - That means the system’s primary deliverable is content generation, not an API response or UI rendering.

12. **How to diagram it**
   - A good architecture diagram would show:
     - a topic/config input
     - `crew.py` as the orchestrator
     - `agents.py` split into researcher and writer
     - `tools.py` connecting the researcher to YouTube
     - OpenAI as the model backend
     - `tasks.py` defining the handoff between stages
     - `blog_post.md` as the final output

Main entry points: [`crew.py`](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/crew.py) (Crew entry), [`tasks.py`](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py) (Write task), [`agents.py`](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py) (Agents), [`tools.py`](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tools.py) (YouTube search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core pipeline"]
  node_crew_py["Crew entry<br/>orchestrator<br/>[crew.py]"]
  node_topic_config["Topic config<br/>input<br/>[crew.py]"]
  node_agents_py["Agents<br/>agent defs<br/>[agents.py]"]
  node_researcher(("Researcher<br/>LLM agent<br/>[agents.py]"))
  node_writer(("Writer<br/>LLM agent<br/>[agents.py]"))
  node_tasks_py["Tasks<br/>task defs<br/>[tasks.py]"]
  node_research_task["Research task<br/>workflow step<br/>[tasks.py]"]
  node_write_task["Write task<br/>workflow step<br/>[tasks.py]"]
  node_tools_py["Tools<br/>tool config<br/>[tools.py]"]
end

subgraph group_external["External services"]
  node_youtube_tool[("YouTube search<br/>external tool<br/>[tools.py]")]
  node_crewai{{"CrewAI<br/>orchestration runtime"}}
  node_openai{{"OpenAI<br/>model backend"}}
end

subgraph group_output["Output"]
  node_blog_md["Blog post<br/>generated artifact"]
end

node_topic_config -->|"configure"| node_crew_py
node_crew_py -->|"execute"| node_crewai
node_crew_py -->|"load"| node_agents_py
node_crew_py -->|"load"| node_tasks_py
node_crew_py -->|"load"| node_tools_py
node_agents_py -->|"defines"| node_researcher
node_agents_py -->|"defines"| node_writer
node_tasks_py -->|"defines"| node_research_task
node_tasks_py -->|"defines"| node_write_task
node_tools_py -->|"binds"| node_youtube_tool
node_researcher -->|"uses"| node_openai
node_writer -->|"uses"| node_openai
node_researcher -->|"queries"| node_youtube_tool
node_youtube_tool -->|"feeds"| node_write_task
node_research_task -->|"handoff"| node_write_task
node_write_task -->|"produces"| node_blog_md

click node_crew_py "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/crew.py"
click node_topic_config "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/crew.py"
click node_agents_py "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py"
click node_researcher "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py"
click node_writer "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py"
click node_tasks_py "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py"
click node_research_task "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py"
click node_write_task "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py"
click node_tools_py "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tools.py"
click node_youtube_tool "https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tools.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_crew_py,node_topic_config,node_agents_py,node_researcher,node_writer,node_tasks_py,node_research_task,node_write_task,node_tools_py toneBlue
class node_youtube_tool,node_crewai,node_openai toneAmber
class node_blog_md toneMint
```

## Components

### Core pipeline

Entry point, agents, tasks, and orchestration for the two-stage workflow.

- [Crew entry](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/crew.py): orchestrator · Runtime entry point that assembles the workflow and starts execution. · `crew.py`
- [Topic config](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/crew.py): input · The topic or run-specific focus selected for the blog workflow. · `crew.py`
- [Agents](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py): agent defs · Defines the specialized researcher and writer agents. · `agents.py`
- [Researcher](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py): LLM agent · Finds and analyzes YouTube content relevant to the topic. · `agents.py`
- [Writer](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/agents.py): LLM agent · Synthesizes research into a polished blog post. · `agents.py`
- [Tasks](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py): task defs · Defines the ordered work units and the handoff between stages. · `tasks.py`
- [Research task](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py): workflow step · Collects and structures research for the writer to consume. · `tasks.py`
- [Write task](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tasks.py): workflow step · Transforms research into the final Markdown article. · `tasks.py`
- [Tools](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tools.py): tool config · Configures the YouTube search capability used by the researcher. · `tools.py`

### External services

Model and data-source boundaries used by the workflow.

- [YouTube search](https://github.com/tusharbecoding/multi-youtube-agent/blob/main/tools.py): external tool · Channel-scoped search tool used to gather source material. · `tools.py`
- **CrewAI**: orchestration runtime · Framework that executes the sequential agent task plan.
- **OpenAI**: model backend · LLM provider used by both agents for reasoning and generation.

### Output

Generated artifact produced by the run.

- **Blog post**: generated artifact · Final Markdown output written by the workflow.

## Connections

- Topic config → Crew entry: configure · Run topic feeds the orchestration entry point.
- Crew entry → CrewAI: execute · Entry point hands the assembled plan to CrewAI.
- Crew entry → Agents: load · Orchestrator loads the agent definitions.
- Crew entry → Tasks: load · Orchestrator loads the task definitions.
- Crew entry → Tools: load · Orchestrator loads the tool configuration.
- Agents → Researcher: defines · Agent module defines the research specialist.
- Agents → Writer: defines · Agent module defines the writing specialist.
- Tasks → Research task: defines · Task module defines the research step.
- Tasks → Write task: defines · Task module defines the writing step.
- Tools → YouTube search: binds · Tool module configures the YouTube source access.
- Researcher → OpenAI: uses · Research agent relies on the model backend.
- Writer → OpenAI: uses · Writer agent relies on the model backend.
- Researcher → YouTube search: queries · Research agent gathers source material through the YouTube tool.
- YouTube search → Write task: feeds · Research output becomes input to the writing stage.
- Research task → Write task: handoff · Tasks enforce the sequential flow from research to writing.
- Write task → Blog post: produces · Writing stage emits the final Markdown artifact.
