# answerlink/intelliq architecture

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

- Interactive diagram: https://gitdiagram.com/answerlink/intelliq
- Repository: https://github.com/answerlink/intelliq

## Overview

##### Project Type and Purpose
- IntelliQ is an open-source conversational AI system designed to manage multi-turn dialogues by leveraging intent recognition and slot filling.
- The README indicates that it is aimed at providing developers a flexible framework for building and optimizing conversational (chatbot) applications, with built-in support for API-based integrations (e.g., to external LLMs).

##### File Structure
- At the top level, key files include app.py for application startup, configuration files within the “config” directory, a “models” directory for the chatbot model logic, and “scene_config” and “scene_processor” directories that manage dialogue scenes and their processing pipelines.
- The “frontend” and “demo” directories hold the static assets (HTML, JS) for visual debugging and interaction, implying a separation between backend processing and frontend presentation.
- The “utils” directory contains various helper scripts (date handling, file utilities, prompt-related functions) to support the core application logic.
- This modular structure suggests a clear separation of concerns: configuration, dialogue processing, model integration, and presentation.

##### README for Additional Insights
- The README describes key features like multi-turn dialogue management, intent recognition, and slot filling – underscoring the role of the “models”, “scene_config”, and “scene_processor” modules.
- Installation steps and configuration hints (modifying API keys and endpoint URLs) confirm that configuration management (via “config”) is central.

a. Main Components:
- Frontend/UI Module: Represented by the “frontend” (app.js, rec_demo.html) and demo HTML files; these serve the web interface for user interactions.
- Backend/Application Layer: Initiated by app.py; this is the core server that orchestrates requests.
- Configuration Module: “config” for global settings and logging configurations.
- Models Module: “models/chatbot_model.py” that likely interfaces with external LLM endpoints using provided API keys.
- Scene Configuration Module: “scene_config,” containing JSON templates, scene-specific prompts, and custom scene configurations.
- Scene Processing Module: “scene_processor” (with its “impl” subdirectory) which encapsulates the dialogue processing logic including intent recognition and slot filling.
- Utility Modules: “utils” serving as supporting functions for data formatting, file operations, prompt utilities, etc.

b. Relationships and Interactions:
- The Frontend sends user queries (via demo/user_input.html or frontend/web components) to the backend (app.py).
- The backend first loads settings and initializes necessary resources via “config” and “utils”.
- Incoming requests are processed by the scene processing layer which uses scene configurations (from “scene_config”) and calls upon the models (via “models/chatbot_model.py”) to generate responses. The processing layer (scene_processor) distinguishes the flow into stages, applying common processing logic (from scene_processor/impl/common_processor.py).
- The response is then sent back to the frontend for user display.
- External interactions (API calls to LLM services) are mediated using configuration parameters (API_KEY, GPT_URL).

c. Architectural Patterns and Design Principles:
- Modular and layered design: Each functionality (configuration, model handling, processing, utility) is encapsulated in its own module and communicates via well-defined interfaces.
- Separation of concerns: Clear division between presentation (frontend/demo) and business logic (backend processing).
- Extensibility: The “scene_config” and “scene_processor” modules are highly abstracted, suggesting an architecture that allows easy modifications to dialogue flows and integration with various LLMs.

d. Relevant Technologies:
- Python as the primary language.
- JavaScript/HTML for the frontend.
- Use of JSON for configuration and scene definitions.
- Likely integration with external LLMs (e.g., ChatGPT API) via endpoint configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    FE["Frontend UI"]:::frontend

    %% Backend/Application Layer
    AS["Application Server (app.py)"]:::backend

    %% Configuration Module
    CN["Configuration & Logging"]:::config

    %% Utility Modules
    UT["Utility Functions"]:::utility

    %% Scene Processing Module
    DP["Dialogue Processor"]:::processor

    %% Scene Configuration Module
    SC["Scene Configuration"]:::scene

    %% Models Module
    CM["Chatbot Model"]:::model

    %% Data Flow
    FE -->|"sends user query"| AS
    AS -->|"loads settings"| CN
    AS -->|"calls helper functions"| UT
    AS -->|"initiates dialogue processing"| DP
    DP -->|"retrieves scene details"| SC
    DP -->|"integrates LLM API"| CM
    CM -->|"returns generated response"| DP
    DP -->|"sends response"| AS
    AS -->|"delivers response"| FE

    %% Annotations for key interactions
    %% e.g., within Dialogue Processor: Intent Recognition, Slot Filling, API call to external LLM
    DP ---|"IntentRecognition/SlotFilling"| SC
    DP ---|"LLM API call"| CM

    %% Click Events for Frontend/UI Module
    click FE "https://github.com/answerlink/intelliq/blob/main/demo/user_input.html"
    click FE "https://github.com/answerlink/intelliq/blob/main/frontend/app.js"
    click FE "https://github.com/answerlink/intelliq/blob/main/frontend/rec_demo.html"

    %% Click Events for Backend/Application Layer
    click AS "https://github.com/answerlink/intelliq/blob/main/app.py"

    %% Click Events for Configuration Module
    click CN "https://github.com/answerlink/intelliq/blob/main/config/__init__.py"
    click CN "https://github.com/answerlink/intelliq/blob/main/config/log_config.py"

    %% Click Events for Models Module
    click CM "https://github.com/answerlink/intelliq/blob/main/models/chatbot_model.py"

    %% Click Events for Scene Configuration Module
    click SC "https://github.com/answerlink/intelliq/blob/main/scene_config/conf/scene_custom1.json"
    click SC "https://github.com/answerlink/intelliq/blob/main/scene_config/scene_templates.json"
    click SC "https://github.com/answerlink/intelliq/blob/main/scene_config/scene_prompts.py"

    %% Click Events for Scene Processing Module
    click DP "https://github.com/answerlink/intelliq/blob/main/scene_processor/scene_processor.py"
    click DP "https://github.com/answerlink/intelliq/blob/main/scene_processor/impl/common_processor.py"

    %% Click Events for Utility Modules
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/app_init.py"
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/data_format_utils.py"
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/date_utils.py"
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/file_utils.py"
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/helpers.py"
    click UT "https://github.com/answerlink/intelliq/blob/main/utils/prompt_utils.py"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#084298,stroke-width:2px;
    classDef backend fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef config fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef processor fill:#ead1dc,stroke:#b8548e,stroke-width:2px;
    classDef scene fill:#d0e0e3,stroke:#115740,stroke-width:2px;
    classDef model fill:#f4cccc,stroke:#990000,stroke-width:2px;
    classDef utility fill:#fce5cd,stroke:#b45f06,stroke-width:2px;
```
