# yugeshkaran/assistant_knowledge_hub architecture

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

- Interactive diagram: https://gitdiagram.com/yugeshkaran/assistant_knowledge_hub
- Repository: https://github.com/yugeshkaran/assistant_knowledge_hub

## Overview

BytesBase Assistant is a Flask RAG service for community posts. Authorized clients submit posts for embedding and indexing, or ask questions that are checked, embedded, matched against category-filtered and current-post content, then sent with a system prompt to an LLM for a schema-shaped answer. The README also describes suggestions and optional video results. The shown implementation uses Pinecone inference for embeddings; the README’s OpenAI embedding description differs. The graph follows shown calls and documented product behavior; unsampled capabilities and external-service boundaries are represented only where evidence supports them.

Main entry points: [`retrieval.py`](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/retrieval.py) (Search and fetch), [`app.py`](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/app.py) (Flask API), [`ingestion.py`](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/ingestion.py) (Post ingest/delete), [`embedder.py`](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/embedder.py) (Embedding generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and safeguards"]
  node_api["Flask API<br/>[app.py]"]
  node_auth["JWT guard<br/>[auth_token.py]"]
  node_filter["Injection filter"]
end

subgraph group_ingest["Post ingestion"]
  node_ingestion["Post ingest/delete<br/>[ingestion.py]"]
  node_post_text["Post text and metadata<br/>[ingestion.py]"]
  node_embed["Embedding generation<br/>[embedder.py]"]
  node_pinecone[("Pinecone index<br/>[pinecone_client.py]")]
end

subgraph group_retrieval["Retrieval and answers"]
  node_retrieval["Search and fetch<br/>[retrieval.py]"]
  node_context["Context assembly<br/>[retrieval.py]"]
  node_prompt["System prompt<br/>[system.py]"]
  node_llm["Groq language model"]
  node_response_schema["Answer schema<br/>[schema.py]"]
end

subgraph group_shared["Shared configuration"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_client(("Community client"))
node_pinecone_service["Pinecone service"]
node_response["JSON answer"]

node_client -->|"sends requests"| node_api
node_api -->|"guards routes"| node_auth
node_api -->|"checks query"| node_filter
node_api -->|"upserts or deletes"| node_ingestion
node_ingestion -->|"builds text and metadata"| node_post_text
node_ingestion -->|"requests embedding"| node_embed
node_ingestion -->|"upserts or deletes"| node_pinecone
node_embed -->|"requests embedding"| node_pinecone_service
node_pinecone -->|"connects to index"| node_pinecone_service
node_api -->|"calls ask_ai"| node_retrieval
node_retrieval -->|"embeds query"| node_embed
node_retrieval -->|"queries and fetches"| node_pinecone
node_retrieval -->|"assembles retrieved posts"| node_context
node_api -->|"passes system prompt"| node_prompt
node_retrieval -->|"includes prompt in chain"| node_prompt
node_retrieval -->|"invokes model chain"| node_llm
node_retrieval -->|"parses structured output"| node_response_schema
node_retrieval -->|"returns parsed answer"| node_response
node_api -->|"returns HTTP JSON"| node_response
node_embed -->|"reads API key"| node_config
node_pinecone -->|"reads index settings"| node_config
node_retrieval -->|"reads model settings"| node_config

click node_api "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/app.py"
click node_auth "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/middleware/auth_token.py"
click node_filter "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/prompt_injection_filtering.py"
click node_ingestion "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/ingestion.py"
click node_post_text "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/ingestion.py"
click node_embed "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/embedder.py"
click node_pinecone "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/pinecone_client.py"
click node_retrieval "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/retrieval.py"
click node_context "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/retrieval.py"
click node_prompt "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/prompts/system.py"
click node_response_schema "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/schema.py"
click node_config "https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/config.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_api,node_auth,node_filter,node_client toneBlue
class node_ingestion,node_post_text,node_embed,node_pinecone toneAmber
class node_retrieval,node_context,node_prompt,node_llm,node_response_schema toneMint
class node_config toneRose
class node_pinecone_service,node_response toneIndigo
```

## Components

### API and safeguards

- [Flask API](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/app.py): `app.py`
- [JWT guard](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/middleware/auth_token.py): `middleware/auth_token.py`
- [Injection filter](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/prompt_injection_filtering.py): `utility/prompt_injection_filtering.py`

### Post ingestion

- [Post ingest/delete](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/ingestion.py): `ingestion.py`
- [Post text and metadata](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/ingestion.py): `ingestion.py`
- [Embedding generation](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/embedder.py): `embedder.py`
- [Pinecone index](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/pinecone_client.py): `pinecone_client.py`

### Retrieval and answers

- [Search and fetch](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/retrieval.py): `retrieval.py`
- [Context assembly](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/retrieval.py): `retrieval.py`
- [System prompt](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/prompts/system.py): `utility/prompts/system.py`
- **Groq language model**
- [Answer schema](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/schema.py): `utility/schema.py`

### Shared configuration

- [Runtime configuration](https://github.com/yugeshkaran/assistant_knowledge_hub/blob/main/utility/config.py): `utility/config.py`

### Other components

- **Community client**
- **Pinecone service**
- **JSON answer**

## Connections

- Community client → Flask API: sends requests (evidence: `app.py`)
- Flask API → JWT guard: guards routes (evidence: `app.py`)
- Flask API → Injection filter: checks query (evidence: `app.py`)
- Flask API → Post ingest/delete: upserts or deletes (evidence: `app.py`)
- Post ingest/delete → Post text and metadata: builds text and metadata (evidence: `ingestion.py`)
- Post ingest/delete → Embedding generation: requests embedding (evidence: `ingestion.py`)
- Post ingest/delete → Pinecone index: upserts or deletes (evidence: `ingestion.py`)
- Embedding generation → Pinecone service: requests embedding (evidence: `embedder.py`)
- Pinecone index → Pinecone service: connects to index (evidence: `pinecone_client.py`)
- Flask API → Search and fetch: calls ask_ai (evidence: `app.py`)
- Search and fetch → Embedding generation: embeds query (evidence: `retrieval.py`)
- Search and fetch → Pinecone index: queries and fetches (evidence: `retrieval.py`)
- Search and fetch → Context assembly: assembles retrieved posts (evidence: `retrieval.py`)
- Flask API → System prompt: passes system prompt (evidence: `app.py`)
- Search and fetch → System prompt: includes prompt in chain (evidence: `retrieval.py`)
- Search and fetch → Groq language model: invokes model chain (evidence: `retrieval.py`)
- Search and fetch → Answer schema: parses structured output (evidence: `retrieval.py`)
- Search and fetch → JSON answer: returns parsed answer (evidence: `retrieval.py`)
- Flask API → JSON answer: returns HTTP JSON (evidence: `app.py`)
- Embedding generation → Runtime configuration: reads API key (evidence: `embedder.py`)
- Pinecone index → Runtime configuration: reads index settings (evidence: `pinecone_client.py`)
- Search and fetch → Runtime configuration: reads model settings (evidence: `retrieval.py`)
