# neural-maze/agentic-patterns-course architecture

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

- Interactive diagram: https://gitdiagram.com/neural-maze/agentic-patterns-course
- Repository: https://github.com/neural-maze/agentic-patterns-course

## Overview

##### Project Type and Purpose
- This is an open-source Python library (“agentic-patterns”) implementing four LLM agentic patterns (Reflection, Tool, Planning/ReAct, Multiagent) using direct API calls to Groq.
- It’s intended as an educational framework: to teach and experiment with these patterns via notebooks or direct code, not as a deployed web service.

##### File Structure Analysis
- Top level:
- notebooks/ – Jupyter notebooks demonstrating each pattern.
- src/agentic_patterns/ – the library code, split into subpackages:
– reflection_pattern/ (ReflectionAgent)
– tool_pattern/ (ToolAgent, Tool decorator)
– planning_pattern/ (ReactAgent extends ToolAgent)
– multiagent_pattern/ (Agent, Crew orchestrating DAG)
– utils/ (completions, extraction, logging helpers)
- config/build: pyproject.toml, .env.example, GitHub workflows.

##### Key Insights from README
- Four patterns each encapsulated by a Python Agent class.
- Agents internally call the Groq LLM API (via utils/completions).
- Tools are user-defined Python functions decorated with @tool; ToolAgent and ReactAgent invoke them.
- Crew builds a DAG of Agents, plots it, then executes steps.
- Notebooks drive usage and learning.

##### Main Components
a. User Layer
– Notebooks or Python scripts that import agentic_patterns.
b. Agentic-Patterns Library
- reflection_pattern: ReflectionAgent
- tool_pattern: ToolAgent + @tool decorator + Tool class
- planning_pattern: ReactAgent (planning + tools)
- multiagent_pattern: Agent, Crew (DAG orchestration)
- utils: CompletionsClient (Groq API wrapper), Extraction, Logging
c. External Services
– Groq LLM API
– Optional external APIs (e.g. Hacker News, Wikipedia, Wolfram Alpha) used by Tools
d. File System / Persistence
– Local files (e.g. writing output to .txt in multiagent pattern)

##### Relationships and Data Flows
- Within Library: Agents call utils.completions → Groq API → LLM responses.
- Crew: resolves Agent dependencies → sequential/parallel invocation → file outputs.

##### Highlighted Architectural Patterns
- Modular package-per-pattern (separation of concerns).
- Strategy pattern: each Agent encapsulates prompt + behavior.
- Decorator pattern: @tool wraps user functions into callable tools.
- DAG orchestration (Multiagent): similar to workflow engines like Airflow.
- Single external dependency: Groq API, injected via utils/completions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% User Layer
    subgraph "User Layer" 
        direction TB
        NB1["reflection_pattern.ipynb"] 
        NB2["tool_pattern.ipynb"] 
        NB3["planning_pattern.ipynb"] 
        NB4["multiagent_pattern.ipynb"] 
    end

    %% Library Package
    subgraph "agentic_patterns Package"
        direction TB
        subgraph "Core Patterns"
            direction TB
            RA["ReflectionAgent"]:::core
            TA["ToolAgent"]:::core
            REA["ReactAgent"]:::core
            A["Agent (base)"]:::core
            CR["Crew"]:::core
        end
        subgraph "Utils"
            direction TB
            CC["CompletionsClient"]:::util
            EX["Extraction"]:::util
            LG["Logging"]:::util
        end
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        GO["Groq LLM API"]:::external
        EXT["External APIs"]:::external
    end

    %% File System
    FS["Local File System"]:::fs

    %% Connections User to Library
    NB1 -->|"instantiate/run"| RA
    NB2 -->|"instantiate/run"| TA
    NB3 -->|"instantiate/run"| REA
    NB4 -->|"instantiate/run"| CR

    %% Agents to Utils and External
    RA -->|"POST prompt"| CC
    TA -->|"POST prompt"| CC
    REA -->|"POST prompt"| CC
    A -->|"used by Crew"| CR

    TA -->|"CALL_TOOL"| EXT
    REA -->|"CALL_TOOL"| EXT

    CC -->|"request"| GO
    CR -->|"write file"| FS

    %% Click Events
    click RA "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/reflection_pattern/reflection_agent.py"
    click TA "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/tool_pattern/tool_agent.py"
    click REA "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/planning_pattern/react_agent.py"
    click A "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/multiagent_pattern/agent.py"
    click CR "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/multiagent_pattern/crew.py"
    click CC "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/utils/completions.py"
    click EX "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/utils/extraction.py"
    click LG "https://github.com/neural-maze/agentic-patterns-course/blob/main/src/agentic_patterns/utils/logging.py"
    click NB1 "https://github.com/neural-maze/agentic-patterns-course/blob/main/notebooks/reflection_pattern.ipynb"
    click NB2 "https://github.com/neural-maze/agentic-patterns-course/blob/main/notebooks/tool_pattern.ipynb"
    click NB3 "https://github.com/neural-maze/agentic-patterns-course/blob/main/notebooks/planning_pattern.ipynb"
    click NB4 "https://github.com/neural-maze/agentic-patterns-course/blob/main/notebooks/multiagent_pattern.ipynb"

    %% Styles
    classDef core fill:#e0f7fa,stroke:#006064
    classDef util fill:#e8f5e9,stroke:#1b5e20
    classDef external fill:#fff3e0,stroke:#e65100
    classDef fs fill:#eceff1,stroke:#455a64
    classDef default stroke-width:2px;font-family:Arial
```
