# abdulraqib20/ai-powered-customer-support-agent architecture

> Architecture diagram of the GitHub repository abdulraqib20/ai-powered-customer-support-agent, 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/abdulraqib20/ai-powered-customer-support-agent
- Repository: https://github.com/abdulraqib20/ai-powered-customer-support-agent

## Overview

##### Project Type and Purpose
- This is an AI-driven customer support solution tailored for the Nigerian e-commerce market.
- The system simulates customer profiles and conversation scenarios using advanced AI models (Meta's Llama 3.3 70-B, Google’s embedding models), employs a memory layer (mem0) for continuity, and leverages Qdrant for efficient similarity searches.

##### File Structure Analysis
- Top-Level Files and Folders:
- .env_example, .gitignore, .secrets.baseline, and requirements.txt indicate standard configuration, security, deployment, and dependency management practices.
- The “config” directory (with appconfig.py) likely holds application settings and credentials.
- “deploy.ps1” denotes a deployment script for Windows PowerShell, hinting at simplified manual or scripted deployment processes.
- The “src” directory holds the main project code (multiple Python scripts such as main.py, main2.py, trial.py). These are likely entry points or variations in execution.
- Although the project is self-contained, its integration with several external services (e.g., Qdrant, Google Embedding API, mem0, and Meta’s Llama) is key.

a. Main Components:
- Customer Simulation Engine: Responsible for generating synthetic customer profiles.
- AI Response Engine: Uses Meta’s Llama 3.3 70-B model to process and generate intelligent responses.
- Memory Module (mem0): Manages conversation history to ensure context continuity.
- Similarity Search Component: Qdrant Vector DB for fast context-aware retrieval of past interactions.
- Embedding Conversion Service: Uses Google’s embedding models for converting text into vectors.
- Configuration/Deployment Layer: Representing configuration settings (from config/appconfig.py, .env file) and deployment scripts (deploy.ps1).

b. Relationships and Interactions:
- The system starts with the Customer Simulation Engine generating or selecting a specific customer profile.
- Customer queries (or simulated messages) are sent to the AI Response Engine.
- For context enrichment, the Memory Module (mem0) provides conversation history.
- When needed, customer queries are processed via Google's Embedding Conversion Service to get vector representations.
- The Qdrant Vector DB is queried with these vectors to retrieve relevant past interaction records, feeding back into the response generation.
- Configuration settings are loaded from the “config” directory and environment files, which guide credentials and API keys for each external service.
- Data flows back and forth among these components through well-defined interfaces.

c. Architectural Patterns and Design Principles:
- Use of external services and how they integrate with the internal core logic.
- Though the code is consolidated in a single repository, treat each external service as a distinct component for clarity.

d. Incorporate Relevant Technologies and Frameworks:
- Meta’s Llama 3.3 70-B model (for natural language processing).
- mem0 as the persistence layer for conversation memory.
- Qdrant for vector-based similarity searches.
- Google’s Embedding models for text-to-vector conversion.
- Python (as seen by the .py files in the “src” directory) along with configuration management.
- Deployment considerations through scripts like deploy.ps1.

##### Instructing the Principal Software Engineer
- Clear labels for each component (e.g., “Customer Simulation Engine,” “AI Response Engine,” “Memory Module (mem0),” “Qdrant Vector DB,” “Google Embedding Service”).
- Customer query or synthetic profile → AI Response Engine.
- AI Response Engine ↔ Memory Module (bidirectional for context).
- AI Response Engine → Google Embedding Service → Qdrant Vector DB → AI Response Engine.
- Clearly demarcate the configuration and deployment aspects, showing where settings (from .env and config/appconfig.py) influence service access.

- The core AI modules (including Meta's Llama and integrating memory via mem0),
- The vector and embedding services (Google Embedding models and Qdrant),
- The simulation engine responsible for generating customer profiles,
- And configuration/deployment components.
This holistic view will make it easier to understand interactions and dependencies while ensuring every architectural element is represented for the AI-powered customer support functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration/Deployment Layer Subgraph
    subgraph "Configuration/Deployment Layer"
        AppConfig["AppConfig"]:::config
        Env[".env_example"]:::config
        Deploy["deploy.ps1"]:::config
    end

    %% Main AI System Components
    SimEngine["Customer Simulation Engine"]:::internal
    AIEngine["AI Response Engine"]:::internal
    MemoryModule["Memory Module (mem0)"]:::internal
    Embedding["Google Embedding Service"]:::external
    Qdrant["Qdrant Vector DB"]:::external

    %% Data Flow
    SimEngine -->|"sends_queries"| AIEngine
    AIEngine <-->|"context_exchange"| MemoryModule
    AIEngine -->|"vectorize_query"| Embedding
    Embedding -->|"search_similar"| Qdrant
    Qdrant -->|"retrieved_context"| AIEngine

    %% Configuration Influence (dotted connections)
    AppConfig -.->|"configures"| AIEngine
    Env       -.->|"configures"| AIEngine
    Deploy    -.->|"configures"| AIEngine

    AppConfig -.->|"configures"| Embedding
    Env       -.->|"configures"| Embedding
    Deploy    -.->|"configures"| Embedding

    AppConfig -.->|"configures"| Qdrant
    Env       -.->|"configures"| Qdrant
    Deploy    -.->|"configures"| Qdrant

    %% Click Events
    click SimEngine "https://github.com/abdulraqib20/ai-powered-customer-support-agent/blob/main/src/main.py"
    click AIEngine "https://github.com/abdulraqib20/ai-powered-customer-support-agent/blob/main/src/main2.py"
    click AppConfig "https://github.com/abdulraqib20/ai-powered-customer-support-agent/blob/main/config/appconfig.py"
    click Env "https://github.com/abdulraqib20/ai-powered-customer-support-agent/blob/main/.env_example"
    click Deploy "https://github.com/abdulraqib20/ai-powered-customer-support-agent/blob/main/deploy.ps1"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#007bff,stroke-width:2px;
    classDef external fill:#ffe6cc,stroke:#ff8c1a,stroke-width:2px;
    classDef config fill:#d4edda,stroke:#28a745,stroke-width:2px;
```
