# baizunxian/zerorunner architecture

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

- Interactive diagram: https://gitdiagram.com/baizunxian/zerorunner
- Repository: https://github.com/baizunxian/zerorunner

## Overview

##### Project Type and Purpose
- This is a full-stack automated testing platform with a clear separation between a Python-based backend and a modern Vue3 frontend.
- The backend (built on Python with FastAPI, celery, SQLAlchemy, and Redis) primarily handles API, UI, and system test tasks with asynchronous job scheduling. It also appears to include modules for test runner execution (the “zerorunner” subfolder) and extensive support for API/UITest case management.
- The frontend (built using Vite, Vue3, and Element Plus) provides the user interface for interacting with test cases, reports, system configurations, and real-time updates (via WebSocket integration).

##### File Structure
- Backend:
- The directory structure under “backend” is organized into multiple layers:
∗ “autotest” – Contains APIs, jobs, models, schemas, services, and utilities that show a layered (often MVC-like) approach.
∗ “celery_worker” – Manages asynchronous and scheduled tasks using celery with separate modules for schedulers and tasks.
∗ “zerorunner” – Likely encapsulates core logic for test-case parsing, running, reporting, and result formatting.
∗ Other configuration and initialization files (.env files, config.py) to support environment management.
- Notice the clear separation between modules handling API testing, UI testing, system management (like user roles, menus, notifications) and job management.
- Frontend:
- The “frontend” directory reveals a structured Vue3 project, with separate folders for API abstractions, components (for test reporting, case editing, dashboards), layouts, routing, and state management.
- Clear delineation for components that build interactivity (e.g., Z-Report, Z-Step, etc.) and integrations with backend API endpoints.
- Additionally, various Docker and configuration files and multiple docker-compose files indicate that the project is containerized and supports deployment of the backend, frontend, MySQL, Redis, and Selenium services.

##### Examining the README
- The README clarifies the stack versions (FastAPI, Celery, Vue3, etc.) and provides instructions to launch both backend and frontend.
- It emphasizes the platform’s purpose as an “Automated Testing Platform” and shows example screenshots (like reporting pages) that reinforce the idea of a test orchestration and reporting tool.

a. Main Components:
- Frontend Client (Browser): Vue3 application built with Vite and Element Plus.
- Backend API Server: FastAPI server handling REST endpoints for API and UI test interactions.
- Asynchronous Task Processor: Celery Worker managing background jobs, scheduled tasks, and test case executions.
- Database Layer: MySQL for persistent storage (test cases, configurations, reports) and Redis for in-memory caching and message brokering.
- WebSocket Service: Modules within the backend (see “websocket” directories) handling real-time communication between the server and the frontend.
- Auxiliary Components: Components aiding test processing such as modules for parsing, executing test steps (“zerorunner” modules), and reporting.

b. Relationships and Interactions:
- The Frontend communicates with the Backend via RESTful APIs (and possibly WebSocket for real-time updates).
- The Backend processes incoming requests through various endpoints (grouped by API testing, UI testing, system management, etc.) and manages data in the MySQL database.
- For heavy or scheduled operations, the Backend delegates tasks to Celery Workers which then use Redis as a message broker (and might also interact with MySQL for storing results).
- The “zerorunner” slice of the backend forms the core test execution engine, processing test definitions, parsing test suites, and generating test reports.
- Deployment components (Docker configurations) indicate containerized deployment where each service/component interacts over defined network channels.

c. Architectural Patterns / Design Principles:
- Modular Organization: A layered (perhaps MVC-like) design separating business logic (services, schemas, models) from API controllers.
- Asynchronous Processing: Utilizes Celery for offloading time-consuming tasks and scheduled jobs.
- Clear Separation of Concerns: Frontend is isolated from backend logic, and configuration/environment details are externalized.
- Componentization in Frontend: Reusable Vue components with dedicated folders for views, layouts, and state management.

d. Technologies, Frameworks, and Libraries:
- Backend: Python3, FastAPI, Celery, SQLAlchemy, MySQL, Redis.
- Frontend: Vue3, Vite, Element Plus, plus additional libraries for state management and UI components.
- Containerization/Docker: Multiple docker-compose files to isolate and integrate development, testing, and production environments.
- WebSockets and real-time communication support for front-to-back updates.

##### Instructing the Principal Software Engineer
- Use clear and distinct labels for each component (e.g., “Vue3 Frontend”, “FastAPI Server”, “Celery Worker”, “MySQL Database”, “Redis Broker”).
- User interface components (front-end)
- Business logic (backend APIs and service layers)
- Asynchronous processing (celery-related modules)
- Data persistence layers (database and cache)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["Vue3 Frontend"]:::frontend
    end

    subgraph "Backend Layer"
        BE["FastAPI Backend API Server"]:::backend
        APIS["API Endpoints"]:::backend
        WS["WebSocket API"]:::backend
        CELERY["Celery Worker"]:::celery
        ZEROTEST["Zerorunner Engine"]:::zerorunner
    end

    subgraph "Data Layer"
        MYSQL["MySQL Database"]:::database
        REDIS["Redis Broker"]:::redis
    end

    subgraph "Deployment"
        DOCKER["Docker Compose Deployment"]:::docker
    end

    %% Data Flow Connections
    FE -->|"REST_API"| APIS
    APIS -->|"queries"| MYSQL
    APIS -->|"caches"| REDIS
    APIS -->|"delegates"| CELERY
    CELERY -->|"stores_results"| MYSQL
    APIS -->|"real_time"| WS
    WS -->|"pushes_update"| FE

    %% Docker connections (dashed lines)
    DOCKER --- FE
    DOCKER --- BE
    DOCKER --- CELERY
    DOCKER --- MYSQL
    DOCKER --- REDIS

    %% Click Events
    click FE "https://github.com/baizunxian/zerorunner/tree/master/frontend/"
    click BE "https://github.com/baizunxian/zerorunner/blob/master/backend/main.py"
    click APIS "https://github.com/baizunxian/zerorunner/tree/master/backend/autotest/apis/"
    click CELERY "https://github.com/baizunxian/zerorunner/tree/master/backend/celery_worker/"
    click ZEROTEST "https://github.com/baizunxian/zerorunner/tree/master/backend/zerorunner/"
    click REDIS "https://github.com/baizunxian/zerorunner/blob/master/backend/autotest/db/my_redis.py"
    click MYSQL "https://github.com/baizunxian/zerorunner/tree/master/backend/db_script/"
    click WS "https://github.com/baizunxian/zerorunner/tree/master/backend/autotest/apis/websocket/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef celery fill:#FFCCCB,stroke:#000,stroke-width:2px;
    classDef zerorunner fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef database fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef redis fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef docker fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
