# jagath-132/multi-document-chatbot architecture

> Architecture diagram of the GitHub repository jagath-132/multi-document-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jagath-132/multi-document-chatbot
- Repository: https://github.com/jagath-132/multi-document-chatbot

## Overview

##### Project type and purpose
- The core functionality is document retrieval via BM25 and FAISS vector indexes, wrapped in a RESTful chatbot server.

##### File structure
- Top-level files:
- main.py – likely the entry point that launches the server
- apps.py – possibly a hook for WSGI/ASGI hosting
- requirements.txt – declares Python dependencies (e.g., Flask/FastAPI, FAISS, BM25 library)
- client/: holds the static front-end (client/index.html)
- src/chatbot/server/app.py: contains the REST API or web server implementation
- src/chatbot/util/common_util.py: utility functions for text processing or index loading
- storage/: persisting the retrieval indexes (bm25.pkl and the FAISS index files)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Browser<br/>Static Client (index.html + JS)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Python Monolith)"
        direction TB
        EntryPoint["main.py<br/>Server Launcher"]:::server
        HostingHook["apps.py<br/>WSGI/ASGI Hook"]:::server
        subgraph "Chatbot Server"
            direction TB
            API["Chatbot API<br/>(Flask/FastAPI)"]:::server
            Utility["Common Util<br/>(text preprocessing & index loading)"]:::server
            subgraph "Storage Layer"
                direction TB
                BM25["BM25 Index<br/>(bm25.pkl)"]:::storage
                FAISS1["FAISS Index File<br/>(index.faiss)"]:::storage
                FAISS2["FAISS Index Data<br/>(index.pkl)"]:::storage
            end
        end
    end

    %% External Services
    External["External Embedding/LLM Service"]:::external

    %% Connections
    Browser -->|HTTP Request /chat| API
    API -->|calls Utility| Utility
    Utility -->|loads| BM25
    Utility -->|loads| FAISS1
    Utility -->|loads| FAISS2
    API -->|optionally calls| External
    API -->|HTTP Response JSON| Browser

    EntryPoint --> HostingHook
    HostingHook --> API

    %% Click Events
    click Browser "https://github.com/jagath-132/multi-document-chatbot/blob/main/client/index.html"
    click EntryPoint "https://github.com/jagath-132/multi-document-chatbot/blob/main/main.py"
    click HostingHook "https://github.com/jagath-132/multi-document-chatbot/blob/main/apps.py"
    click API "https://github.com/jagath-132/multi-document-chatbot/blob/main/src/chatbot/server/app.py"
    click Utility "https://github.com/jagath-132/multi-document-chatbot/blob/main/src/chatbot/util/common_uitl.py"
    click BM25 "https://github.com/jagath-132/multi-document-chatbot/blob/main/storage/bm25.pkl"
    click FAISS1 "https://github.com/jagath-132/multi-document-chatbot/blob/main/storage/faiss_index/index.faiss"
    click FAISS2 "https://github.com/jagath-132/multi-document-chatbot/blob/main/storage/faiss_index/index.pkl"

    %% Styles
    classDef frontend fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20;
    classDef server fill:#e3f2fd,stroke:#1565c0,color:#0d47a1;
    classDef storage fill:#f5f5f5,stroke:#9e9e9e,color:#616161;
    classDef external fill:#fff3e0,stroke:#ef6c00,color:#e65100;
```
