# hui-lun/chatflow-agent architecture

> Architecture diagram of the GitHub repository hui-lun/chatflow-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hui-lun/chatflow-agent
- Repository: https://github.com/hui-lun/chatflow-agent

## Overview

##### Project type and purpose
- This is a full-stack web application composed of:
- A Python-based backend (in `backend/`) exposing an HTTP API (likely using FastAPI or Flask).
- A Vue.js frontend (in `frontend/`) served via Nginx.
- Docker/Docker-Compose orchestration for local development and deployment.
- The backend also integrates with an external large-language-model service (see `backend/app/services/llm.py`).

##### File structure
Top-level:
- `.gitignore`, `docker-compose.yml` – project config & orchestration.
- `backend/` – Python API service with its own `Dockerfile`, `requirements.txt`, and `app/` folder.
- `frontend/` – Vue.js SPA with `Dockerfile`, `nginx.conf` for serving static assets, `package.json`, and `src/`.
Inside `backend/app/`:
- `main.py` – application entry point.
- `services/llm.py` – encapsulates calls to an external LLM API.
Inside `frontend/src/`:
- `App.vue`, `main.js` – Vue application bootstrap.
- `api/chat.js` – client module for calling the backend chat endpoint.
- `assets/styles` – SCSS files for styling.

##### Additional insights
- The absence of a database directory implies no persistent storage or it’s abstracted behind the LLM service.
- `docker-compose.yml` orchestrates at least two services: `frontend` and `backend`.
- `nginx.conf` indicates the frontend container uses Nginx both to serve static files and probably to proxy API requests.

##### Detailed component breakdown (
- Frontend Container:
- Nginx process
- Vue.js app files (`index.html`, `main.js`, `App.vue`, `styles/`)
- `nginx.conf` routing rules
- Backend Container:
- Python runtime + `main.py`
- Service layer (`services/llm.py`)
- Dependency list (`requirements.txt`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Web Browser"]:::client

    %% External
    ExternalLLM["External LLM API"]:::externalService

    %% Orchestrator
    subgraph dockerComposeGroup["Docker-Compose Orchestrator"]
        DockerCompose["Docker-Compose"]:::orchestrator

        subgraph "Frontend Container"
            FrontendContainer["Frontend Container"]:::container
            DockerfileFE["Dockerfile"]:::file
            ConfigNginx["nginx.conf"]:::file
            IndexHTML["index.html"]:::file
            PackageJSON["package.json"]:::file
            ViteConfig["vite.config.js"]:::file
            SrcDir["src/"]:::dir

            subgraph "src/"
                MainJS["main.js"]:::module
                AppVue["App.vue"]:::module
                ChatJS["chat.js"]:::module
                AssetsDir["assets/styles/"]:::dir

                subgraph "assets/styles/"
                    MainSCSS["main.scss"]:::file
                end
            end
        end

        subgraph "Backend Container"
            BackendContainer["Backend Container"]:::container
            DockerfileBE["Dockerfile"]:::file
            Requirements["requirements.txt"]:::file
            AppDir["app/"]:::dir

            subgraph "app/"
                MainPY["main.py"]:::module
                LLMPY["services/llm.py"]:::module
            end
        end
    end

    %% Flows
    Browser -->|"GET HTML/CSS/JS"| DockerCompose
    DockerCompose -->|"routes 80/443"| FrontendContainer
    FrontendContainer -->|serves| IndexHTML
    IndexHTML -->|loaded by| Browser

    Browser -->|"POST /api/chat"| FrontendContainer
    FrontendContainer -->|"proxy /api/chat"| BackendContainer
    BackendContainer -->|"HTTP call"| ExternalLLM
    ExternalLLM -->|"response"| BackendContainer
    BackendContainer -->|"JSON response"| FrontendContainer
    FrontendContainer -->|"JSON response"| Browser

    %% Click Events
    click DockerCompose "https://github.com/hui-lun/chatflow-agent/blob/main/docker-compose.yml"
    click FrontendContainer "https://github.com/hui-lun/chatflow-agent/tree/main/frontend/"
    click DockerfileFE "https://github.com/hui-lun/chatflow-agent/tree/main/frontend/Dockerfile"
    click ConfigNginx "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/nginx.conf"
    click IndexHTML "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/index.html"
    click PackageJSON "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/package.json"
    click ViteConfig "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/vite.config.js"
    click SrcDir "https://github.com/hui-lun/chatflow-agent/tree/main/frontend/src/"
    click MainJS "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/src/main.js"
    click AppVue "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/src/App.vue"
    click ChatJS "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/src/api/chat.js"
    click MainSCSS "https://github.com/hui-lun/chatflow-agent/blob/main/frontend/src/assets/styles/main.scss"
    click BackendContainer "https://github.com/hui-lun/chatflow-agent/tree/main/backend/"
    click DockerfileBE "https://github.com/hui-lun/chatflow-agent/tree/main/backend/Dockerfile"
    click Requirements "https://github.com/hui-lun/chatflow-agent/blob/main/backend/requirements.txt"
    click AppDir "https://github.com/hui-lun/chatflow-agent/tree/main/backend/app/"
    click MainPY "https://github.com/hui-lun/chatflow-agent/blob/main/backend/app/main.py"
    click LLMPY "https://github.com/hui-lun/chatflow-agent/blob/main/backend/app/services/llm.py"

    %% Styles
    classDef client fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef orchestrator fill:none,stroke:#7D3C98,stroke-dasharray:5 5,stroke-width:2px;
    classDef container fill:#AED6F1,stroke:#3498DB,stroke-width:2px,stroke-radius:5px;
    classDef file fill:#F9E79F,stroke:#B7950B,stroke-width:1px;
    classDef dir fill:#FCF3CF,stroke:#B9770E,stroke-width:1px;
    classDef module fill:#F5B7B1,stroke:#C0392B,stroke-width:1px;
    classDef externalService fill:#D5F5E3,stroke:#27AE60,stroke-width:2px,stroke-dasharray:2 2;
```
