The admin API provides privileged access to the operational internals of the NISIRA Assistant: managing documents in Google Drive, controlling the embedding generation pipeline, viewing detailed RAG performance metrics, and inspecting the status of each system component. All endpoints underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/HugoX2003/nisira-assistant/llms.txt
Use this file to discover all available pages before exploring further.
/api/admin/ are guarded by the admin_required decorator, which checks that the authenticated user’s username is exactly admin. Standard staff (is_staff) accounts cannot access these endpoints.
Authentication Note
Every/api/admin/* endpoint requires:
- A valid JWT access token in the
Authorization: Bearer <token>header. - The authenticated user must have the username
"admin". This is enforced by theis_admin_user()helper inadmin_views.py, which checksuser.username == "admin"directly.
Drive Management
These endpoints interface with Google Drive to list, upload, delete, and synchronize the source documents that the RAG pipeline indexes. If Drive is not authenticated (no valid OAuth credentials), upload and delete operations fall back to local filesystem storage.| Method | Path | Description |
|---|---|---|
GET | /api/admin/drive/files/ | List files in the configured Drive folder with pagination and search |
POST | /api/admin/drive/upload/ | Upload a file to Drive (and local storage); triggers background embedding |
DELETE | /api/admin/drive/delete/<file_id>/ | Permanently delete a file from Drive by its Drive file ID |
POST | /api/admin/drive/sync/ | Trigger a full Drive→local sync in a background thread |
GET | /api/admin/drive/sync/progress/ | Poll the sync progress (status, percentage, recent logs) |
GET /api/admin/drive/files/
Page number for paginated file listing.
Number of files per page.
Filter files by name (case-insensitive substring match).
POST /api/admin/drive/upload/
Acceptsmultipart/form-data. Allowed extensions: .pdf, .txt, .md, .doc, .docx. The file is saved to Google Drive (if authenticated) and locally. Embedding generation is launched automatically in a background thread — the endpoint returns immediately without waiting for embeddings to complete.
The document file to upload. Must be one of the supported types above.
POST /api/admin/drive/sync/
Launches a background thread that downloads all new or changed files from Drive and processes them into the vector store. Returns immediately; useGET /api/admin/drive/sync/progress/ to track progress. Returns 409 Conflict if a sync is already running.
If new files are downloaded, embedding generation is triggered automatically after the sync completes — no separate call to POST /api/admin/embeddings/generate/ is needed.
GET /api/admin/drive/sync/progress/
Poll this endpoint after starting a sync to track its progress. The backend writes progress data to a JSON file (sync_progress.json) that this endpoint reads. If the status is "running" but no log entry has been added in the last 90 seconds, the status is automatically changed to "error" (stale worker detection).
Embeddings Management
These endpoints control the embedding pipeline — generating, verifying, and clearing the vector representations stored in PostgreSQL (pgvector) or ChromaDB.
| Method | Path | Description |
|---|---|---|
GET | /api/admin/embeddings/status/ | Current embedding store status and document counts per collection |
POST | /api/admin/embeddings/generate/ | Start background embedding generation for all unprocessed documents |
POST | /api/admin/embeddings/verify/ | Verify embedding integrity across collections |
POST | /api/admin/embeddings/clear/ | Destructive — delete all embeddings from the vector store |
GET | /api/admin/embeddings/progress/ | Poll embedding generation progress |
GET | /api/admin/embeddings/processed/ | List all files that have been embedded, with chunk counts |
DELETE | /api/admin/embeddings/delete/<file_name>/ | Delete embeddings for a single named file |
GET /api/admin/embeddings/status/
POST /api/admin/embeddings/generate/
Starts embedding generation in a background thread. Returns409 Conflict if generation is already running. The backend uses a DocumentLoader to discover all available files (from PostgreSQL file store or filesystem), skips files that are already embedded (checked by MD5 hash), and processes new files sequentially. Use GET /api/admin/embeddings/progress/ to track completion.
GET /api/admin/embeddings/progress/
Polls theembedding_progress.json file written by the background embedding thread. Returns an idle state if no generation has been started.
POST /api/admin/embeddings/clear/
DELETE /api/admin/embeddings/delete/<file_name>/
Deletes all embedding chunks for a single document. Useful when you want to re-process a file after it has been updated. After deletion, re-runPOST /api/admin/embeddings/generate/ to rebuild the embeddings.
Optional MD5 hash of the file for more precise deletion targeting. If omitted, all chunks matching
file_name are deleted.Metrics
The metrics endpoints expose the performance and quality data collected byMetricsTracker during each RAG query. Data is stored in the QueryMetrics and RAGASMetrics Django models and used for thesis-level analysis of the system.
| Method | Path | Description |
|---|---|---|
GET | /api/admin/metrics/ | Aggregated system metrics: latency, processing speed, response quality score |
GET | /api/admin/metrics/queries/ | Paginated list of individual query records with performance breakdown |
GET | /api/admin/metrics/queries/<query_id>/ | Full detail for a single query with metric calculation explanations |
GET | /api/admin/metrics/ratings/ | Aggregated rating metrics: distribution, top issues, trending messages |
GET /api/admin/metrics/
Returns the three top-level KPIs used for system evaluation:| Field | Unit | Description |
|---|---|---|
latenciaTotal | seconds | Average total response latency across all queries |
reduccionTiempo | tokens/second | Average LLM generation throughput |
calidadRespuesta | 0–1 score | Composite RAGAS quality score (faithfulness + answer relevancy + context precision) |
GET /api/admin/metrics/queries/
Page number.
Records per page.
When
true, returns only queries classified as complex by the adaptive top-k algorithm.GET /api/admin/metrics/queries/<query_id>/
Returns a single query record with full metric detail and human-readable calculation explanations. Thequery_id is a UUID string obtained from the query_id field in the paginated list.
GET /api/admin/metrics/ratings/
Returns aggregated rating statistics for the admin panel: distribution of likes/dislikes, period stats (last week/month), top issue tags from dislike ratings, and the top 5 most-liked and most-disliked messages.Pipeline
| Method | Path | Description |
|---|---|---|
GET | /api/admin/pipeline/status/ | Detailed RAG pipeline component status including Drive, embeddings, and vector store |
GET /api/admin/pipeline/status/
Checks each pipeline component independently and returns an overall health assessment.| Component | true when… |
|---|---|
drive_sync | GoogleDriveManager.is_authenticated() returns true |
embeddings | EmbeddingManager instantiates without error |
vector_store | At least one collection exists in ChromaDB (or pgvector is reachable) |
pipeline | Both embeddings and vector_store are true |
overall field is "operational" when pipeline is true, and "degraded" otherwise.