# msilver22/agentic_mbd architecture

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

- Interactive diagram: https://gitdiagram.com/msilver22/agentic_mbd
- Repository: https://github.com/msilver22/agentic_mbd

## Overview

##### Project type and purpose
- This is a full-stack AI-agent orchestration project. It provides three “agents” (Feed Builder, Social Prompter, and a combined MBD Agent that includes a small-talk capability) implemented in Python, exposed via Streamlit UIs, and wired together using LangGraph workflows. It integrates with the Farcaster social network (via the mbd API), Groq for LLM inference, and Langfuse for observability.

##### File structure
- Top-level files and folders:
- `.devcontainer/` – Docker/devcontainer definition for reproducible environments
- `requirements.txt` – Python dependencies: LangGraph, Groq SDK, mbd client, Streamlit, Langfuse, etc.
- `src/` – core business logic implementing each agent (`feed_builder.py`, `social_prompter.py`, `mbd_agent.py`, and a v2 of mbd_agent)
- `streamlit/` – one Streamlit script per agent to serve a browser-based UI

##### Readme insights
- The README describes three LangGraph-based agents with contextual memory, tool-enabled LLM calls, and real-time data fetch from Farcaster.
- It also highlights the use of Groq LLMs for certain nodes (summarization, planning, tool execution) and Langfuse for tracing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser (User)"]:::client
    end

    %% Presentation/API Layer
    subgraph "Presentation/API Layer"
        SB_UI["Streamlit: feed_builder.py"]:::api
        SP_UI["Streamlit: social_prompter.py"]:::api
        MBD_UI_v1["Streamlit: mbd_agent.py"]:::api
        MBD_UI_v2["Streamlit: mbd_agent_v2.py"]:::api
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        subgraph "LangGraph Workflow"
            Planner["Planner Node"]:::orchestration
            Memory["Memory Node (Context Summary)"]:::memory
            Planner -->|routes to| Memory
            subgraph "Agent Subgraphs"
                FB_Sub["Feed Builder Subgraph"]:::orchestration
                SP_Sub["Social Prompter Subgraph"]:::orchestration
                MBD_Sub["MBD Agent + SmallTalk Subgraph"]:::orchestration
            end
            Planner -->|fan-out| FB_Sub
            Planner -->|fan-out| SP_Sub
            Planner -->|fan-out| MBD_Sub
        end
    end

    %% Core Agent Modules
    subgraph "Core Agent Modules"
        FB_Core["src/feed_builder.py"]:::core
        SP_Core["src/social_prompter.py"]:::core
        MBD_Core["src/mbd_agent.py"]:::core
        MBDv2_Core["src/mbd_agent_v2.py"]:::core
    end

    %% External Services
    subgraph "External Services"
        mbdAPI["mbd API (Farcaster)"]:::external
        Groq["Groq Inference Endpoint"]:::external
        Langfuse["Langfuse Trace Collector"]:::external
    end

    %% Relationships
    Browser -->|interacts via HTTP/WebSocket| SB_UI
    Browser -->|interacts via HTTP/WebSocket| SP_UI
    Browser -->|interacts via HTTP/WebSocket| MBD_UI_v1
    Browser -->|interacts via HTTP/WebSocket| MBD_UI_v2

    SB_UI -->|calls| FB_Core
    SP_UI -->|calls| SP_Core
    MBD_UI_v1 -->|calls| MBD_Core
    MBD_UI_v2 -->|calls| MBDv2_Core

    FB_Core -->|starts workflow| Planner
    SP_Core -->|starts workflow| Planner
    MBD_Core -->|starts workflow| Planner
    MBDv2_Core -->|starts workflow| Planner

    %% Workflow nodes interactions with services
    Memory -->|stores context| Memory
    Memory -->|trace| Langfuse

    FB_Sub -->|LLM: summarization| Groq
    FB_Sub -->|tool call| mbdAPI
    FB_Sub -->|trace| Langfuse

    SP_Sub -->|LLM: planning| Groq
    SP_Sub -->|tool call| mbdAPI
    SP_Sub -->|trace| Langfuse

    MBD_Sub -->|LLM: small-talk| Groq
    MBD_Sub -->|tool call| mbdAPI
    MBD_Sub -->|trace| Langfuse

    %% Response back to UI
    Planner -->|returns Markdown output| SB_UI
    Planner -->|returns Markdown output| SP_UI
    Planner -->|returns Markdown output| MBD_UI_v1
    Planner -->|returns Markdown output| MBD_UI_v2
    SB_UI -->|renders| Browser
    SP_UI -->|renders| Browser
    MBD_UI_v1 -->|renders| Browser
    MBD_UI_v2 -->|renders| Browser

    %% Click Events
    click SB_UI "https://github.com/msilver22/agentic_mbd/blob/main/streamlit/feed_builder.py"
    click SP_UI "https://github.com/msilver22/agentic_mbd/blob/main/streamlit/social_prompter.py"
    click MBD_UI_v1 "https://github.com/msilver22/agentic_mbd/blob/main/streamlit/mbd_agent.py"
    click MBD_UI_v2 "https://github.com/msilver22/agentic_mbd/blob/main/streamlit/mbd_agent_v2.py"
    click FB_Core "https://github.com/msilver22/agentic_mbd/blob/main/src/feed_builder.py"
    click SP_Core "https://github.com/msilver22/agentic_mbd/blob/main/src/social_prompter.py"
    click MBD_Core "https://github.com/msilver22/agentic_mbd/blob/main/src/mbd_agent.py"
    click MBDv2_Core "https://github.com/msilver22/agentic_mbd/blob/main/src/mbd_agent_v2.py"
    click GraphFB "https://github.com/msilver22/agentic_mbd/blob/main/graphs/feed_builder.png"
    click GraphSP "https://github.com/msilver22/agentic_mbd/blob/main/graphs/social_prompter.png"
    click GraphMBD "https://github.com/msilver22/agentic_mbd/blob/main/graphs/mbd_agent.png"
    click Requirements "https://github.com/msilver22/agentic_mbd/blob/main/requirements.txt"
    click Dev "https://github.com/msilver22/agentic_mbd/blob/main/ .devcontainer/devcontainer.json"
    click Readme "https://github.com/msilver22/agentic_mbd/blob/main/README.md"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#0366D6,color:#0366D6
    classDef api fill:#CCE5FF,stroke:#0284C7,color:#0284C7
    classDef orchestration fill:#DFFFE0,stroke:#28A745,color:#28A745
    classDef core fill:#E8E8E8,stroke:#6C757D,color:#495057
    classDef external fill:#FFF4E5,stroke:#D97706,color:#C2410C
    classDef memory fill:#FFD6D6,stroke:#D63333,color:#D63333
```
