# ys-pundir/teslafi-groq-rag architecture

> Architecture diagram of the GitHub repository ys-pundir/teslafi-groq-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ys-pundir/teslafi-groq-rag
- Repository: https://github.com/ys-pundir/teslafi-groq-rag

## Overview

TeslaFi-Groq-RAG provides multi-turn question answering over Tesla annual reports. Users submit a question through the Streamlit interface or the console chat; the application retrieves relevant chunks from Chroma, adds retrieved context to the conversation, and sends the conversation to Groq for a grounded answer. Conversation history is persisted separately. The README documents semantic retrieval and context-aware generation; the sampled code confirms these responsibilities, though the Streamlit excerpt omits part of its request-handling path.

Main entry points: [`src/streamlit_app.py`](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py) (Chunk retrieval), [`src/app.py`](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/app.py) (Console chat), [`data/tesla_db/chroma.sqlite3`](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla_db/chroma.sqlite3) (Chroma store), [`data/tesla-annual-reports/tsla-20231231-gen.pdf`](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla-annual-reports/tsla-20231231-gen.pdf) (Annual report)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Streamlit chat<br/>[streamlit_app.py]"]
  node_console["Console chat<br/>[app.py]"]
end

subgraph group_rag["RAG pipeline"]
  node_retrieval["Chunk retrieval<br/>[streamlit_app.py]"]
  node_context["Context assembly<br/>[streamlit_app.py]"]
  node_answer["Grounded answer<br/>[streamlit_app.py]"]
end

subgraph group_state["Conversation state"]
  node_history["Conversation history<br/>[streamlit_app.py]"]
  node_historyfile[("History file<br/>[streamlit_app.py]")]
end

subgraph group_services["Data and inference"]
  node_vectorstore[("Chroma store<br/>[chroma.sqlite3]")]
  node_reports["Annual report"]
  node_groq["Groq inference"]
end

node_user(("User"))

node_user -->|"asks"| node_streamlit
node_user -->|"asks"| node_console
node_streamlit -->|"requests chunks"| node_retrieval
node_console -->|"requests chunks"| node_retrieval
node_retrieval -->|"searches"| node_vectorstore
node_vectorstore -->|"returns matches"| node_retrieval
node_retrieval -->|"supplies chunks"| node_context
node_context -->|"adds context"| node_history
node_history -->|"sends messages"| node_groq
node_groq -->|"returns response"| node_answer
node_answer -->|"displays"| node_streamlit
node_answer -->|"displays"| node_console
node_history -->|"loads and saves"| node_historyfile
node_reports -.-> node_vectorstore

click node_streamlit "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py"
click node_console "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/app.py"
click node_retrieval "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py"
click node_context "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py"
click node_history "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py"
click node_historyfile "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py"
click node_vectorstore "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla_db/chroma.sqlite3"
click node_reports "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla-annual-reports/tsla-20231231-gen.pdf"
click node_answer "https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.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_streamlit,node_console,node_user toneBlue
class node_retrieval,node_context,node_answer toneAmber
class node_history,node_historyfile toneMint
class node_vectorstore,node_reports,node_groq toneRose
```

## Components

### User interfaces

- [Streamlit chat](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`
- [Console chat](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/app.py): `src/app.py`

### RAG pipeline

- [Chunk retrieval](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`
- [Context assembly](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`
- [Grounded answer](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`

### Conversation state

- [Conversation history](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`
- [History file](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/src/streamlit_app.py): `src/streamlit_app.py`

### Data and inference

- [Chroma store](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla_db/chroma.sqlite3): `data/tesla_db/chroma.sqlite3`
- [Annual report](https://github.com/ys-pundir/teslafi-groq-rag/blob/main/data/tesla-annual-reports/tsla-20231231-gen.pdf): `data/tesla-annual-reports/tsla-20231231-gen.pdf`
- **Groq inference**

### Other components

- **User**

## Connections

- User → Streamlit chat: asks
- User → Console chat: asks
- Streamlit chat → Chunk retrieval: requests chunks
- Console chat → Chunk retrieval: requests chunks
- Chunk retrieval → Chroma store: searches
- Chroma store → Chunk retrieval: returns matches
- Chunk retrieval → Context assembly: supplies chunks
- Context assembly → Conversation history: adds context
- Conversation history → Groq inference: sends messages
- Groq inference → Grounded answer: returns response
- Grounded answer → Streamlit chat: displays
- Grounded answer → Console chat: displays
- Conversation history → History file: loads and saves
- Annual report → Chroma store
