# lesifpe/iabadie architecture

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

- Interactive diagram: https://gitdiagram.com/lesifpe/iabadie
- Repository: https://github.com/lesifpe/iabadie

## Overview

IAbadie answers questions about an ADS course using a chat interface, semantic FAQ retrieval, and natural-language rewriting. The principal workflow is user question → Streamlit chat → FAISS search over FAQ embeddings → local response generation → displayed answer with the original FAQ source and links. A separate indexing workflow embeds FAQ questions into the FAISS index. The README describes Ollama, but the sampled response code instead uses llama.cpp and downloads a model from Hugging Face; the graph follows the sampled implementation. Other unsampled capabilities are not inferred.

Main entry points: [`src/search.py`](https://github.com/lesifpe/iabadie/blob/main/src/search.py) (Semantic search), [`src/app.py`](https://github.com/lesifpe/iabadie/blob/main/src/app.py) (Chat interface), [`src/generate_embeddings.py`](https://github.com/lesifpe/iabadie/blob/main/src/generate_embeddings.py) (Embedding builder), [`src/generate_response.py`](https://github.com/lesifpe/iabadie/blob/main/src/generate_response.py) (Response rewriter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat experience"]
  node_chat_app["Chat interface<br/>[app.py]"]
end

subgraph group_retrieval["FAQ retrieval"]
  node_faq["FAQ corpus<br/>[faq.json]"]
  node_embed_builder["Embedding builder"]
  node_embed_model["Sentence transformer"]
  node_vector_index[("FAISS index<br/>[faq.index]")]
  node_search["Semantic search<br/>[search.py]"]
end

subgraph group_generation["Response generation"]
  node_rewrite["Response rewriter"]
  node_local_llm["Local LLM inference"]
end

node_user(("Question asker"))
node_model_host["Hugging Face model host"]

node_user -->|"asks question"| node_chat_app
node_chat_app -->|"queries FAQ"| node_search
node_search -->|"reads answers"| node_faq
node_search -->|"searches vectors"| node_vector_index
node_search -->|"encodes query"| node_embed_model
node_search -->|"returns matches"| node_chat_app
node_chat_app -->|"rewrites answer"| node_rewrite
node_rewrite -->|"generates text"| node_local_llm
node_rewrite -->|"downloads model"| node_model_host
node_chat_app -->|"shows answer"| node_user
node_embed_builder -->|"reads questions"| node_faq
node_embed_builder -->|"encodes questions"| node_embed_model
node_embed_builder -->|"writes vectors"| node_vector_index

click node_chat_app "https://github.com/lesifpe/iabadie/blob/main/src/app.py"
click node_faq "https://github.com/lesifpe/iabadie/blob/main/data/faq.json"
click node_embed_builder "https://github.com/lesifpe/iabadie/blob/main/src/generate_embeddings.py"
click node_vector_index "https://github.com/lesifpe/iabadie/blob/main/embeddings/faq.index"
click node_search "https://github.com/lesifpe/iabadie/blob/main/src/search.py"
click node_rewrite "https://github.com/lesifpe/iabadie/blob/main/src/generate_response.py"
click node_local_llm "https://github.com/lesifpe/iabadie/blob/main/src/generate_response.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 toneBlue
class node_faq,node_embed_builder,node_embed_model,node_vector_index,node_search toneAmber
class node_rewrite,node_local_llm toneMint
class node_user,node_model_host toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/lesifpe/iabadie/blob/main/src/app.py): `src/app.py`

### FAQ retrieval

- [FAQ corpus](https://github.com/lesifpe/iabadie/blob/main/data/faq.json): `data/faq.json`
- [Embedding builder](https://github.com/lesifpe/iabadie/blob/main/src/generate_embeddings.py): `src/generate_embeddings.py`
- **Sentence transformer**
- [FAISS index](https://github.com/lesifpe/iabadie/blob/main/embeddings/faq.index): `embeddings/faq.index`
- [Semantic search](https://github.com/lesifpe/iabadie/blob/main/src/search.py): `src/search.py`

### Response generation

- [Response rewriter](https://github.com/lesifpe/iabadie/blob/main/src/generate_response.py): `src/generate_response.py`
- [Local LLM inference](https://github.com/lesifpe/iabadie/blob/main/src/generate_response.py): `src/generate_response.py`

### Other components

- **Question asker**
- **Hugging Face model host**

## Connections

- Question asker → Chat interface: asks question (evidence: `README.md`)
- Chat interface → Semantic search: queries FAQ (evidence: `src/app.py`)
- Semantic search → FAQ corpus: reads answers (evidence: `src/search.py`)
- Semantic search → FAISS index: searches vectors (evidence: `src/search.py`)
- Semantic search → Sentence transformer: encodes query (evidence: `src/search.py`)
- Semantic search → Chat interface: returns matches (evidence: `src/app.py`)
- Chat interface → Response rewriter: rewrites answer (evidence: `src/app.py`)
- Response rewriter → Local LLM inference: generates text (evidence: `src/generate_response.py`)
- Response rewriter → Hugging Face model host: downloads model (evidence: `src/generate_response.py`)
- Chat interface → Question asker: shows answer (evidence: `src/app.py`)
- Embedding builder → FAQ corpus: reads questions (evidence: `src/generate_embeddings.py`)
- Embedding builder → Sentence transformer: encodes questions (evidence: `src/generate_embeddings.py`)
- Embedding builder → FAISS index: writes vectors (evidence: `src/generate_embeddings.py`)
