# ajay9345/skcet-rag architecture

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

- Interactive diagram: https://gitdiagram.com/ajay9345/skcet-rag
- Repository: https://github.com/ajay9345/skcet-rag

## Overview

#### Purpose and Entry Points
SKCET Knowledge Assistant is a document-grounded RAG assistant for answering questions about Sri Krishna College of Engineering and Technology. The interactive runtime starts at `app.py`; ingestion is run through `ingest.py`; retrieval/answering is available through `query.py`.

#### Runtime Composition
The application is a Python/Streamlit system with a persistent local Chroma vector database. It uses an embedding model to represent document chunks and Groq-hosted LLM generation for final responses. Dependencies are declared in `requirements.txt`; persisted Chroma state is under `chroma_db/chroma.sqlite3` and `chroma_db/f99740fd-0a99-487f-b78c-9ebe45745b99/`.

#### Configuration and Provider Boundary
Central configuration should define model choices, credentials, collection/storage settings, and retrieval parameters in `src/config.py`. External-provider calls are isolated by responsibility: embedding generation in `src/embeddings.py`, LLM/Groq interaction in `src/llm.py`, and Chroma persistence/query operations in `src/vector_store.py`.

#### Offline Ingestion Pipeline
`ingest.py` coordinates the knowledge-base build process:
1. Source documents are acquired and normalized by `src/loader.py`.
2. Text is divided into retrieval-sized, likely overlapping chunks by `src/chunker.py`.
3. Each chunk is embedded through `src/embeddings.py`.
4. Vectors plus chunk metadata are written through `src/vector_store.py` into the local `chroma_db/` store.

This is the key boundary between source content preparation and the query-serving path; it must be rerun to refresh indexed knowledge.

#### Retrieval and Generation Flow
At query time, `query.py` and the Streamlit interface invoke the RAG orchestration in `src/rag.py`. A user question is embedded, passed to `src/retriever.py` for nearest-neighbor lookup against Chroma, then paired with retrieved chunks as LLM context. `src/llm.py` sends the grounded prompt to Groq and returns the generated answer.

#### State and Memory
Persistent semantic knowledge resides in `chroma_db/`, including SQLite metadata and binary vector-index files. Conversational or request-scoped state is separated into `src/memory.py`, allowing the UI/RAG layer to retain dialogue context without conflating it with the document index.

#### Primary Control Boundaries
The UI (`app.py`) should remain a presentation/controller layer over the RAG service. `src/rag.py` is the application-level coordinator; retriever, vector-store, embedding, and LLM modules are replaceable infrastructure adapters. Document loading/chunking is intentionally isolated from serving, while Chroma and Groq are the material external storage and inference dependencies.

