# shybert-ai/openmanus-webui architecture

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

- Interactive diagram: https://gitdiagram.com/shybert-ai/openmanus-webui
- Repository: https://github.com/shybert-ai/openmanus-webui

## Overview

Based on an analysis of the file tree and README, the project is a full‐stack web application that creates a simple Flask-based web UI for interacting with the OpenManus system. In essence, the project separates the frontend—served via Flask routes using templates and static assets (including PDF.js for file preview and other assets for viewing files such as HTML, code, etc.)—from the backend business logic located in the “app” directory. The backend contains various modules for handling agents, flows, prompts, tools, logging, and configuration. There is also a configuration folder (“config”) for setting up the LLM’s API parameters (for example, deepseek/deepseek chat based on DeepSeek-R1 model).

- Frontend UI:
– The project includes two main versions (WebUI_v1 and WebUI_v2), each with its own app.py, templates, and static resources.
– The “templates” and “static” directories (as well as the duplicate PDF.js assets in both WebUI_v2 and the root static directory) serve the web page’s HTML, CSS, JavaScript, and file preview functionality.

- Backend Application Logic:
– The “app” directory houses the core business logic. Break it into its subcomponents:
○ Agent modules (agent, including base, planning, react, swe, and toolcall) which likely manage different conversation channels or decision flows.
○ Flow modules (defining various workflows and execution flows, with a flow_factory to instantiate flows).
○ Prompt modules (for defining and formatting prompts corresponding to different tasks).
○ Tool modules (wrappers or executors for specific functions like bash commands, Google search integration, file operations, etc.)
○ LLM integration (app/llm.py) that coordinates API calls to the external LLM service.
○ Logger (app/logger.py) for handling real-time logging and flow execution monitoring.

- Configuration & Environment:
– The “config” directory with TOML configuration files governs the API keys, model parameters, and global settings.
– The requirements.txt, setup.py, and other deployment scripts indicate how the project is built and deployed.

##### Out the relationships and interactions
- The user’s browser sends HTTP requests to the Flask server (initiated from app.py or WebUI_v1/app.py, WebUI_v2/app.py).
- The Flask routes render HTML pages (using templates) and deliver static resources (stored in static folders, including PDF.js and additional assets).
- When a user submits a prompt or request, the Flask backend calls into the “app” modules:
– The agent and flow components process the prompt.
– Tools may be executed to supplement the workflow (e.g., file saving, executing shell commands, or browser tool operations).
– The LLM module (llm.py) makes API calls to an external service for generating responses.
- The response is then logged (via app/logger.py) and the results are rendered back to the client (including file previews).
- For file preview functionality, static PDF.js components and other viewer templates (like google_viewer.html, onlyoffice_viewer.html, code.html) are triggered to display documents.

##### Architectural patterns
- Separation of concerns: Frontend vs. Backend.
- Modular design within the “app” directory (agents, flows, prompts, tools, etc.), which promotes extensibility.
- A micro “service-like” internal architecture even though the entire application runs in a single Flask instance, where separate modules handle specific tasks.
- Use of configuration files (TOML) to decouple API/LLM settings from code.

##### Technologies and frameworks
- Python (≥ 3.8) with Flask for the webserver and routing.
- Template rendering (Jinja2) for the frontend HTML pages.
- PDF.js and other static JavaScript libraries for file preview.
- External LLM APIs (configured in config/config.toml) for processing user inputs.
- TOML for configuration management.
- Command-line and logging utilities in the “app” folder.

- User Browser (client)
- Flask Web Server:
– Handles routing and serves HTML pages (templates) and static resources (JavaScript, CSS, PDF.js assets)
- Backend Application (app folder):
– Agent Modules
– Flow Modules
– Prompt Modules
– Tool Modules
– LLM integration module (which makes HTTP requests to the external LLM API)
– Logger for real-time monitoring
- Configuration & Deployment:
– “config” directory and environment setup (requirements.txt, setup.py)
- External Services:
– LLM API (DeepSeek-R1 endpoint)
- File Preview/Viewer:
– PDF.js components (served from multiple static directories)

