# gupta-nakul/airline-customer-support-rag architecture

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

- Interactive diagram: https://gitdiagram.com/gupta-nakul/airline-customer-support-rag
- Repository: https://github.com/gupta-nakul/airline-customer-support-rag

## Overview

##### Main Components

- Frontend Application:
- Located under the "frontend" folder.
- Built with modern web technologies (React, TypeScript).
- Communicates with the backend via APIs.

- Backend Service:
- Found under the "backend" directory.
- Contains two parts:
a. The core routing and chatbot logic (src/app.py, src/chatbot.py).
b. The "agentic_system" modules and tools that build various assistants, graph structures, and manage state (build_assistants.py, build_graph.py, etc.).
- Handles business logic and integrates external APIs (possibly LLM APIs, airline policy lookups, etc.) using API keys declared in the .env file.

- Data Preparation Module:
- Located in the "data_prepare" directory.
- Scripts to download data, prepare a vector database (prepare_vector_db.py), and update the database dates (update_db_date.py).
- Ensures that the system uses up-to-date airline data and booking information.

- Infrastructure & Deployment:
- Docker files in "backend", "data_prepare", and "frontend" directories indicate containerized deployment.
- A docker-compose.yml file suggests orchestration between containers.

- External Services & APIs:
- External LLM services (OpenAI, LangChain) and airline-related search APIs (Tavily Search).
- These are configured using environment variables in the .env file.

##### Relationships and Interactions

- Frontend communicates with the Backend’s API endpoints to send user queries and receive responses.
- Backend serves as the brain:
- It interacts with “agentic_system” components, which likely construct the structured logic for handling questions (using build_prompts, build_runnables, etc.).
- It utilizes a range of "tools" (for flights, hotels, rental cars, excursions, etc.) to answer specific customer inquiries.
- It integrates with external LLM services to produce augmented generated responses based on dynamic data and airline policies.
- Data Preparation module is used periodically (or as a scheduled task) to fetch, preprocess, and vectorize data needed by the RAG pipeline, ensuring that the chatbot delivers up-to-date information.

##### Important Architectural Patterns and Design Principles

- Separation of concerns:
- Clear demarcation between front-end, business logic (backend), and data preprocessing.

- Microservices-like modularity within the backend:
- The segmentation into “agentic_system”, “tools”, and “utils” indicates an organized approach where each module performs its designated role.

- Containerization:
- Usage of Dockerfiles and docker-compose points to a containerized deployment strategy for isolation and ease of maintenance.

##### Technologies, Frameworks, and Libraries

- Frontend: React with TypeScript.
- Backend: Python (with modules for chatbot logic and agentic systems).
- Data Management: Likely the use of a vector database (as indicated by prepare_vector_db.py) and structured data management for real-time airline information.
- External API integrations: OpenAI, LangChain, and Tavily Search.
- Deployment: Docker and Docker Compose.

## Diagram (Mermaid)

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

    %% Backend Layer
    subgraph "Backend Layer"
        subgraph "Core Services"
            API["API Service"]:::backend
            CB["Chatbot Logic"]:::backend
        end
        subgraph "Auxiliary Modules"
            AS["Agentic System Modules"]:::agentic
            TOOLS["Customer Inquiry Tools"]:::tools
        end
    end

    %% Data Preparation Layer
    subgraph "Data Preparation Layer"
        DP["Data Preparation Module"]:::data
    end

    %% External Services
    subgraph "External Services & APIs"
        EXT["External LLM & Airline APIs"]:::external
    end

    %% Deployment & Infrastructure
    subgraph "Deployment Details"
        DC1["Docker Compose"]:::infra
        DB["Dockerfile Backend"]:::infra
        DF["Dockerfile Frontend"]:::infra
        DP_DF["Dockerfile DataPrep"]:::infra
        ENV["Environment Config (.env)"]:::infra
    end

    %% Deployment Orchestration Node
    INFRA["Deployment & Infrastructure"]:::infra

    %% Connections: Frontend -> Backend
    FE -->|"sends request"| API
    API -->|"routes to"| CB
    CB -->|"invokes"| AS
    CB -->|"invokes"| TOOLS
    AS -->|"calls"| EXT
    TOOLS -->|"calls"| EXT
    DP -->|"provides data"| CB

    %% Deployment orchestration connections
    INFRA ---|"orchestrates"| FE
    INFRA ---|"orchestrates"| API
    INFRA ---|"orchestrates"| CB
    INFRA ---|"orchestrates"| AS
    INFRA ---|"orchestrates"| TOOLS
    INFRA ---|"orchestrates"| DP
    INFRA -->|"manages"| DC1
    INFRA -->|"manages"| DB
    INFRA -->|"manages"| DF
    INFRA -->|"manages"| DP_DF
    INFRA -->|"manages"| ENV

    %% Styling Classes
    classDef frontend fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef agentic fill:#d5f5e3,stroke:#1d8348,stroke-width:2px;
    classDef tools fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef data fill:#fdebd0,stroke:#e67e22,stroke-width:2px;
    classDef external fill:#e6e6fa,stroke:#6a5acd,stroke-width:2px;
    classDef infra fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;

    %% Click Events for Component Mapping
    click FE "https://github.com/gupta-nakul/airline-customer-support-rag/tree/main/frontend/"
    click API "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/backend/src/app.py"
    click CB "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/backend/src/chatbot.py"
    click AS "https://github.com/gupta-nakul/airline-customer-support-rag/tree/main/backend/agentic_system/"
    click TOOLS "https://github.com/gupta-nakul/airline-customer-support-rag/tree/main/backend/tools/"
    click DP "https://github.com/gupta-nakul/airline-customer-support-rag/tree/main/data_prepare/"
    click DC1 "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/docker-compose.yml"
    click DB "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/backend/Dockerfile.backend"
    click DF "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/frontend/Dockerfile.frontend"
    click DP_DF "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/data_prepare/Dockerfile.prepare_data"
    click ENV "https://github.com/gupta-nakul/airline-customer-support-rag/blob/main/.env"
```
