# mohamedashraf2005/marbert_egyptian-intent-router_with_rag architecture

> Architecture diagram of the GitHub repository mohamedashraf2005/marbert_egyptian-intent-router_with_rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag
- Repository: https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag

## Overview

This is a Streamlit customer-service chatbot for Egyptian Arabic e-commerce and logistics questions. A user submits a message; the app classifies its intent and routes it to a deterministic reply or, for supported complex intents, a retrieval-grounded response. The RAG subsystem chunks a local knowledge file, embeds and searches those chunks, then asks Groq to generate an answer. The README also describes thumbs-up/down feedback for active learning. The app excerpt is partial, so some routing details are supported by the README rather than inspected implementation.

Main entry points: [`app.py`](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py) (Chat and feedback UI), [`rag_engine.py`](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py) (Context chunking), [`data/e_commerce_NLP_BOT.txt`](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/data/e_commerce_NLP_BOT.txt) (E-commerce knowledge), [`classifier.py`](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/classifier.py) (Intent classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_chat_app["Chat and feedback UI<br/>[app.py]"]
  node_feedback["Feedback capture<br/>[app.py]"]
end

subgraph group_routing["Intent routing"]
  node_intent_classifier["Intent classifier<br/>[classifier.py]"]
  node_quick_replies["Static replies<br/>[app.py]"]
  node_intent_data["Intent training data"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_knowledge_file["E-commerce knowledge"]
  node_chunking["Context chunking<br/>[rag_engine.py]"]
  node_semantic_index[("In-memory vector index<br/>[rag_engine.py]")]
  node_retrieval["Intent-filtered retrieval<br/>[rag_engine.py]"]
end

subgraph group_generation["Response generation"]
  node_rag_generation["Grounded response generation<br/>[rag_engine.py]"]
end

node_user(("Customer"))
node_embedding_model["Sentence-transformers model"]
node_groq_api["Groq API"]

node_user -->|"submits query"| node_chat_app
node_chat_app -->|"classifies query"| node_intent_classifier
node_chat_app -->|"routes simple intents"| node_quick_replies
node_chat_app -->|"routes complex intents"| node_rag_generation
node_chat_app -->|"records rating"| node_feedback
node_knowledge_file -->|"provides source text"| node_chunking
node_chunking -->|"indexes chunks"| node_semantic_index
node_chunking -->|"encodes chunks"| node_embedding_model
node_retrieval -->|"encodes query"| node_embedding_model
node_retrieval -->|"searches vectors"| node_semantic_index
node_rag_generation -->|"retrieves context"| node_retrieval
node_rag_generation -->|"requests completion"| node_groq_api

click node_chat_app "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py"
click node_feedback "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py"
click node_intent_classifier "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/classifier.py"
click node_quick_replies "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py"
click node_intent_data "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/data/Egyptian_intents_data.csv"
click node_knowledge_file "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/data/e_commerce_NLP_BOT.txt"
click node_chunking "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py"
click node_semantic_index "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py"
click node_retrieval "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py"
click node_rag_generation "https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat_app,node_feedback toneBlue
class node_intent_classifier,node_quick_replies,node_intent_data toneAmber
class node_knowledge_file,node_chunking,node_semantic_index,node_retrieval,node_groq_api toneMint
class node_rag_generation toneRose
class node_user,node_embedding_model toneIndigo
```

## Components

### Chat experience

- [Chat and feedback UI](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py): `app.py`
- [Feedback capture](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py): `app.py`

### Intent routing

- [Intent classifier](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/classifier.py): `classifier.py`
- [Static replies](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/app.py): `app.py`
- [Intent training data](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/data/Egyptian_intents_data.csv): `data/Egyptian_intents_data.csv`

### Knowledge retrieval

- [E-commerce knowledge](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/data/e_commerce_NLP_BOT.txt): `data/e_commerce_NLP_BOT.txt`
- [Context chunking](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py): `rag_engine.py`
- [In-memory vector index](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py): `rag_engine.py`
- [Intent-filtered retrieval](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py): `rag_engine.py`

### Response generation

- [Grounded response generation](https://github.com/mohamedashraf2005/marbert_egyptian-intent-router_with_rag/blob/main/rag_engine.py): `rag_engine.py`

### Other components

- **Customer**
- **Sentence-transformers model**
- **Groq API**

## Connections

- Customer → Chat and feedback UI: submits query (evidence: `README.md`)
- Chat and feedback UI → Intent classifier: classifies query (evidence: `README.md`)
- Chat and feedback UI → Static replies: routes simple intents (evidence: `README.md`)
- Chat and feedback UI → Grounded response generation: routes complex intents (evidence: `app.py`)
- Chat and feedback UI → Feedback capture: records rating (evidence: `README.md`)
- E-commerce knowledge → Context chunking: provides source text (evidence: `rag_engine.py`)
- Context chunking → In-memory vector index: indexes chunks (evidence: `rag_engine.py`)
- Context chunking → Sentence-transformers model: encodes chunks (evidence: `rag_engine.py`)
- Intent-filtered retrieval → Sentence-transformers model: encodes query (evidence: `rag_engine.py`)
- Intent-filtered retrieval → In-memory vector index: searches vectors (evidence: `rag_engine.py`)
- Grounded response generation → Intent-filtered retrieval: retrieves context (evidence: `rag_engine.py`)
- Grounded response generation → Groq API: requests completion (evidence: `rag_engine.py`)
