# mihirkothari04/multi-agent-content-creator architecture

> Architecture diagram of the GitHub repository mihirkothari04/multi-agent-content-creator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mihirkothari04/multi-agent-content-creator
- Repository: https://github.com/mihirkothari04/multi-agent-content-creator

## Overview

##### Project Type and Purpose
- This is an open-source, modular AI pipeline tool (built with CrewAI) that automates end-to-end content creation for social media and blogs.
- It offers both a scheduled batch pipeline (via `src/main.py`) and an on-demand HTTP API (`src/api.py`).

##### File Structure
- Top-level configuration:
– `config/agents/*.yaml` (agent behavior settings)
– `config/pipeline.yaml` (pipeline sequencing)
– `docker-compose.yml` + `Dockerfile` for containerized deployment
- Source code layout:
– `src/agents/` (TrendResearcher, ContentWriter, StyleEditor, ImageAgent, SchedulerAgent, ReviewerNotifier)
– `src/utils/` (config_loader, file_manager, logger)
– `src/main.py` (CLI-driven pipeline runner)
– `src/api.py` (Flask-style HTTP server for on-demand triggers)
- Tests: `tests/` for unit-testing agents and pipeline logic.

##### Extract Architectural Insights from the README
- Modular “Agents” that each perform a discrete AI task
- A “Pipeline” orchestrator that invokes agents in sequence
- “Tools” (external services: OpenAI, Serper, image-generation API, notification service)
- Human-in-the-loop review step via ReviewerNotifierAgent
- Docker-based deployment and cron scheduling for automated runs

##### Main Components and Their Roles
A. Configuration Layer
- YAML Config Files → loaded by `src/utils/config_loader.py`
B. Orchestration Layer
- SchedulerAgent + Cron (or Docker Compose schedule) → triggers pipeline
- Pipeline Engine (`src/main.py`) → reads pipeline.yaml, invokes agents
C. Agent Layer (Core Workers)
1. TrendResearcherAgent → fetch trends via external search API
2. ContentWriterAgent → generate draft via language model
3. StyleEditorAgent → refine tone via language model
4. ImageAgent → generate visuals via image-API
5. ReviewerNotifierAgent → send notifications for human review
D. API Layer
- HTTP Server (`src/api.py`) → exposes `/trigger` endpoint for manual runs
E. Integration Layer (External Services)
- OpenAI API, Serper Search, Image-generation service, Notification service (email/slack)
F. Utility Layer
- Logger (`src/utils/logger.py`), File Manager (`src/utils/file_manager.py`)
G. Deployment Layer
- Dockerfile, docker-compose.yml, environment variables (`.env`)

##### Relationships and Data Flows
1. At startup, the **Configuration Layer** loads all YAML files.
2. The **Orchestration Layer** (SchedulerAgent or HTTP API) triggers the **Pipeline Engine**.
3. The **Pipeline Engine** invokes each **Agent** in the order defined in `pipeline.yaml`, passing outputs (e.g., research data → draft text → styled text → image artifacts).
4. When content is ready, the **ReviewerNotifierAgent** calls the Notification Service and awaits human feedback.
5. Approved content is stored (via File Manager) or handed off to a publication system.
6. All components log activity centrally via the **Logger** utility.

##### Architectural Patterns and Principles
- Pipeline Pattern: modular, sequential data processing
- Agent-based Decomposition: each AI agent encapsulates a single responsibility
- Configuration-driven Behavior: YAML files determine pipeline flow and agent parameters
- Adapter/Facade Pattern for external service integrations
- Human-in-the-loop pattern for quality control

