# filip-michalsky/salesgpt architecture

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

- Interactive diagram: https://gitdiagram.com/filip-michalsky/salesgpt
- Repository: https://github.com/filip-michalsky/salesgpt

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack open-source AI Agent platform (“SalesGPT”) plus companion documentation sites.
- Core functionality: a Python library and backend API that orchestrates LLM-powered sales agents with tools (Stripe, Calendly, product catalog lookup, Mindware, etc.).
- Frontend: a Next.js React app for real-time chat.
- Two documentation sites:
- api-website (Sphinx-built library docs)
- website (Docusaurus marketing/site docs)

##### File structure
Top‐level directories & files:
- salesgpt/       ← core Python package (agents, chains, tools, prompts, logger)
- run.py          ← CLI entrypoint for an interactive agent
- run_api.py      ← backend API server (FastAPI/Flask)
- frontend/       ← Next.js React chat UI, Dockerfile.frontend, package.json, src/…
- api-website/    ← Sphinx docs for the Python library
- website/        ← Docusaurus marketing/documentation site
- examples/       ← sample configs, product catalog, notebooks
- tests/          ← pytest tests for library and API
- Dockerfile.backend, docker-compose.yml, Makefile, .github/… (CI), pyproject.toml, requirements*.txt

Architectural patterns & hints:
- Separation of concerns: UI vs. API vs. core library vs. docs
- Microservices‐style via Docker Compose: “backend” service, “frontend” service
- Python package is composable via run.py (CLI) or run_api.py (HTTP API)
- Tools are plugged into agents through LangChain custom agent pattern

##### README for additional insights
- Quickstart shows how SalesGPT.from_llm(...) wires up LLM + tools
- Architecture section includes a sample flow chart (agent → tool invocation → observation)
- External dependencies: LiteLLM (any LLM), Mindware integration, Stripe, Calendly, LangSmith tracing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        UserBrowser["Browser (Web UI)"]:::external_user
        UserTerminal["Terminal (CLI)"]:::external_user
    end

    %% Frontend and CLI
    Frontend["Frontend UI<br>Next.js/React"]:::internal
    CLI["CLI Interface<br>run.py"]:::internal
    click CLI "https://github.com/filip-michalsky/salesgpt/blob/main/run.py"

    UserBrowser --> Frontend
    UserTerminal --> CLI

    %% Backend Layer
    Backend["Backend API Service<br>run_api.py"]:::internal
    click Backend "https://github.com/filip-michalsky/salesgpt/blob/main/run_api.py"

    Frontend -->|"HTTP/WebSocket"| Backend
    CLI -->|"Library Call"| SalesCore

    %% Core Engine
    subgraph "SalesGPT Core Engine"
        SalesCore["salesgpt/"]:::internal
        click SalesCore "https://github.com/filip-michalsky/salesgpt/tree/main/salesgpt/"
        Agents["Agents Module<br>agents.py"]:::internal
        click Agents "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/agents.py"
        Chains["Chains Module<br>chains.py"]:::internal
        click Chains "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/chains.py"
        ToolsModule["Tools Orchestrator<br>tools.py"]:::internal
        click ToolsModule "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/tools.py"
        PromptsEn["Prompts (EN)<br>prompts.py"]:::internal
        click PromptsEn "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/prompts.py"
        PromptsCn["Prompts (CN)<br>prompts_cn.py"]:::internal
        click PromptsCn "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/prompts_cn.py"
        Logger["Logger/Tracing<br>logger.py"]:::internal
        click Logger "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/logger.py"
        APIAbstraction["API Abstraction<br>salesgptapi.py"]:::internal
        click APIAbstraction "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/salesgptapi.py"
        CustomLLM["Custom LLM Adapter<br>custom_invoke.py"]:::internal
        click CustomLLM "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/custom_invoke.py"
        Models["Data Models<br>models.py"]:::internal
        click Models "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/models.py"
        Stages["Pipeline Stages<br>stages.py"]:::internal
        click Stages "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/stages.py"
        Templates["Templates Engine<br>templates.py"]:::internal
        click Templates "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/templates.py"
        Version["Version Info<br>version.py"]:::internal
        click Version "https://github.com/filip-michalsky/salesgpt/blob/main/salesgpt/version.py"
    end

    Backend --> APIAbstraction
    Backend --> SalesCore

    %% LLM Provider
    LLMProvider["LLM Provider<br>OpenAI/LiteLLM"]:::external
    SalesCore -->|"gRPC/Streaming"| LLMProvider
    LLMProvider -->|"Response"| SalesCore

    %% Tools & Integrations
    subgraph "Tools & Integrations"
        ProductCatalog["Product Catalog<br>sample_product_catalog.txt"]:::datastore
        click ProductCatalog "https://github.com/filip-michalsky/salesgpt/blob/main/examples/sample_product_catalog.txt"
        Stripe["Stripe Payment API"]:::external
        Calendly["Calendly Scheduling API"]:::external
        click Calendly "https://github.com/filip-michalsky/salesgpt/blob/main/calendly.py"
        Mindware["Mindware Data System"]:::external
        LangSmith["LangSmith Tracing Service"]:::external
    end

    SalesCore --> Stripe
    SalesCore --> Calendly
    SalesCore --> Mindware
    SalesCore --> LangSmith
    SalesCore --> ProductCatalog

    %% Documentation
    subgraph "Documentation Sites"
        Sphinx["Sphinx API Docs"]:::docs
        click Sphinx "https://github.com/filip-michalsky/salesgpt/tree/main/api-website/"
        Docusaurus["Docusaurus Site"]:::docs
        click Docusaurus "https://github.com/filip-michalsky/salesgpt/tree/main/website/"
    end

    %% DevOps / CI
    GitHubActions["GitHub Actions CI/CD"]:::devtools
    GitHubActions -.-> Frontend
    GitHubActions -.-> Backend

    %% Styles
    classDef internal fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef external fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef docs fill:#e2e3e5,stroke:#333,stroke-width:1px;
    classDef devtools fill:#ffe5cc,stroke:#333,stroke-width:1px;
    classDef datastore fill:#fff3cd,stroke:#333,stroke-width:1px;
    classDef external_user fill:#f8d7da,stroke:#333,stroke-width:1px;
```
