# automateyournetwork/netbox_react_agent architecture

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

- Interactive diagram: https://gitdiagram.com/automateyournetwork/netbox_react_agent
- Repository: https://github.com/automateyournetwork/netbox_react_agent

## Overview

##### Project Type and Purpose
- This is a self-contained, AI-driven network-management application.
- It exposes a chat-style UI (via Streamlit) that translates natural-language queries into CRUD calls against a NetBox instance.
- It can run in two modes:
- “Main” branch: calls out to the OpenAI API (ChatGPT/GPT-4o)
- “Ollama” branch: invokes a local LLM via Ollama

##### File Structure
- Top level
- docker-compose.yml: orchestrates containers, sets up environment variables (NetBox URL, token, OpenAI key)
- docker/Dockerfile: builds the Python/Streamlit image
- requirements.txt: Python dependencies (streamlit, langchain, openai, requests, etc.)
- scripts/startup.sh: container entrypoint, environment prep
- netbox_react_agent/
- netbox_react_agent.py: main application logic (Streamlit UI + ReAct orchestration)
- netbox_apis.json: static description of NetBox endpoints for dynamic tool selection
- README.md: high-level architecture, setup, branch differences

##### README for Additional Insights
- Key Components called out:
- NetBoxController — wrapper around NetBox REST API
- LangChain ReAct Agent — orchestrator for natural-language tools
- Streamlit Interface — web frontend
- External dependencies: NetBox API, OpenAI API or local Ollama LLM

a. Main Components
1) User/Browser (frontend client)
2) Streamlit Web App (Python container)
3) ReAct Agent (LangChain orchestration layer)
4) NetBoxController (tool for CRUD operations)
5) LLM Service
– External OpenAI API (cloud)
– or Ollama local LLM
6) NetBox API (external network-inventory service)
7) Docker/Docker-Compose (deployment layer)
b. Relationships & Data Flow
– The user issues a query in the browser → HTTP to Streamlit server
– Streamlit forwards the query to the ReAct Agent
– ReAct Agent may call:
- NetBoxController to fetch or modify data
- LLM Service to interpret or generate API calls
– NetBoxController issues REST calls to the NetBox API, returns JSON
– The Agent composes a response, hands it back to the Streamlit UI
– Streamlit renders the result in the browser
– Docker-Compose ensures the container is configured with environment variables and port mapping
c. Architectural Patterns & Principles
– Single-page web UI and backend logic combined in one process (Streamlit)
– ReAct pattern via LangChain: dynamic tool selection + LLM reasoning loop
– Clear separation of concerns: UI layer, orchestration layer, tool layer, external services
d. Key Technologies & Libraries
– Containerization: Docker, Docker-Compose
– Web UI: Streamlit
– LLM orchestration: LangChain ReAct Agent
– AI backends: OpenAI API or Ollama local LLM
– Network API client: NetBoxController (requests-based)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment Layer
    subgraph "Deployment Layer"
        dockerCompose["docker-compose.yml"]:::deploy
        dockerFile["Dockerfile"]:::deploy
        startupScript["startup.sh"]:::deploy
        requirements["requirements.txt"]:::deploy
        readme["README.md"]:::deploy
    end

    %% Application Container
    subgraph "Application Container"
        streamlit["Streamlit UI / Backend"]:::frontend
        agent["ReAct Agent"]:::logic
        controller["NetBoxController"]:::logic
        apiDefs["NetBox APIs (static)"]:::logic
    end

    %% External Services
    subgraph "External Services"
        openai["OpenAI API"]:::external
        ollama["Ollama LLM"]:::external
        netboxApi["NetBox API"]:::external
    end

    %% Data Flow
    Browser["User/Browser"]:::frontend -->|"HTTP Request"| streamlit
    streamlit -->|"forward query"| agent
    agent -->|"uses tool"| controller
    agent -->|"calls LLM"| openai
    agent -->|"calls LLM"| ollama
    controller -->|"REST JSON"| netboxApi
    openai -->|"response"| agent
    ollama -->|"response"| agent
    agent -->|"compose result"| streamlit
    streamlit -->|"render UI"| Browser

    %% Deployment to Application
    dockerCompose -->|"configures & runs"| streamlit
    dockerFile -->|"builds image"| streamlit
    startupScript -->|"entrypoint"| streamlit
    requirements -->|"dependencies"| streamlit

    %% Click Events
    click streamlit "https://github.com/automateyournetwork/netbox_react_agent/blob/main/netbox_react_agent/netbox_react_agent.py"
    click agent "https://github.com/automateyournetwork/netbox_react_agent/blob/main/netbox_react_agent/netbox_react_agent.py"
    click controller "https://github.com/automateyournetwork/netbox_react_agent/blob/main/netbox_react_agent/netbox_react_agent.py"
    click apiDefs "https://github.com/automateyournetwork/netbox_react_agent/blob/main/netbox_react_agent/netbox_apis.json"
    click dockerCompose "https://github.com/automateyournetwork/netbox_react_agent/blob/main/docker-compose.yml"
    click dockerFile "https://github.com/automateyournetwork/netbox_react_agent/tree/main/docker/Dockerfile"
    click startupScript "https://github.com/automateyournetwork/netbox_react_agent/blob/main/scripts/startup.sh"
    click requirements "https://github.com/automateyournetwork/netbox_react_agent/blob/main/requirements.txt"
    click readme "https://github.com/automateyournetwork/netbox_react_agent/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#0366D6,color:#0366D6;
    classDef logic fill:#FFF4D6,stroke:#D6A800,color:#D6A800;
    classDef external fill:#E8F5E9,stroke:#388E3C,color:#388E3C;
    classDef deploy fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A;
```