##### Technology and Frameworks
- Python 3.x
- CrewAI agent framework
- Flask (or similar) for the HTTP API
- PyYAML for config loading
- Docker & Docker Compose for containerization
- Cron (or Docker-based scheduler) for periodic execution
- Logging library (e.g., Python’s `logging`)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Layer
    subgraph "Configuration Layer"
        direction TB
        confAgents["config/agents/*.yaml"]:::config
        confPipeline["config/pipeline.yaml"]:::config
    end

    %% Utility Layer
    subgraph "Utility Layer"
        direction TB
        configLoader["Config Loader"]:::util
        fileManager["File Manager"]:::util
        logger["Logger"]:::util
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        schedulerAgent["SchedulerAgent"]:::orchestration
        pipelineEngine["Pipeline Engine (CLI)"]:::orchestration
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        apiServer["HTTP API /trigger"]:::api
    end

    %% Agent Layer
    subgraph "Agent Layer"
        direction TB
        baseAgent["Agent Base Class"]:::agents
        trendResearcher["TrendResearcherAgent"]:::agents
        contentWriter["ContentWriterAgent"]:::agents
        styleEditor["StyleEditorAgent"]:::agents
        imageAgent["ImageAgent"]:::agents
        reviewerNotifier["ReviewerNotifierAgent"]:::agents
    end

    %% Integration Layer
    subgraph "External Services"
        direction TB
        openai["OpenAI API"]:::external
        serper["Serper Search"]:::external
        imageService["Image Generation Service"]:::external
        notificationService["Notification Service"]:::external
        humanReviewer["Human Reviewer"]:::external
    end

    %% Deployment Layer
    subgraph "Deployment"
        direction TB
        dockerfile["Dockerfile"]:::deployment
        compose["docker-compose.yml"]:::deployment
    end

    %% Tests
    subgraph "Tests"
        direction TB
        testAgents["tests/test_agents.py"]:::tests
        testPipeline["tests/test_pipeline.py"]:::tests
    end

    %% Connections
    confAgents -->|loads| configLoader
    confPipeline -->|loads| configLoader
    configLoader -->|"config_data"| pipelineEngine
    configLoader -->|"config_data"| apiServer

    schedulerAgent -->|"cron trigger"| pipelineEngine
    apiServer -->|"HTTP trigger"| pipelineEngine

    pipelineEngine -->|"research_data"| trendResearcher
    trendResearcher -->|"research_data"| contentWriter
    contentWriter -->|"draft_text"| styleEditor
    styleEditor -->|"edited_text"| imageAgent
    imageAgent -->|"image_asset"| reviewerNotifier
    reviewerNotifier -->|"notification_payload"| notificationService
    notificationService -->|"human_review"| humanReviewer
    humanReviewer -->|"approval"| fileManager

    pipelineEngine -->|logs| logger
    trendResearcher -->|logs| logger
    contentWriter -->|logs| logger
    styleEditor -->|logs| logger
    imageAgent -->|logs| logger
    reviewerNotifier -->|logs| logger

    %% Deployment flows
    dockerfile --> compose
    compose --> schedulerAgent
    compose --> apiServer

    %% Tests dependencies
    testAgents --> trendResearcher
    testAgents --> contentWriter
    testAgents --> styleEditor
    testAgents --> imageAgent
    testAgents --> reviewerNotifier
    testPipeline --> pipelineEngine

    %% Click Events
    click confAgents "https://github.com/mihirkothari04/multi-agent-content-creator/tree/main/config/agents/"
    click confPipeline "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/config/pipeline.yaml"
    click schedulerAgent "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/scheduler_agent.py"
    click pipelineEngine "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/main.py"
    click apiServer "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/api.py"
    click configLoader "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/utils/config_loader.py"
    click fileManager "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/utils/file_manager.py"
    click logger "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/utils/logger.py"
    click trendResearcher "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/trend_researcher.py"
    click contentWriter "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/content_writer.py"
    click styleEditor "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/style_editor.py"
    click imageAgent "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/image_agent.py"
    click reviewerNotifier "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/reviewer_notifier.py"
    click baseAgent "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/src/agents/base_agent.py"
    click dockerfile "https://github.com/mihirkothari04/multi-agent-content-creator/tree/main/Dockerfile"
    click compose "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/docker-compose.yml"
    click testAgents "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/tests/test_agents.py"
    click testPipeline "https://github.com/mihirkothari04/multi-agent-content-creator/blob/main/tests/test_pipeline.py"

    %% Styles
    classDef config fill:#D0E8FF,stroke:#0055AA,color:#003366
    classDef orchestration fill:#E8D0FF,stroke:#5500AA,color:#330033
    classDef agents fill:#D0FFD0,stroke:#00AA00,color:#006600
    classDef api fill:#FFE0B2,stroke:#EE7A00,color:#663300
    classDef external fill:#FFD0D0,stroke:#AA0000,color:#660000
    classDef util fill:#F0F0F0,stroke:#999999,color:#333333
    classDef deployment fill:#F5E0C7,stroke:#8B4513,color:#5A2D0C
    classDef tests fill:#EEEFFF,stroke:#6666AA,color:#333366
```
