# as-aigc/as-aigfaq architecture

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

- Interactive diagram: https://gitdiagram.com/as-aigc/as-aigfaq
- Repository: https://github.com/as-aigc/as-aigfaq

## Overview

##### Project type and purpose
- This is a command-line Python toolkit that automates generation of FAQs from regulatory or service-context text.
- It is not a web app; rather it’s a pipeline of Python scripts that call external LLM APIs (OpenAI/ChatGPT or TAIDE) to:
1. generate candidate questions (AS-1 scripts),
2. answer them,
3. translate answers into multiple languages (AS-2 scripts),
4. package everything into static HTML (AS-3 scripts).

##### File structure
- Top-level scripts:
- AS-1-AIGFAQ.py    / AS-1-AIGFAQ-TAIDE.py
→ prompts LLM to generate Q&A pairs.
- AS-2-AIGFAQ-to-i18n.py / AS-2-AIGFAQ-TAIDE-to-i18n.py
→ translates Q&A CSV into many languages via LLM.
- AS-3-AIGFAQ-to-HTML.py / AS-3-AIGFAQ-TAIDE-to-HTML.py
→ reads CSV(s) and emits static HTML pages.
- Config & dependencies:
- config.py.example – contains API keys, model settings.
- requirements.txt – Python dependencies (openai, requests, pandas, etc.).
- examples/ – directory of sample CSV and HTML outputs across domains and locales.
- Notebook:
- colab_notebook_AS_AIGFAQ.ipynb – interactive demo for ChatGPT variant.

##### Key insights from README
- The core “architecture” is a linear multi-stage pipeline:
Input text (legal/regulations) → Q-generation → Answering → Translation → HTML rendering.
- Two interchangeable backends: ChatGPT API or TAIDE API.
- No persistent database; outputs are flat files (CSV, HTML).

##### Detailed capture of essential elements
- Config.py feeding credentials/parameters into each stage
- Both CSV and HTML as output artifacts
- API calls with “HTTP POST /v1/chat/completions” or “TAIDE endpoint”
- Requirements.txt as build/deployment dependency

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer Interfaces
    subgraph "Developer Interfaces"
        CLI["CLI Interface"]:::code
        Notebook["Colab Notebook"]:::code
    end

    %% Input Source
    Input["Context Document\n(examples/AS-ALL.txt)"]:::storage

    %% Pipeline Stages
    subgraph "Pipeline Stages"
        direction TB
        Stage1["AS-1: FAQ Generator"]:::stage
        Stage2["AS-2: Translator (i18n)"]:::stage
        Stage3["AS-3: HTML Renderer"]:::stage
    end

    %% External LLM Backends
    subgraph "LLM Backends"
        direction TB
        ChatGPT["OpenAI ChatGPT API\n(POST /v1/chat/completions)"]:::external
        TAIDE["TAIDE API Endpoint"]:::external
    end

    %% Configuration & Dependencies
    subgraph "Config & Dependencies"
        Config["Configuration Module\n(config.py.example)"]:::config
        Req["Dependency Manifest\n(requirements.txt)"]:::doc
        CSS["Static Assets\n(FAQ.css)"]:::doc
        README["Project Documentation\n(README.md)"]:::doc
        License["License File\n(LICENSE)"]:::doc
    end

    %% Outputs
    Outputs["Output Artifacts\n(CSV & HTML)\n(examples/)"]:::storage

    %% Flow Connections
    CLI --> Input
    Notebook --> Input
    Input --> Stage1
    Stage1 --> Stage2
    Stage2 --> Stage3
    Stage3 --> Outputs

    %% Config feeding stages
    Config --> Stage1
    Config --> Stage2
    Config --> Stage3

    %% Dependencies & docs references
    Req -->|provides libs| Stage1
    Req -->|provides libs| Stage2
    Req -->|provides libs| Stage3
    CSS --> Stage3
    README -.-> CLI
    README -.-> Notebook
    LICENSE -.-> README

    %% LLM backend connections
    Stage1 -->|calls| ChatGPT
    Stage1 -->|calls| TAIDE
    Stage2 -->|calls| ChatGPT
    Stage2 -->|calls| TAIDE
    Stage3 -->|templates| CSS

    %% Click Events
    click Input "https://github.com/as-aigc/as-aigfaq/blob/main/examples/AS-ALL.txt"
    click Stage1 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-1-AIGFAQ.py"
    click Stage1 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-1-AIGFAQ-TAIDE.py"
    click Stage2 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-2-AIGFAQ-to-i18n.py"
    click Stage2 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-2-AIGFAQ-TAIDE-to-i18n.py"
    click Stage3 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-3-AIGFAQ-to-HTML.py"
    click Stage3 "https://github.com/as-aigc/as-aigfaq/blob/main/AS-3-AIGFAQ-TAIDE-to-HTML.py"
    click Config "https://github.com/as-aigc/as-aigfaq/blob/main/config.py.example"
    click Req "https://github.com/as-aigc/as-aigfaq/blob/main/requirements.txt"
    click CSS "https://github.com/as-aigc/as-aigfaq/blob/main/FAQ.css"
    click Outputs "https://github.com/as-aigc/as-aigfaq/tree/main/examples/"
    click Notebook "https://github.com/as-aigc/as-aigfaq/blob/main/colab_notebook_AS_AIGFAQ.ipynb"
    click README "https://github.com/as-aigc/as-aigfaq/blob/main/README.md"
    click License "https://github.com/as-aigc/as-aigfaq/tree/main/LICENSE"

    %% Styles
    classDef stage fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef external fill:#FFE0B2,stroke:#E65100,stroke-width:2px,shape:cloud
    classDef storage fill:#E0F7FA,stroke:#006064,stroke-width:2px,shape:cylinder
    classDef config fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px,shape:hexagon
    classDef doc fill:#FFF9C4,stroke:#F9A825,stroke-width:2px
    classDef code fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
```
