# vidyutchakrabarti/agentflux architecture

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

- Interactive diagram: https://gitdiagram.com/vidyutchakrabarti/agentflux
- Repository: https://github.com/vidyutchakrabarti/agentflux

## Overview

##### Project type and purpose
- AgentFlux is a full-stack AI agent engineering platform. The Next.js/React frontend (in main/app and main/components) provides an interactive playground, visualization, and observation UI. The Node/TypeScript backend (in main/server.ts, API routes, and the main/Agents folder) handles agent orchestration, refinement, persistence, and third-party integrations.

##### File structure
- Top-level directories:
- data – static training and lookup data (codes.json, train.csv)
- main/Agents – core “agent” code: two ADK agents (graph_architect, prompt_refiner) plus shared helper_funcs and api wrappers
- main/app – Next.js 13 app folder with pages, API routes, and Firebase auth
- main/components – reusable UI components for visualization, code editor, modals, etc.
- main/lib, main/models – MongoDB connection (mongodb.js) and Mongoose schemas (Playground, Sheet, Runs, RefineHistory)
- main/public – static assets (AgentFlux-logo.gif, videos)
- Configuration: .env.example, package.json, tsconfig, ESLint, Tailwind

##### README for additional insights
- Confirms the UI features (playground, graph viz, diff reports), the two core agents (Prompt Refinement, Graph Re-architect), model management (Hugging Face models behind scenes), and observation tooling (logs, profilers).
- Mentions EC2-backed “studios” but that detail can be captured later as an optional compute layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        NextJS["Next.js Frontend"]:::frontend
        PlaygroundUI["Playground UI"]:::frontend
        GraphViz["Graph Visualization Component"]:::frontend
        DiffViewer["Diff Viewer Modal"]:::frontend
        CodeEditor["Code Editor Modal"]:::frontend
        NextJS --> PlaygroundUI
        NextJS --> GraphViz
        NextJS --> DiffViewer
        NextJS --> CodeEditor
        NextJS -->|calls API| APIGateway
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        APIGateway["API Gateway (Next.js API Routes)"]:::backend
        AuthService["Firebase Auth Service"]:::backend
        MongoConn["MongoDB Connection"]:::backend
        subgraph "Data Models"
            direction TB
            PlaygroundModel["Playground Schema"]:::backend
            SheetModel["Sheet Schema"]:::backend
            RunsModel["Runs Schema"]:::backend
            RefineHistoryModel["RefineHistory Schema"]:::backend
        end
        subgraph "Agent Engine"
            direction TB
            GraphAgent["GraphArchitect Agent"]:::backend
            PromptAgent["PromptRefiner Agent"]:::backend
            Helpers["Agent SDK Helpers & API Wrappers"]:::backend
        end
        APIGateway -->|auth calls| AuthService
        APIGateway -->|DB CRUD| MongoConn
        MongoConn --> PlaygroundModel
        MongoConn --> SheetModel
        MongoConn --> RunsModel
        MongoConn --> RefineHistoryModel
        APIGateway --> GraphAgent
        APIGateway --> PromptAgent
        GraphAgent -->|uses| Helpers
        PromptAgent -->|uses| Helpers
        GraphAgent -->|Invoke LLM inference| SageMaker
        PromptAgent -->|Invoke LLM inference| SageMaker
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SageMaker["AWS SageMaker Endpoint\n(hosts fine-tuned models\nMistral_prompttune, Deepseek_Agentarchitect)"]:::external
        HuggingFace["External LLM Provider\n(Hugging Face)"]:::external
        HuggingFace -->|provides models| SageMaker
    end

    %% Connections back to UI
    APIGateway -->|returns graphs, diffs, metrics| NextJS

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#000,stroke-width:1px
    classDef backend fill:#C8E6C9,stroke:#000,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#000,stroke-width:1px

    %% Click Events
    click NextJS "https://github.com/vidyutchakrabarti/agentflux/tree/main/main/app/"
    click PlaygroundUI "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/app/playground/page.tsx"
    click GraphViz "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/components/GraphVisualization.tsx"
    click DiffViewer "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/components/AgentGraphDiffModal.tsx"
    click CodeEditor "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/components/CodeditorModal.tsx"
    click AuthService "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/app/firebase/authService.tsx"
    click APIGateway "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/app/api/playgrounds/route.ts"
    click GraphAgent "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/Agents/adk_agents/graph_architect/agent.py"
    click PromptAgent "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/Agents/adk_agents/prompt_refiner/agent.py"
    click Helpers "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/Agents/helper_funcs.py"
    click MongoConn "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/lib/mongodb.js"
    click PlaygroundModel "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/models/Playground.ts"
    click SheetModel "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/models/Sheet.ts"
    click RunsModel "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/models/Runs.ts"
    click RefineHistoryModel "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/models/RefineHistory.ts"
    click SageMaker "https://github.com/vidyutchakrabarti/agentflux/blob/main/main/.env.example"
```
