XIAOJUSURVEY Documentation

repository·main·Indexed 26 days ago

https://github.com/didi/xiaoju-survey

A lightweight, secure, and professional survey system for building questionnaires, exams, and complex forms. It features AI-driven questionnaire generation, smart logic (display and jump logic), multi-role permission management, and advanced data analysis. The technical stack consists of a Vue3 and ElementPlus web client with a NestJS and MongoDB server. Supports deployment via Docker with slim and full image versions.

Tokens
11.7K
Snippets
41
Records
98
Agent score
87%

What's inside XIAOJUSURVEY

  1. Overview of XIAOJUSURVEY

    main

    XIAOJUSURVEY is a lightweight and secure survey system providing a one-stop product-level solution for individuals and enterprises. It is used to build various questionnaires, exams, assessments, and complex forms.

    Key capabilities include:

    • Data Collection: Supports text input, data selection, ratings, voting, file uploads, etc.
    • Smart Logic: Dynamic form design using display logic, jump logic, option/question referencing.
    • Permission Management: Space management and multi-role permission control.
    • Data Analysis: Online analysis and export, including question-based statistics and cross-analysis.
    • AI Integration: AI-generated questionnaires via LLM conversational interfaces.
    • Customization: Theme customization (colors, backgrounds, logos) and multi-terminal SDK support.
  2. Set up XIAOJUSURVEY for local development

    main

    To run the project locally, you need to start both the server and the web client. Ensure you have Node.js >= 18 installed.

    1. Start the Server: Navigate to the server directory, install dependencies, and run the local command.
    2. Start the Web Client: Navigate to the web directory, install dependencies, and run the serve command.

    Access Points:

    • Management (B-end): http://localhost:8080/management
    • Rendering (C-end): http://localhost:8080/render/:surveyPath
    # 服务启动
    cd server
    npm install
    npm run local
    
    # 页面启动
    cd web
    npm install
    npm run serve
  3. Deploy XIAOJUSURVEY using Docker

    main

    XIAOJUSURVEY supports Docker-based deployment. You can choose between two image versions in your docker-compose.yaml file:

    • slim version (xiaojusurvey/xiaoju-survey:latest-slim): Based on node:18-slim. Smaller footprint, contains minimal dependencies, recommended for production environments.
    • full version (xiaojusurvey/xiaoju-survey:latest-full): Based on node:18. Includes full development tools like curl, vim, and git, recommended for development or debugging.
  4. Deploy xiaoju-survey using Docker Compose

    main

    You can deploy the xiaoju-survey application using Docker Compose. The setup includes a MongoDB service and the xiaoju-survey application service.

    Image Selection:

    • Slim version (Recommended for production): xiaojusurvey/xiaoju-survey:1.3.4-slim
    • Full version (Recommended for development): xiaojusurvey/xiaoju-survey:1.3.4

    Ports:

    • The application API is exposed on port 8080.
    • MongoDB is exposed on port 27017.
    version: "3.6"
    services:
      mongo:
        image: mongo:4
        container_name: xiaoju-survey-mongo
        restart: always
        environment:
          MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
          MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
        ports:
          - "27017:27017"
        volumes:
          - mongo-volume:/data/db
        networks:
          - xiaoju-survey
    
      xiaoju-survey:
        image: "xiaojusurvey/xiaoju-survey:1.3.4-slim"
        container_name: xiaoju-survey
        restart: always
        ports:
          - "8080:8080"
        environment:
          XIAOJU_SURVEY_MONGO_URL: mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@xiaoju-survey-mongo:27017
          XIAOJU_SURVEY_MONGO_AUTH_SOURCE: ${XIAOJU_SURVEY_MONGO_AUTH_SOURCE}
          AImodel_API_URL: ${AImodel_API_URL}
          AImodel_API_KEY: ${AImodel_API_KEY}
          AImodel_MODEL: ${AImodel_MODEL}
        links:
          - mongo:mongo
        depends_on:
          - mongo
        networks:
          - xiaoju-survey
    
    volumes:
      mongo-volume:
    
    networks:
      xiaoju-survey:
        name: xiaoju-survey
        driver: bridge
  5. Configure local file storage

    main

    Use SERVER_LOCAL_CONFIG to configure file uploads and storage directly on the local server (e.g., via Nginx).

    Key configuration options:

    • LOCAL_STATIC_RENDER_TYPE: Set to 'server' for Nginx-based local static rendering.
    • IS_PRIVATE_READ: Boolean indicating if files require private access.
    • FILE_KEY_PREFIX: The storage path prefix (e.g., 'userUpload').
    • NEED_AUTH: Boolean indicating if authentication is required for uploads.
    const SERVER_LOCAL_CONFIG = {
      LOCAL_STATIC_RENDER_TYPE: 'server', // nginx
      IS_PRIVATE_READ: false,
      FILE_KEY_PREFIX: 'userUpload', // 存储路径
      NEED_AUTH: true,
    };
  6. Configure chart types for question analysis

    main

    The questionChartsConfig object maps question types (retrieved from menuItems) to the allowed chart types used in the analysis interface. This ensures that specific question types (like NPS or checkboxes) display the appropriate visualizations (e.g., gauge, pie, or bar charts).

    export const questionChartsConfig = {
      [menuItems['checkbox']['type']]: ['bar'],
      [menuItems['radio-nps']['type']]: ['gauge', 'pie', 'bar'],
      default: ['pie', 'bar']
    }
  7. Configure Minio cloud storage

    main

    Use MINIO_CONFIG to configure file uploads to a Minio instance.

    Key configuration options:

    • FILE_STORAGE_PROVIDER: Must be set to 'minio'.
    • FILE_KEY_PREFIX: The prefix for file keys (e.g., 'userUpload/{surveyPath}').
    • LINK_EXPIRY_TIME: Duration for which the file link is valid (e.g., '2h').
    • ACCESS_KEY, SECRET_KEY, BUCKET, REGION, ENDPOINT: Minio credentials and endpoint.
    • USE_SSL: Boolean to enable SSL.
    export const MINIO_CONFIG = {
      FILE_STORAGE_PROVIDER: 'minio',
      IS_PRIVATE_READ: false,
      FILE_KEY_PREFIX: 'userUpload/{surveyPath}',
      NEED_AUTH: true,
      LINK_EXPIRY_TIME: '2h',
      ACCESS_KEY: '',
      SECRET_KEY: '',
      BUCKET: '',
      REGION: '',
      ENDPOINT: '',
      USE_SSL: true,
    };
  8. Configure Qiniu cloud storage

    main

    Use QINIU_CONFIG to configure file uploads to Qiniu cloud storage.

    Key configuration options:

    • FILE_STORAGE_PROVIDER: Must be set to 'qiniu'.
    • FILE_KEY_PREFIX: The prefix for file keys. Note that {surveyPath} is used as a placeholder for validation (e.g., 'userUpload/{surveyPath}').
    • LINK_EXPIRY_TIME: Duration for which the file link is valid (e.g., '2h').
    • ACCESS_KEY, SECRET_KEY, BUCKET, ENDPOINT: Cloud provider credentials and endpoint.
    • USE_SSL: Boolean to enable SSL.
    const QINIU_CONFIG = {
      FILE_STORAGE_PROVIDER: 'qiniu',
      IS_PRIVATE_READ: false,
      FILE_KEY_PREFIX: 'userUpload/{surveyPath}',
      NEED_AUTH: true,
      LINK_EXPIRY_TIME: '2h',
      ACCESS_KEY: '',
      SECRET_KEY: '',
      BUCKET: '',
      ENDPOINT: '',
      USE_SSL: false,
    };
  9. Configure Ali-OSS cloud storage

    main

    Use ALI_OSS_CONFIG to configure file uploads to Alibaba Cloud OSS.

    Key configuration options:

    • FILE_STORAGE_PROVIDER: Must be set to 'ali-oss'.
    • FILE_KEY_PREFIX: The prefix for file keys (e.g., 'userUpload/{surveyPath}').
    • LINK_EXPIRY_TIME: Duration for which the file link is valid (e.g., '2h').
    • ACCESS_KEY, SECRET_KEY, BUCKET, REGION, ENDPOINT: Alibaba Cloud credentials and region settings.
    • USE_SSL: Boolean to enable SSL.
    const ALI_OSS_CONFIG = {
      FILE_STORAGE_PROVIDER: 'ali-oss',
      IS_PRIVATE_READ: false,
      FILE_KEY_PREFIX: 'userUpload/{surveyPath}',
      NEED_AUTH: true,
      LINK_EXPIRY_TIME: '2h',
      ACCESS_KEY: '',
      SECRET_KEY: '',
      BUCKET: '',
      REGION: '',
      ENDPOINT: '',
      USE_SSL: false,
    };
  10. Define analysis types and data table headers

    main

    The analysis module supports two primary types of views defined in analysisTypeMap: dataTable (数据列表) and separateStatistics (分题统计).

    When using list-based views, the separateItemListHead defines the standard columns for itemized data:

    • text: The option label.
    • count: The quantity.
    • percent: The percentage/proportion.
  11. Configure NPS summary item ranges

    main

    The summaryItemConfig allows defining specific score ranges for NPS (Net Promoter Score) analysis. For the radio-nps type, you can define segments like 'Promoters' (推荐者), 'Passives' (中立者), and 'Detractors' (贬损者) using a between summary type and specifying min and max score boundaries.

    export const summaryItemConfig = {
      'radio-nps': [
        {
          text: '推荐者',
          field: 'id',
          type: 'between',
          max: 10,
          min: 9
        },
        {
          text: '中立者',
          field: 'id',
          type: 'between',
          max: 8,
          min: 7
        },
        {
          text: '贬损者',
          field: 'id',
          type: 'between',
          max: 6,
          min: 0
        }
      ]
    }