# dataelement/bisheng architecture

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

- Interactive diagram: https://gitdiagram.com/dataelement/bisheng
- Repository: https://github.com/dataelement/bisheng

## Overview

##### Project Type and Purpose
- This is a full-stack, containerized enterprise LLM application platform (“BISHENG”) that bundles:
- A monolithic Python backend (FastAPI + Celery)
- Two React-based frontends (“client” for user chat & “platform” for workflow & admin)
- Self-hostable infrastructure via Docker Compose, including DB, cache, vector stores, message broker, search, office server, and reverse proxies
- Purpose: Provide an end-to-end devops platform to author, orchestrate and run complex LLM workflows (chat, document parsing, multi-agent flows), with enterprise features (RBAC, SSO, observability).

##### Key Directories & Architectural Signals
- docker/: Compose files & container configs for bisheng backend, worker, MySQL, Redis, Elasticsearch, Milvus, OnlyOffice, Nginx
- src/backend/: Python service using FastAPI (API router, services, cache, database models), Celery tasks & workers, LLM/chat adapters, workflow engine
- src/bisheng-langchain/: LangChain integration library, custom agents, tools, document loaders, RAG pipelines
- src/frontend/client/: React “chat client” served by Nginx, communicates via REST & SSE/WebSockets
- src/frontend/platform/: React “platform UI” for building workflows, flows and admin functions
- Configuration / CI: .drone.yml, GitHub workflows, pre-commit, Dockerfiles

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        ChatClient["Chat Client (Browser)"]:::frontend
        PlatformUI["Platform UI (Browser)"]:::frontend
    end

    %% Reverse Proxy
    subgraph "Infrastructure / Proxy"
        direction TB
        Nginx["Nginx Reverse Proxy"]:::infra
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        FastAPI["FastAPI Service"]:::backend
        subgraph "FastAPI Modules"
            direction TB
            Auth["Auth & RBAC"]:::backend
            WorkflowEngine["Workflow Engine"]:::backend
            LLMAdapter["LLM Adapter Interfaces"]:::backend
            OCRService["OCR Service"]:::backend
            AuditLogs["Audit & Logs"]:::backend
        end
    end

    %% Worker Layer
    subgraph "Worker Layer"
        direction TB
        CeleryWorker["Celery Worker"]:::worker
        Broker["Task Broker (Redis)"]:::infra
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Cache["Redis Cache"]:::datastore
        MySQL["MySQL Database"]:::datastore
        ES["Elasticsearch"]:::datastore
        Milvus["Milvus Vector Store"]:::datastore
        OnlyOffice["OnlyOffice Service"]:::datastore
    end

    %% Shared Library
    SharedLib["bisheng-langchain Library"]:::shared

    %% External Services
    subgraph "Third-party Services"
        direction TB
        ExtLLM["External LLM Providers"]:::external
        ExtOCR["External OCR Models"]:::external
    end

    %% Connections
    ChatClient -->|HTTP/HTTPS| Nginx
    PlatformUI -->|HTTP/HTTPS| Nginx

    Nginx -->|REST API| FastAPI

    FastAPI -->|ORM CRUD| MySQL
    FastAPI -->|Cache Ops| Cache
    FastAPI -->|AMQP/Redis Broker| Broker
    FastAPI -->|Vector Query| ES
    FastAPI -->|Vector Query| Milvus
    FastAPI -->|HTTP| OnlyOffice
    FastAPI -->|Load Library| SharedLib

    FastAPI -->|SSE/WebSocket| ChatClient
    FastAPI -->|SSE/WebSocket| PlatformUI

    Broker -->|Enqueue/Dequeue| CeleryWorker
    CeleryWorker -->|DB Write| MySQL
    CeleryWorker -->|Cache Write| Cache
    CeleryWorker -->|Index| ES
    CeleryWorker -->|Index| Milvus
    CeleryWorker -->|LLM Calls| ExtLLM
    CeleryWorker -->|OCR Calls| ExtOCR

    %% Click Events
    click Nginx "https://github.com/dataelement/bisheng/blob/main/docker/nginx/conf.d/default.conf"
    click Nginx "https://github.com/dataelement/bisheng/blob/main/docker/nginx/nginx.conf"
    click FastAPI "https://github.com/dataelement/bisheng/blob/main/src/backend/bisheng/main.py"
    click FastAPI "https://github.com/dataelement/bisheng/tree/main/src/backend/bisheng/api/"
    click CeleryWorker "https://github.com/dataelement/bisheng/tree/main/src/backend/bisheng/worker/"
    click Broker "https://github.com/dataelement/bisheng/blob/main/docker/redis/redis.conf"
    click Cache "https://github.com/dataelement/bisheng/tree/main/src/backend/bisheng/cache/"
    click MySQL "https://github.com/dataelement/bisheng/blob/main/docker/mysql/conf/my.cnf"
    click SharedLib "https://github.com/dataelement/bisheng/tree/main/src/bisheng-langchain/"
    click ChatClient "https://github.com/dataelement/bisheng/tree/main/src/frontend/client/"
    click PlatformUI "https://github.com/dataelement/bisheng/tree/main/src/frontend/platform/"
    click OnlyOffice "https://github.com/dataelement/bisheng/blob/main/docker/office/bisheng/config.json"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#004d40
    classDef backend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef worker fill:#d1c4e9,stroke:#4a148c,color:#4a148c
    classDef datastore fill:#ffe0b2,stroke:#e65100,color:#bf360c
    classDef infra fill:#cfd8dc,stroke:#37474f,color:#263238
    classDef external fill:#eeeeee,stroke:#757575,color:#424242,stroke-dasharray: 5 5
    classDef shared fill:#dcedc8,stroke:#558b2f,color:#33691e
```