Main entry points: [`src/rag.py`](https://github.com/ajay9345/skcet-rag/blob/main/src/rag.py) (RAG coordinator), [`src/vector_store.py`](https://github.com/ajay9345/skcet-rag/blob/main/src/vector_store.py) (Chroma adapter), [`src/config.py`](https://github.com/ajay9345/skcet-rag/blob/main/src/config.py) (Central configuration), [`src/embeddings.py`](https://github.com/ajay9345/skcet-rag/blob/main/src/embeddings.py) (Embedding adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_ui["Streamlit UI<br/>presentation<br/>[app.py]"]
  node_query_cli["Query entry point<br/>cli<br/>[query.py]"]
end

subgraph group_ingestion["Offline Ingestion"]
  node_ingest["Ingestion coordinator<br/>pipeline<br/>[ingest.py]"]
  node_loader["Document loader<br/>content normalization<br/>[loader.py]"]
  node_chunker["Text chunker<br/>chunking<br/>[chunker.py]"]
end

subgraph group_serving["RAG Serving"]
  node_rag{{"RAG coordinator<br/>application service<br/>[rag.py]"}}
  node_memory["Conversation memory<br/>request state<br/>[memory.py]"]
  node_retriever["Retriever<br/>nearest-neighbor retrieval<br/>[retriever.py]"]
end

subgraph group_adapters["Infrastructure Adapters"]
  node_config["Central configuration<br/>configuration boundary<br/>[config.py]"]
  node_embeddings["Embedding adapter<br/>embedding provider<br/>[embeddings.py]"]
  node_vector_store["Chroma adapter<br/>vector-store adapter<br/>[vector_store.py]"]
  node_llm["Groq LLM adapter<br/>generation provider<br/>[llm.py]"]
  node_chroma[("Persistent Chroma store<br/>local vector database<br/>[chroma.sqlite3]")]
  node_groq{{"Groq<br/>external inference service"}}
end

node_ui -->|"asks questions"| node_rag
node_query_cli -->|"asks questions"| node_rag
node_ingest -->|"loads sources"| node_loader
node_loader -->|"normalized text"| node_chunker
node_chunker -->|"chunks"| node_embeddings
node_embeddings -->|"vectors and metadata"| node_vector_store
node_vector_store -->|"writes index"| node_chroma
node_rag -->|"reads and updates context"| node_memory
node_rag -->|"embeds question"| node_embeddings
node_rag -->|"retrieves context"| node_retriever
node_retriever -->|"searches vectors"| node_vector_store
node_vector_store -->|"queries index"| node_chroma
node_rag -->|"grounded prompt"| node_llm
node_llm -->|"generation request"| node_groq
node_config -.->|"model settings"| node_embeddings
node_config -.->|"storage settings"| node_vector_store
node_config -.->|"retrieval settings"| node_retriever
node_config -.->|"credentials and model"| node_llm

click node_ui "https://github.com/ajay9345/skcet-rag/blob/main/app.py"
click node_query_cli "https://github.com/ajay9345/skcet-rag/blob/main/query.py"
click node_ingest "https://github.com/ajay9345/skcet-rag/blob/main/ingest.py"
click node_loader "https://github.com/ajay9345/skcet-rag/blob/main/src/loader.py"
click node_chunker "https://github.com/ajay9345/skcet-rag/blob/main/src/chunker.py"
click node_rag "https://github.com/ajay9345/skcet-rag/blob/main/src/rag.py"
click node_memory "https://github.com/ajay9345/skcet-rag/blob/main/src/memory.py"
click node_retriever "https://github.com/ajay9345/skcet-rag/blob/main/src/retriever.py"
click node_config "https://github.com/ajay9345/skcet-rag/blob/main/src/config.py"
click node_embeddings "https://github.com/ajay9345/skcet-rag/blob/main/src/embeddings.py"
click node_vector_store "https://github.com/ajay9345/skcet-rag/blob/main/src/vector_store.py"
click node_llm "https://github.com/ajay9345/skcet-rag/blob/main/src/llm.py"
click node_chroma "https://github.com/ajay9345/skcet-rag/blob/main/chroma_db/chroma.sqlite3"

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_ui,node_query_cli toneBlue
class node_ingest,node_loader,node_chunker toneAmber
class node_rag,node_memory,node_retriever toneMint
class node_config,node_embeddings,node_vector_store,node_llm,node_chroma,node_groq toneRose
```

## Components

### Entry Points

- [Streamlit UI](https://github.com/ajay9345/skcet-rag/blob/main/app.py): presentation · `app.py`
- [Query entry point](https://github.com/ajay9345/skcet-rag/blob/main/query.py): cli · `query.py`

### Offline Ingestion

- [Ingestion coordinator](https://github.com/ajay9345/skcet-rag/blob/main/ingest.py): pipeline · Rebuilds the document index when source content changes. · `ingest.py`
- [Document loader](https://github.com/ajay9345/skcet-rag/blob/main/src/loader.py): content normalization · `src/loader.py`
- [Text chunker](https://github.com/ajay9345/skcet-rag/blob/main/src/chunker.py): chunking · `src/chunker.py`

### RAG Serving

- [RAG coordinator](https://github.com/ajay9345/skcet-rag/blob/main/src/rag.py): application service · Coordinates retrieval, context assembly, and answer generation. · `src/rag.py`
- [Conversation memory](https://github.com/ajay9345/skcet-rag/blob/main/src/memory.py): request state · Keeps dialogue context separate from the document index. · `src/memory.py`
- [Retriever](https://github.com/ajay9345/skcet-rag/blob/main/src/retriever.py): nearest-neighbor retrieval · `src/retriever.py`

### Infrastructure Adapters

- [Central configuration](https://github.com/ajay9345/skcet-rag/blob/main/src/config.py): configuration boundary · Defines models, credentials, storage, collection, and retrieval settings. · `src/config.py`
- [Embedding adapter](https://github.com/ajay9345/skcet-rag/blob/main/src/embeddings.py): embedding provider · `src/embeddings.py`
- [Chroma adapter](https://github.com/ajay9345/skcet-rag/blob/main/src/vector_store.py): vector-store adapter · `src/vector_store.py`
- [Groq LLM adapter](https://github.com/ajay9345/skcet-rag/blob/main/src/llm.py): generation provider · `src/llm.py`
- [Persistent Chroma store](https://github.com/ajay9345/skcet-rag/blob/main/chroma_db/chroma.sqlite3): local vector database · Stores chunk metadata, SQLite state, and vector-index files. · `chroma_db/chroma.sqlite3`
- **Groq**: external inference service

## Connections

- Streamlit UI → RAG coordinator: asks questions
- Query entry point → RAG coordinator: asks questions
- Ingestion coordinator → Document loader: loads sources
- Document loader → Text chunker: normalized text
- Text chunker → Embedding adapter: chunks
- Embedding adapter → Chroma adapter: vectors and metadata
- Chroma adapter → Persistent Chroma store: writes index
- RAG coordinator → Conversation memory: reads and updates context
- RAG coordinator → Embedding adapter: embeds question
- RAG coordinator → Retriever: retrieves context
- Retriever → Chroma adapter: searches vectors
- Chroma adapter → Persistent Chroma store: queries index
- RAG coordinator → Groq LLM adapter: grounded prompt
- Groq LLM adapter → Groq: generation request
- Central configuration → Embedding adapter: model settings
- Central configuration → Chroma adapter: storage settings
- Central configuration → Retriever: retrieval settings
- Central configuration → Groq LLM adapter: credentials and model
