RAG Explainer EP19 | admin.py Blueprint: Upload, Process & ChromaDB Collections
Welcome to Episode 19 of the RAG Explainer Series from Secure AI Learning Lab. In the previous episodes, we examined the core rag_service.py implementation. We covered PDF and DOCX parsing, Sentence Transformer initialization, ChromaDB connectivity, sentence-aware chunking, document embedding, Server-Sent Events processing, collection listing, and semantic context retrieval. In Episode 19, we move from the RAG service layer into the Flask route layer by examining admin.py. The admin.py file is a Flask Blueprint responsible for the document-administration area of the RAG Explainer application. It exposes secured routes that allow an admin user to upload documents, process those documents into vector embeddings, and list available ChromaDB collections. This episode covers: Why admin.py is implemented as a Flask Blueprint How Blueprints help organize related UI and REST endpoints Why admin routes are separated from the main run.py file Importing Flask components such as Blueprint, current_app, render_template, request, Response, session, stream_with_context, and jsonify Importing secure_filename from Werkzeug Importing login_required and role_required from auth_service.py Importing process_document_sse and list_collections from rag_service.py Creating the admin Blueprint with the /admin URL prefix Creating a logger for the admin route module Defining allowed document extensions such as PDF, DOCX, and DOC Validating uploaded filenames before processing Protecting the admin index page with the rag-admin role Loading ChromaDB collections for the admin UI Rendering the admin.html template Passing user, role, and collection data into the template Implementing the /upload route Validating whether the browser actually submitted a document Returning JSON errors for missing files Rejecting unsupported file extensions Securing uploaded filenames before saving them Saving uploaded documents into the configured upload folder Returning a successful upload response to the browser Implementing the /process route Validating the selected filename before processing Reading ChromaDB path, embedding model, chunk size, and overlap settings from application configuration Calling process_document_sse from the RAG service layer Streaming document-processing progress back to the browser using Server-Sent Events Implementing the collections endpoint Returning available ChromaDB collections to the UI The key takeaway is that admin.py does not contain the heavy RAG business logic itself. Instead, it acts as the secured web entry point for administrative document operations. The actual RAG work is delegated to rag_service.py. The route layer receives browser requests, validates inputs, checks user roles, saves uploaded files, calls the service layer, and streams progress updates back to the UI. The simplified flow is: Admin user logs in → User opens the Document Admin page → Flask verifies the rag-admin role → User uploads a PDF or DOCX file → admin.py validates and saves the file → User starts processing → admin.py calls process_document_sse → rag_service.py parses, chunks, embeds, and stores vectors → Browser receives real-time SSE progress updates → ChromaDB collections become available for RAG chat This episode is useful for Python developers, Flask developers, AI engineers, enterprise architects, and technical leaders who want to understand how a secure RAG application connects the browser UI, Flask routes, role-based access control, document upload, RAG processing, and ChromaDB collection management. Subscribe to Secure AI Learning Lab for practical Enterprise AI, Secure AI, RAG, Python, Flask, Keycloak, ChromaDB, Sentence Transformers, OAuth2/OIDC, and secure-by-design application architecture. Chapters: 00:00 Introduction 00:08 Moving into the admin.py page 00:19 Grouping service pages in the UI menu 00:29 admin.py as a Flask Blueprint 00:39 What a Flask Blueprint does 01:06 Imports used by admin.py 01:43 secure_filename and upload protection 01:56 login_required and role_required 02:03 process_document_sse and list_collections 02:12 Creating the admin Blueprint 02:18 Allowed document extensions 02:31 The admin index route 02:39 Protecting the route with rag-admin 02:48 Loading collections from ChromaDB 02:55 Rendering the admin template 03:06 The upload route 03:18 Handling missing uploaded files 03:39 Validating file extension 03:49 Securing and saving the uploaded filename 04:15 The process route 04:27 Validating filename and file path 04:43 Reading ChromaDB and embedding configuration 04:55 Calling process_document_sse 05:04 Streaming SSE updates to the browser 05:20 The collections route 05:31 Listing ChromaDB collections 05:52 Episode summary 06:04 Closing and subscribe reminder

RAG Explainer EP20 | chat.py Blueprint: RAG Query Flow & Claude Streaming

Don't learn AI Agents without Learning these Fundamentals

Compose Multiplatform & a Design-Token System That Scales Across Modules

Lesson 3: Stringly Typed Code

Android 17 sucks. So I put Linux on a phone.

The State of AI Coding Is Honestly Terrifying

RAG Explainer EP06 | IAM, OAuth2, OIDC, Tokens & Keycloak Explained

RAG Crash Course for Beginners

TV Art Screensaver Modern Art | Line Art | Vintage Art TV Background | 4K Fine Art for your TV

Blue gradient background - screensaver, mood lighting, ambiance, TV art, focus, study

AI layoffs fail as companies rehire cut staff | David Gerard

Purple abstract art | screensavers for Samsung TV | Frame TV art | wall art | home decor | paintings

Building Great Agent Skills: The Missing Manual

What else is coming? Chat control, age verification, DSA, VPN ban

Keycloak Explained EP07 | Realms, OIDC Clients, Redirect URIs & PKCE
![PINK & ORANGE GRADIENT IN HD [3 HOURS]](https://i.ytimg.com/vi/6ih8zppfQSQ/hqdefault.jpg?sqp=-oaymwE9CNACELwBSFryq4qpAy8IARUAAAAAGAElAADIQj0AgKJDeAHwAQH4Af4JgALQBYoCDAgAEAEYfyAsKBMwDw==&rs=AOn4CLDvw6mQM98bfl572zfE7r4GdUG8dg)
PINK & ORANGE GRADIENT IN HD [3 HOURS]

Complete Agentic AI Course - AI Agents, RAG, Embeddings, Architectures, Framework, VectorDB & Memory

Aura Peach Screensaver Background – Soft Aesthetic Wall Art 4K

Turing Award Winner: Disagreeing with Google, Postgres, Future Problems | Mike Stonebraker

Mr.Bean Making Celebrities Cry With Laughter NONSTOP!

Loop Engineering explained in 8min..
![Your Phone Is Destroying Your Sense of Meaning | Arthur Brooks [ARC 2026]](https://i.ytimg.com/vi/PfTcgYwW14E/hqdefault.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLBzBqlOzXKaS_MJrH8pIKehA8ZKPQ)
Your Phone Is Destroying Your Sense of Meaning | Arthur Brooks [ARC 2026]

MIT Just Revealed the AI Bubble's Fatal Flaw

Boho Landscape Art Screensaver | Art Slideshow For TV | Turn Your TV Into Wall Art | 1 Hr | No Sound

The Riskiest Moment of the AI Bubble

