# uddipanr/temporal-rag-project architecture

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

- Interactive diagram: https://gitdiagram.com/uddipanr/temporal-rag-project
- Repository: https://github.com/uddipanr/temporal-rag-project

## Overview

This repository implements a temporal question-answering RAG system: users submit a question, the service retrieves relevant dated corpus chunks, classifies temporal intent, adaptively reranks results for freshness, then generates an answer with source and ranking details. The corpus side includes Wikipedia ingestion, corpus preparation, chunking, and index construction; the browser demo calls the API. The sampled pipeline and API excerpts establish the query path, while some corpus-preparation connections are not evidenced in the excerpts and are shown only as unverified.

Main entry points: [`src/pipeline.py`](https://github.com/uddipanr/temporal-rag-project/blob/main/src/pipeline.py) (RAG Pipeline), [`src/ingest.py`](https://github.com/uddipanr/temporal-rag-project/blob/main/src/ingest.py) (Article Ingestion), [`src/chunk_corpus.py`](https://github.com/uddipanr/temporal-rag-project/blob/main/src/chunk_corpus.py) (Chunking), [`src/retriever.py`](https://github.com/uddipanr/temporal-rag-project/blob/main/src/retriever.py) (Vector Indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus Preparation"]
  node_ingestion["Article Ingestion<br/>[ingest.py]"]
  node_articles[("Article Corpus<br/>[articles.json]")]
  node_corpus_build["Corpus Builder<br/>[build_corpus.py]"]
  node_chunking["Chunking<br/>[chunk_corpus.py]"]
end

subgraph group_retrieval["Retrieval"]
  node_indexing["Vector Indexing<br/>[retriever.py]"]
  node_index_store[("FAISS Index")]
  node_retrieval_engine["Semantic Retrieval<br/>[retriever.py]"]
end

subgraph group_reasoning["Temporal Answering"]
  node_classifier["Query Classifier<br/>[classifier.py]"]
  node_reranker["Freshness Reranker<br/>[reranker.py]"]
  node_generator["Answer Generator<br/>[generator.py]"]
end

subgraph group_service["API Service"]
  node_pipeline["RAG Pipeline<br/>[pipeline.py]"]
  node_api["Query API<br/>[api.py]"]
end

subgraph group_interface["Browser Demo"]
  node_frontend["Web Demo<br/>[app.js]"]
end

node_user(("Questioner"))
node_wiki["Wikipedia API"]
node_groq["Groq LLM"]

node_user -->|"submits question"| node_frontend
node_frontend -->|"posts query"| node_api
node_api -->|"runs query"| node_pipeline
node_pipeline -->|"retrieves documents"| node_retrieval_engine
node_pipeline -->|"classifies query"| node_classifier
node_pipeline -->|"reranks documents"| node_reranker
node_pipeline -->|"generates answer"| node_generator
node_retrieval_engine -.->|"searches index"| node_index_store
node_indexing -.->|"builds index"| node_index_store
node_chunking -.->|"supplies chunks"| node_indexing
node_corpus_build -.->|"prepares text"| node_chunking
node_ingestion -->|"fetches articles"| node_wiki
node_ingestion -->|"writes articles"| node_articles
node_classifier -->|"requests classification"| node_groq
node_generator -->|"requests completion"| node_groq

click node_ingestion "https://github.com/uddipanr/temporal-rag-project/blob/main/src/ingest.py"
click node_articles "https://github.com/uddipanr/temporal-rag-project/blob/main/src/data/corpus/articles.json"
click node_corpus_build "https://github.com/uddipanr/temporal-rag-project/blob/main/src/build_corpus.py"
click node_chunking "https://github.com/uddipanr/temporal-rag-project/blob/main/src/chunk_corpus.py"
click node_indexing "https://github.com/uddipanr/temporal-rag-project/blob/main/src/retriever.py"
click node_retrieval_engine "https://github.com/uddipanr/temporal-rag-project/blob/main/src/retriever.py"
click node_classifier "https://github.com/uddipanr/temporal-rag-project/blob/main/src/classifier.py"
click node_reranker "https://github.com/uddipanr/temporal-rag-project/blob/main/src/reranker.py"
click node_generator "https://github.com/uddipanr/temporal-rag-project/blob/main/src/generator.py"
click node_pipeline "https://github.com/uddipanr/temporal-rag-project/blob/main/src/pipeline.py"
click node_api "https://github.com/uddipanr/temporal-rag-project/blob/main/src/api.py"
click node_frontend "https://github.com/uddipanr/temporal-rag-project/blob/main/frontend/app.js"

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_ingestion,node_articles,node_corpus_build,node_chunking toneBlue
class node_indexing,node_index_store,node_retrieval_engine toneAmber
class node_classifier,node_reranker,node_generator,node_wiki toneMint
class node_pipeline,node_api toneRose
class node_frontend,node_user,node_groq toneIndigo
```

## Components

### Corpus Preparation

- [Article Ingestion](https://github.com/uddipanr/temporal-rag-project/blob/main/src/ingest.py): `src/ingest.py`
- [Article Corpus](https://github.com/uddipanr/temporal-rag-project/blob/main/src/data/corpus/articles.json): `src/data/corpus/articles.json`
- [Corpus Builder](https://github.com/uddipanr/temporal-rag-project/blob/main/src/build_corpus.py): `src/build_corpus.py`
- [Chunking](https://github.com/uddipanr/temporal-rag-project/blob/main/src/chunk_corpus.py): `src/chunk_corpus.py`

### Retrieval

- [Vector Indexing](https://github.com/uddipanr/temporal-rag-project/blob/main/src/retriever.py): `src/retriever.py`
- **FAISS Index**
- [Semantic Retrieval](https://github.com/uddipanr/temporal-rag-project/blob/main/src/retriever.py): `src/retriever.py`

### Temporal Answering

- [Query Classifier](https://github.com/uddipanr/temporal-rag-project/blob/main/src/classifier.py): `src/classifier.py`
- [Freshness Reranker](https://github.com/uddipanr/temporal-rag-project/blob/main/src/reranker.py): `src/reranker.py`
- [Answer Generator](https://github.com/uddipanr/temporal-rag-project/blob/main/src/generator.py): `src/generator.py`

### API Service

- [RAG Pipeline](https://github.com/uddipanr/temporal-rag-project/blob/main/src/pipeline.py): `src/pipeline.py`
- [Query API](https://github.com/uddipanr/temporal-rag-project/blob/main/src/api.py): `src/api.py`

### Browser Demo

- [Web Demo](https://github.com/uddipanr/temporal-rag-project/blob/main/frontend/app.js): `frontend/app.js`

### Other components

- **Questioner**
- **Wikipedia API**
- **Groq LLM**

## Connections

- Questioner → Web Demo: submits question (evidence: `frontend/app.js`)
- Web Demo → Query API: posts query (evidence: `frontend/app.js`)
- Query API → RAG Pipeline: runs query (evidence: `src/api.py`)
- RAG Pipeline → Semantic Retrieval: retrieves documents (evidence: `src/pipeline.py`)
- RAG Pipeline → Query Classifier: classifies query (evidence: `src/pipeline.py`)
- RAG Pipeline → Freshness Reranker: reranks documents (evidence: `src/pipeline.py`)
- RAG Pipeline → Answer Generator: generates answer (evidence: `src/pipeline.py`)
- Semantic Retrieval → FAISS Index: searches index
- Vector Indexing → FAISS Index: builds index
- Chunking → Vector Indexing: supplies chunks
- Corpus Builder → Chunking: prepares text
- Article Ingestion → Wikipedia API: fetches articles (evidence: `src/ingest.py`)
- Article Ingestion → Article Corpus: writes articles (evidence: `src/ingest.py`)
- Query Classifier → Groq LLM: requests classification (evidence: `src/classifier.py`)
- Answer Generator → Groq LLM: requests completion (evidence: `src/generator.py`)
