# bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot architecture

> Architecture diagram of the GitHub repository bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot
- Repository: https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot

## Overview

AdInsight AI lets a marketing analyst upload a PDF or CSV campaign report, then ask questions and receive context-grounded answers. The upload path parses and chunks the report, builds an in-memory FAISS index, and reports indexing metadata; the chat path retrieves relevant chunks and sends a prompt to Gemini. The React interface includes upload, chat, status, suggested questions, and message rendering. The graph follows shown calls and documented endpoints; reset is an API capability, while the UI reset shown only clears local state.

Main entry points: [`backend/main.py`](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/main.py) (FastAPI Endpoints), [`backend/rag_pipeline.py`](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/rag_pipeline.py) (RAG Pipeline), [`frontend/src/App.jsx`](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/App.jsx) (Application Shell), [`frontend/src/components/ChatWindow.jsx`](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/ChatWindow.jsx) (Chat Window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Analyst Interface"]
  node_app["Application Shell<br/>[App.jsx]"]
  node_uploader["Report Uploader<br/>[FileUploader.jsx]"]
  node_chat["Chat Window<br/>[ChatWindow.jsx]"]
  node_sidebar["Report Sidebar<br/>[Sidebar.jsx]"]
  node_message["Message Renderer<br/>[MessageBubble.jsx]"]
end

subgraph group_api["API And Session"]
  node_api_main["FastAPI Endpoints<br/>[main.py]"]
  node_session[("In-Memory Session<br/>[main.py]")]
end

subgraph group_ingestion["Report Indexing"]
  node_parser["PDF CSV Parser<br/>[file_parser.py]"]
  node_chunker["Text Chunking<br/>[file_parser.py]"]
  node_faiss[("FAISS Vector Store<br/>[vector_store.py]")]
  node_embeddings["HuggingFace Embeddings"]
end

subgraph group_answers["Retrieval And Answers"]
  node_rag["RAG Pipeline<br/>[rag_pipeline.py]"]
  node_llm["Gemini Handler<br/>[llm_handler.py]"]
end

node_analyst(("Marketing Analyst"))
node_gemini["Gemini Model API"]

node_analyst -->|"selects report"| node_uploader
node_uploader -->|"uploads file"| node_api_main
node_api_main -->|"parses bytes"| node_parser
node_parser -->|"splits text"| node_chunker
node_api_main -->|"builds index"| node_rag
node_rag -->|"creates store"| node_faiss
node_faiss -->|"embeds chunks"| node_embeddings
node_api_main -->|"stores index metadata"| node_session
node_analyst -->|"asks question"| node_chat
node_chat -->|"posts question"| node_api_main
node_api_main -->|"checks index"| node_session
node_api_main -->|"queries index"| node_rag
node_rag -->|"retrieves chunks"| node_faiss
node_rag -->|"generates answer"| node_llm
node_llm -->|"calls model"| node_gemini
node_api_main -->|"returns answer"| node_chat
node_chat -->|"renders messages"| node_message
node_app -->|"renders upload"| node_uploader
node_app -->|"renders chat"| node_chat
node_app -->|"renders status"| node_sidebar
node_sidebar -->|"requests local reset"| node_app
node_analyst -->|"uses interface"| node_app
node_analyst -.->|"requests session reset"| node_api_main

click node_app "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/App.jsx"
click node_uploader "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/FileUploader.jsx"
click node_chat "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/ChatWindow.jsx"
click node_sidebar "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/Sidebar.jsx"
click node_message "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/MessageBubble.jsx"
click node_api_main "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/main.py"
click node_session "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/main.py"
click node_parser "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/file_parser.py"
click node_chunker "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/file_parser.py"
click node_rag "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/rag_pipeline.py"
click node_faiss "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/vector_store.py"
click node_llm "https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/llm_handler.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_app,node_uploader,node_chat,node_sidebar,node_message toneBlue
class node_api_main,node_session toneAmber
class node_parser,node_chunker,node_faiss,node_embeddings,node_gemini toneMint
class node_rag,node_llm toneRose
class node_analyst toneIndigo
```

## Components

### Analyst Interface

- [Application Shell](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Report Uploader](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/FileUploader.jsx): `frontend/src/components/FileUploader.jsx`
- [Chat Window](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/ChatWindow.jsx): `frontend/src/components/ChatWindow.jsx`
- [Report Sidebar](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Message Renderer](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/frontend/src/components/MessageBubble.jsx): `frontend/src/components/MessageBubble.jsx`

### API And Session

- [FastAPI Endpoints](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/main.py): `backend/main.py`
- [In-Memory Session](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/main.py): `backend/main.py`

### Report Indexing

- [PDF CSV Parser](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/file_parser.py): `backend/file_parser.py`
- [Text Chunking](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/file_parser.py): `backend/file_parser.py`
- [FAISS Vector Store](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/vector_store.py): `backend/vector_store.py`
- **HuggingFace Embeddings**

### Retrieval And Answers

- [RAG Pipeline](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`
- [Gemini Handler](https://github.com/bhushanchavan04/adinsight-ai----marketing-analytics-rag-chatbot/blob/main/backend/llm_handler.py): `backend/llm_handler.py`

### Other components

- **Marketing Analyst**
- **Gemini Model API**

## Connections

- Marketing Analyst → Report Uploader: selects report (evidence: `frontend/src/components/FileUploader.jsx`)
- Report Uploader → FastAPI Endpoints: uploads file (evidence: `frontend/src/components/FileUploader.jsx`)
- FastAPI Endpoints → PDF CSV Parser: parses bytes (evidence: `backend/main.py`)
- PDF CSV Parser → Text Chunking: splits text (evidence: `backend/file_parser.py`)
- FastAPI Endpoints → RAG Pipeline: builds index (evidence: `backend/main.py`)
- RAG Pipeline → FAISS Vector Store: creates store (evidence: `backend/rag_pipeline.py`)
- FAISS Vector Store → HuggingFace Embeddings: embeds chunks (evidence: `backend/vector_store.py`)
- FastAPI Endpoints → In-Memory Session: stores index metadata (evidence: `backend/main.py`)
- Marketing Analyst → Chat Window: asks question (evidence: `frontend/src/components/ChatWindow.jsx`)
- Chat Window → FastAPI Endpoints: posts question (evidence: `frontend/src/components/ChatWindow.jsx`)
- FastAPI Endpoints → In-Memory Session: checks index (evidence: `backend/main.py`)
- FastAPI Endpoints → RAG Pipeline: queries index (evidence: `backend/main.py`)
- RAG Pipeline → FAISS Vector Store: retrieves chunks (evidence: `backend/rag_pipeline.py`)
- RAG Pipeline → Gemini Handler: generates answer (evidence: `backend/rag_pipeline.py`)
- Gemini Handler → Gemini Model API: calls model (evidence: `backend/llm_handler.py`)
- FastAPI Endpoints → Chat Window: returns answer (evidence: `frontend/src/components/ChatWindow.jsx`)
- Chat Window → Message Renderer: renders messages (evidence: `frontend/src/components/ChatWindow.jsx`)
- Application Shell → Report Uploader: renders upload (evidence: `frontend/src/App.jsx`)
- Application Shell → Chat Window: renders chat (evidence: `frontend/src/App.jsx`)
- Application Shell → Report Sidebar: renders status (evidence: `frontend/src/App.jsx`)
- Report Sidebar → Application Shell: requests local reset (evidence: `frontend/src/App.jsx`)
- Marketing Analyst → Application Shell: uses interface
- Marketing Analyst → FastAPI Endpoints: requests session reset (evidence: `README.md`)
