# jay4ignite/nlp-cornerstone architecture

> Architecture diagram of the GitHub repository jay4ignite/nlp-cornerstone, 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/jay4ignite/nlp-cornerstone
- Repository: https://github.com/jay4ignite/nlp-cornerstone

## Overview

CampusNLP is a university-query assistant: students submit questions through a chat UI, the backend classifies intent and extracts academic entities, retrieves and reranks institutional evidence, then generates a cited answer or abstains when evidence is weak. The repository also documents ingestion, structured curriculum access, health and feedback capabilities. The graph reflects README-documented behavior and relationships visible in the sampled files or SOURCE INDEX; unsampled internals and some frontend-to-backend wiring are left unasserted.

Main entry points: [`backend/pipeline.py`](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/pipeline.py) (Query pipeline), [`src/App.tsx`](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/App.tsx) (Chat application), [`src/hooks/useConversations.ts`](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/hooks/useConversations.ts) (Conversation state), [`backend/rag/retriever.py`](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/retriever.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_app["Chat application<br/>[App.tsx]"]
  node_chat["Chat interface<br/>[Chat.tsx]"]
  node_conversations["Conversation state"]
  node_api_client["API client<br/>[api.ts]"]
  node_history["Saved conversations<br/>[conversations.ts]"]
end

subgraph group_api["Backend API"]
  node_http_api["HTTP endpoints<br/>[main.py]"]
  node_pipeline["Query pipeline<br/>[pipeline.py]"]
  node_guardrails["Grounding guardrails<br/>[guardrails.py]"]
end

subgraph group_understanding["Query understanding"]
  node_preprocessing["Text preprocessing<br/>[preprocessing.py]"]
  node_intent["Intent classifier"]
  node_entities["Entity extraction"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_ingestion["Resource ingestion"]
  node_pdf_loader["PDF loading<br/>[pdf_loader.py]"]
  node_chunker["Document chunking<br/>[chunker.py]"]
  node_embeddings["Embedding service<br/>[embeddings.py]"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
  node_vector_store["Vector store adapter<br/>[vector_store.py]"]
  node_cloudflare_store[("Vectorize store")]
  node_reranker["Evidence reranker<br/>[reranker.py]"]
  node_generator["Answer generation<br/>[generator.py]"]
  node_attribution["Citation attribution<br/>[attribution.py]"]
end

node_student(("Student"))
node_nvidia{{"NVIDIA NIM"}}
node_cloudflare{{"Cloudflare Vectorize"}}

node_student -->|"asks question"| node_app
node_app -->|"renders"| node_chat
node_app -->|"uses state"| node_conversations
node_conversations -->|"loads and saves"| node_history
node_conversations -->|"sends queries"| node_api_client
node_api_client -.->|"calls endpoints"| node_http_api
node_http_api -->|"processes query"| node_pipeline
node_pipeline -->|"classifies intent"| node_intent
node_intent -->|"preprocesses text"| node_preprocessing
node_pipeline -->|"extracts entities"| node_entities
node_pipeline -->|"retrieves evidence"| node_retriever
node_retriever -->|"embeds query"| node_embeddings
node_retriever -->|"searches vectors"| node_vector_store
node_vector_store -->|"delegates storage"| node_cloudflare_store
node_pipeline -->|"reranks evidence"| node_reranker
node_pipeline -->|"checks grounding"| node_guardrails
node_pipeline -->|"generates answer"| node_generator
node_pipeline -->|"scores citations"| node_attribution
node_embeddings -->|"requests embeddings"| node_nvidia
node_cloudflare_store -.->|"queries remote index"| node_cloudflare
node_ingestion -->|"creates embeddings"| node_embeddings
node_ingestion -->|"loads vectors"| node_cloudflare_store
node_pdf_loader -.->|"loads then chunks"| node_chunker

click node_app "https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/App.tsx"
click node_chat "https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/components/Chat.tsx"
click node_conversations "https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/hooks/useConversations.ts"
click node_api_client "https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/lib/api.ts"
click node_history "https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/lib/conversations.ts"
click node_http_api "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/main.py"
click node_pipeline "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/pipeline.py"
click node_guardrails "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/guardrails.py"
click node_preprocessing "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/preprocessing.py"
click node_intent "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/intent_classifier.py"
click node_entities "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/entity_extractor.py"
click node_ingestion "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/data_ingestion/multi_resource_loader.py"
click node_pdf_loader "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/pdf_loader.py"
click node_chunker "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/chunker.py"
click node_embeddings "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/embeddings.py"
click node_retriever "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/retriever.py"
click node_vector_store "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/vector_store.py"
click node_cloudflare_store "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/cloudflare_vector_store.py"
click node_reranker "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/reranker.py"
click node_generator "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/generator.py"
click node_attribution "https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/attribution.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_chat,node_conversations,node_api_client,node_history toneBlue
class node_http_api,node_pipeline,node_guardrails toneAmber
class node_preprocessing,node_intent,node_entities toneMint
class node_ingestion,node_pdf_loader,node_chunker,node_embeddings,node_retriever,node_vector_store,node_cloudflare_store,node_reranker,node_generator,node_attribution toneRose
class node_student,node_nvidia,node_cloudflare toneIndigo
```

## Components

### Chat interface

- [Chat application](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/App.tsx): `src/App.tsx`
- [Chat interface](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/components/Chat.tsx): `src/components/Chat.tsx`
- [Conversation state](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/hooks/useConversations.ts): `src/hooks/useConversations.ts`
- [API client](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Saved conversations](https://github.com/jay4ignite/nlp-cornerstone/blob/main/src/lib/conversations.ts): `src/lib/conversations.ts`

### Backend API

- [HTTP endpoints](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/main.py): `backend/main.py`
- [Query pipeline](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Grounding guardrails](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/guardrails.py): `backend/guardrails.py`

### Query understanding

- [Text preprocessing](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/preprocessing.py): `backend/nlp/preprocessing.py`
- [Intent classifier](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/intent_classifier.py): `backend/nlp/intent_classifier.py`
- [Entity extraction](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/nlp/entity_extractor.py): `backend/nlp/entity_extractor.py`

### Knowledge retrieval

- [Resource ingestion](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/data_ingestion/multi_resource_loader.py): `backend/data_ingestion/multi_resource_loader.py`
- [PDF loading](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/pdf_loader.py): `backend/rag/pdf_loader.py`
- [Document chunking](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/chunker.py): `backend/rag/chunker.py`
- [Embedding service](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/embeddings.py): `backend/rag/embeddings.py`
- [Hybrid retrieval](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/retriever.py): `backend/rag/retriever.py`
- [Vector store adapter](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/vector_store.py): `backend/rag/vector_store.py`
- [Vectorize store](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/cloudflare_vector_store.py): `backend/rag/cloudflare_vector_store.py`
- [Evidence reranker](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/reranker.py): `backend/rag/reranker.py`
- [Answer generation](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/generator.py): `backend/rag/generator.py`
- [Citation attribution](https://github.com/jay4ignite/nlp-cornerstone/blob/main/backend/rag/attribution.py): `backend/rag/attribution.py`

### Other components

- **Student**
- **NVIDIA NIM**
- **Cloudflare Vectorize**

## Connections

- Student → Chat application: asks question (evidence: `README.md`)
- Chat application → Chat interface: renders (evidence: `src/App.tsx`)
- Chat application → Conversation state: uses state (evidence: `src/App.tsx`)
- Conversation state → Saved conversations: loads and saves (evidence: `src/hooks/useConversations.ts`)
- Conversation state → API client: sends queries (evidence: `src/hooks/useConversations.ts`)
- API client → HTTP endpoints: calls endpoints
- HTTP endpoints → Query pipeline: processes query (evidence: `backend/main.py`)
- Query pipeline → Intent classifier: classifies intent (evidence: `backend/pipeline.py`)
- Intent classifier → Text preprocessing: preprocesses text (evidence: `backend/nlp/intent_classifier.py`)
- Query pipeline → Entity extraction: extracts entities (evidence: `backend/pipeline.py`)
- Query pipeline → Hybrid retrieval: retrieves evidence (evidence: `backend/pipeline.py`)
- Hybrid retrieval → Embedding service: embeds query (evidence: `backend/rag/retriever.py`)
- Hybrid retrieval → Vector store adapter: searches vectors (evidence: `backend/rag/retriever.py`)
- Vector store adapter → Vectorize store: delegates storage (evidence: `backend/rag/vector_store.py`)
- Query pipeline → Evidence reranker: reranks evidence (evidence: `backend/pipeline.py`)
- Query pipeline → Grounding guardrails: checks grounding (evidence: `backend/pipeline.py`)
- Query pipeline → Answer generation: generates answer (evidence: `backend/pipeline.py`)
- Query pipeline → Citation attribution: scores citations (evidence: `backend/pipeline.py`)
- Embedding service → NVIDIA NIM: requests embeddings (evidence: `backend/rag/embeddings.py`)
- Vectorize store → Cloudflare Vectorize: queries remote index
- Resource ingestion → Embedding service: creates embeddings (evidence: `backend/data_ingestion/multi_resource_loader.py`)
- Resource ingestion → Vectorize store: loads vectors (evidence: `backend/data_ingestion/multi_resource_loader.py`)
- PDF loading → Document chunking: loads then chunks
