I’ve been exploring ways to integrate Retrieval-Augmented Generation (RAG) into my website, and I wanted to design a small, event-driven app to learn more about it. My goal was to create something simple yet practical for my site.
Below is a Mermaid diagram I created to model the flow of my application. It highlights the main components of an event-driven RAG system, covering content updates, user queries, and background indexing:
flowchart TD
%% Content Update Flow
A[Markdown File Update] --> B[File Watcher / Git Hook]
B --> C[Trigger Content Update Event]
C --> D[Process Content & Generate Embeddings]
D --> E[Index/Update Qdrant DB]
D --> F[Dynamic Summarization]
%% User Query Flow
G[User Query via API] --> H[Trigger Query Event]
H --> I[Retrieve Related Docs from Qdrant]
I --> J[C# Semantic Kernel]
J --> K[Generate Answer]
K --> L[Return Answer to User]
%% Background Processes
M[Scheduler Trigger] --> N[Initiate Full Reindexing Pipeline]
N --> D
%% Notification/Feedback (Optional)
E --- O[Monitor Confidence / Low-Match Feedback]
O --> P[Trigger Notification or Auto-Enhancement]
How It Works
Content Update Flow
- Markdown File Update: Whenever I add or modify markdown files for my blog, a file watcher or Git hook detects the change.
- Trigger Content Update Event: This detection triggers an event to start processing the updated content.
- Process & Generate Embeddings: The content is processed to extract text, generate embeddings, and optionally create summaries using my C# pipeline.
- Index/Update Qdrant DB: The embeddings are stored or updated in the Qdrant vector database.
User Query Flow
- User Query via API: A user submits a query through the web API.
- Trigger Query Event: The query triggers an event to initiate the search process.
- Retrieve Related Docs: Relevant documents are fetched from Qdrant using vector similarity search.
- C# Semantic Kernel: The Semantic Kernel processes the retrieved documents to provide context.
- Generate Answer: An answer is crafted based on the contextual data.
- Return Answer: The answer is sent back to the user.
Background Processes
- Scheduler Trigger: A scheduled event (like a cron job) periodically reindexes all markdown files.
- Full Reindexing Pipeline: This ensures the database is always up-to-date with the latest embeddings.
Notification/Feedback (Optional)
- Monitor Confidence: The system monitors for low-confidence matches or ambiguous results.
- Trigger Notification or Auto-Enhancement: If issues are detected, notifications are sent, or automatic enhancements are triggered to improve the content.
Why This Matters
This event-driven design ensures that my RAG application is efficient, responsive, and always up-to-date. By automating content updates and query handling, I can focus on improving the user experience while the system takes care of the heavy lifting.