- Flask server to the backend “app” components that process the request through agents, flows, and prompts.
- Outbound API call from the LLM module towards the external LLM API service, and show inbound response channels back.
- Logging and configuration modules that support the smooth operation of the backend processing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UserBrowser["User Browser"]:::frontend
    FlaskServer["Flask Web Server"]:::frontend
    WebUI_v1["WebUI_v1"]:::frontend
    WebUI_v2["WebUI_v2"]:::frontend
    FilePreview["File Preview/Viewers"]:::frontend
    AgentModules["Agent Modules"]:::backend
    FlowModules["Flow Modules"]:::backend
    PromptModules["Prompt Modules"]:::backend
    ToolModules["Tool Modules"]:::backend
    LLMIntegration["LLM Integration Module"]:::backend
    Logging["Logging"]:::backend
    LLMAPI["External LLM API (DeepSeek-R1)"]:::external
    Configuration["Configuration & Deployment"]:::config

    %% Relationships
    UserBrowser -->|"HTTP_Request"| FlaskServer
    FlaskServer ---|"includes"| WebUI_v1
    FlaskServer ---|"includes"| WebUI_v2
    FlaskServer ---|"includes"| FilePreview
    FlaskServer -->|"calls"| AgentModules
    AgentModules -->|"processes"| FlowModules
    FlowModules -->|"routes"| PromptModules
    PromptModules -->|"executes"| ToolModules
    ToolModules -->|"invokes"| LLMIntegration
    LLMIntegration -->|"API_call"| LLMAPI
    LLMAPI -->|"returns"| LLMIntegration
    LLMIntegration -->|"config"| Configuration
    LLMIntegration -->|"logs"| Logging
    Logging -->|"sends_response"| FlaskServer

    %% Click Events for Frontend UI – WebUI_v1
    click WebUI_v1 "https://github.com/shybert-ai/openmanus-webui/blob/master/WebUI_v1/app.py"
    click WebUI_v1 "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v1/templates"
    click WebUI_v1 "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v1/static"

    %% Click Events for Frontend UI – WebUI_v2
    click WebUI_v2 "https://github.com/shybert-ai/openmanus-webui/blob/master/WebUI_v2/app.py"
    click WebUI_v2 "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v2/templates"
    click WebUI_v2 "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v2/static"

    %% Click Events for File Preview/Viewers
    click FilePreview "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v2/templates"
    click FilePreview "https://github.com/shybert-ai/openmanus-webui/tree/master/WebUI_v2/static/pdfjs"
    click FilePreview "https://github.com/shybert-ai/openmanus-webui/tree/master/static/pdfjs"

    %% Click Events for Backend Modules
    click AgentModules "https://github.com/shybert-ai/openmanus-webui/tree/master/app/agent"
    click FlowModules "https://github.com/shybert-ai/openmanus-webui/tree/master/app/flow"
    click PromptModules "https://github.com/shybert-ai/openmanus-webui/tree/master/app/prompt"
    click ToolModules "https://github.com/shybert-ai/openmanus-webui/tree/master/app/tool"
    click LLMIntegration "https://github.com/shybert-ai/openmanus-webui/blob/master/app/llm.py"
    click Logging "https://github.com/shybert-ai/openmanus-webui/blob/master/app/logger.py"

    %% Click Events for Configuration & Environment
    click Configuration "https://github.com/shybert-ai/openmanus-webui/tree/master/config"
    click Configuration "https://github.com/shybert-ai/openmanus-webui/blob/master/requirements.txt"
    click Configuration "https://github.com/shybert-ai/openmanus-webui/blob/master/setup.py"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef backend fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef external fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef config fill:#fff3e0,stroke:#ef6c00,stroke-width:2px;
```
