# abdullahtarek/coffee_shop_customer_service_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/abdullahtarek/coffee_shop_customer_service_chatbot
- Repository: https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot

## Overview

##### Project Type and Purpose
- This is a full-stack, agent-based chatbot project integrated into a React Native coffee shop mobile app. It leverages AI, NLP, and recommendation systems to handle customer inquiries and orders.
- The README emphasizes key functions such as order placement, detailed menu queries via a Retrieval-Augmented Generation system, personalized recommendations (market basket analysis), and safe query filtering via a Guard Agent.

##### File Structure
- Notice two primary components:
- The “coffee_shop_app” directory, containing the React Native mobile app code (with pages, components, assets, configuration, etc.), which forms the frontend.
- The “python_code” directory, which contains the chatbot’s backend and service components. This includes an “api” folder (with various specialized agent modules like classification, order taking, details fetching, etc.), datasets for training, and scripts/notebooks for building the vector database and training recommendation engines.
- The top-level organization clearly separates the mobile frontend from the agent-based backend system, suggesting a microservices-style architecture where components can be deployed, scaled, and managed independently.

##### Insights from the README
- The README details the agent roles: Guard Agent, Order Taking Agent, Details (RAG) Agent, Recommendation Agent, and Classification Agent. It explains how these agents interact sequentially (or in a pipeline) for processing customer queries.
- There is clear emphasis on integrating third-party services and technologies like RunPod for LLM deployment, Pinecone for the vector database, and Firebase for data storage.

a. Main Components:
- Frontend: React Native Coffee Shop Mobile App (UI screens like Landing Page, Home, Item Details, Cart, Chatbot Interface)
- Backend API: Python-based chatbot API hosting various specialized agents.
- Specialized Agents:
– Guard Agent (first filter for queries)
– Classification Agent (routing requests)
– Order Taking Agent (guided order placement)
– Details (RAG) Agent (menu and product information retrieval using a vector database)
– Recommendation Agent (providing product recommendations via market basket analysis)
- Database / External Services:
– Vector Database (e.g., Pinecone) for the RAG component.
– Firebase (for app data management).
– Datasets and training components (as seen from notebooks and dataset files).

b. Relationships and Interactions:
– The mobile app sends customer queries to the API.
– The Guard Agent first inspects the query; valid queries flow to the Classification Agent.
– The Classification Agent routes the query to either the Order Taking Agent, the Details Agent, or the Recommendation Agent (with possible feedback loops—for example, an order may trigger a recommendation).
– Communication between the Details Agent and the vector database should be indicated.
– Firebase service can be shown as a separate data store linked to the app for order management/credits.
- That the Python API is a central hub that integrates the specialized agents and supports the chatbot’s logic.

c. Important Architectural Patterns and Design Principles:
- Modular, agent-based architecture where each agent has a dedicated responsibility.
- Pipeline processing of incoming queries — from validation (Guard), categorization (Classification), and then specific query handling (Order, Details, Recommendation).
- Clear separation of concerns between the frontend mobile app and the AI-driven backend, enabling independent deployment and scaling.
- Use of microservices ideas within the API agent modules that can be independently updated or replaced.

d. Relevant Technologies:
- Frontend: React Native
- Backend: Python (APIs, Flask/FastAPI if applicable, plus agent modules)
- AI and NLP: Large Language Models, RAG system
- External services: RunPod, Firebase, Pinecone
- Toolchaining: Docker, build scripts, and configurations (like environment files)
- Additional supporting libraries and configuration files (found in the file tree)

##### Detailed Capture
- Don’t shy away from breaking down the system into as many relevant parts as possible. Even if some components (like utility scripts or hooks) are not central, the main architectural flow must be captured with precision.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        MA["Mobile App (React Native)"]:::frontend
        UIS["UI Screens (Landing, Home, Chat, Order)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        API["Chatbot API (Python)"]:::backend
        GA["Guard Agent"]:::agent
        CA["Classification Agent"]:::agent
        OTA["Order Taking Agent"]:::agent
        DA["Details (RAG) Agent"]:::agent
        RA["Recommendation Agent"]:::agent
    end

    %% External Services
    VDB["Vector Database (Pinecone)"]:::database
    FB["Firebase"]:::external
    RP["RunPod (LLM Deployment)"]:::external
    DT["Datasets & Training Materials"]:::external

    %% Data Flow from Frontend to Backend
    MA -->|"sends query"| API
    UIS -->|"interacts with"| MA

    %% Query Processing within Backend
    API -->|"routes to"| GA
    GA -->|"filters"| CA
    CA -->|"routes to"| OTA
    CA -->|"routes to"| DA
    CA -->|"routes to"| RA
    OTA -->|"may trigger"| RA

    %% Backend External Interactions
    DA -->|"queries"| VDB
    API -->|"integrates LLM via"| RP

    %% Frontend External Services
    MA -->|"stores data"| FB

    %% Datasets & Training used for backend preparation
    API -->|"trained on"| DT

    %% Click Events
    click MA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/tree/main/coffee_shop_app"
    click UIS "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/tree/main/coffee_shop_app/app"
    click API "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/tree/main/python_code/api"
    click GA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/python_code/api/agents/guard_agent.py"
    click CA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/python_code/api/agents/classification_agent.py"
    click OTA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/python_code/api/agents/order_taking_agent.py"
    click DA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/python_code/api/agents/details_agent.py"
    click RA "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/python_code/api/agents/recommendation_agent.py"
    click FB "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/coffee_shop_app/config/firebaseConfig.ts"
    click RP "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/blob/main/coffee_shop_app/config/runpodConfigs.ts"
    click DT "https://github.com/abdullahtarek/coffee_shop_customer_service_chatbot/tree/main/python_code/dataset"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef agent fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#784212,stroke-width:2px;
    classDef database fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
