How bakrianoo/mini-rag works
mini-rag is a FastAPI question-answering service that ingests project files, chunks and indexes their content, then answers queries with retrieval-augmented generation. The principal workflow runs from API routes through controllers and Celery tasks, storing project, asset, and chunk records alongside vectors. NLPController coordinates embeddings, vector search, prompt construction, and generation. The README documents PostgreSQL/PgVector, Qdrant, OpenAI/Cohere, and Celery capabilities; the sampled excerpts do not show every route or provider invocation, so those links are omitted where unsupported.
Main entry points: file_processing.py File processing task · data.py Data routes · NLPController.py NLP controller · VectorDBProviderFactory.py Vector DB factory
Components 23
API and control
- FastAPI app
src/main.py - Data routes
src/routes/data.py - NLP routes
src/routes/nlp.py - Data controller
src/controllers/DataController.py
File ingestion
- Project files
src/controllers/ProjectController.py - File parsing
src/controllers/ProcessController.py
Project persistence
- Project records
src/models/ProjectModel.py - Asset records
src/models/AssetModel.py - Chunk records
src/models/ChunkModel.py - PostgreSQL
Retrieval and generation
- NLP controller
src/controllers/NLPController.py - Vector DB factory
src/stores/vectordb/VectorDBProviderFactory.py - PgVector provider
src/stores/vectordb/providers/PGVectorProvider.py - Qdrant provider
src/stores/vectordb/providers/QdrantDBProvider.py - LLM factory
src/stores/llm/LLMProviderFactory.py - OpenAI provider
src/stores/llm/providers/OpenAIProvider.py - Cohere provider
src/stores/llm/providers/CoHereProvider.py - Prompt templates
src/stores/llm/templates/template_parser.py
Background execution
- File processing task
src/tasks/file_processing.py - Data indexing task
src/tasks/data_indexing.py - Process workflow
src/tasks/process_workflow.py - Celery setup
src/celery_app.py
Other components
- Client
Connections 30
- Client → FastAPI app: requests
- FastAPI app → Data routes: registers
src/main.py - FastAPI app → NLP routes: registers
src/main.py - Data routes → Data controller: calls
src/routes/data.py - Data routes → Project files: calls
src/routes/data.py - Data routes → File parsing: calls
src/routes/data.py - Data routes → File processing task: dispatches
src/routes/data.py - NLP routes → NLP controller: calls
src/routes/nlp.py - NLP routes → Data indexing task: dispatches
src/routes/nlp.py - File processing task → Celery setup: registers task
src/tasks/file_processing.py - Data indexing task → Celery setup: registers task
src/tasks/data_indexing.py - Process workflow → File processing task: invokes
src/tasks/process_workflow.py - Process workflow → Data indexing task: invokes
src/tasks/process_workflow.py - File processing task → Project records: loads project
src/tasks/file_processing.py - File processing task → Asset records: loads assets
src/tasks/file_processing.py - File processing task → File parsing: parses files
src/tasks/file_processing.py - File processing task → Chunk records: writes chunks
src/tasks/file_processing.py - Data indexing task → NLP controller: indexes chunks
src/tasks/data_indexing.py - NLP controller → Prompt templates: reads prompts
src/controllers/NLPController.py - Celery setup → Vector DB factory: configures
src/celery_app.py - Celery setup → LLM factory: configures
src/celery_app.py - Vector DB factory → PgVector provider: selects provider
src/stores/vectordb/VectorDBProviderFactory.py - Vector DB factory → Qdrant provider: selects provider
src/stores/vectordb/VectorDBProviderFactory.py - LLM factory → OpenAI provider: selects provider
src/stores/llm/LLMProviderFactory.py - LLM factory → Cohere provider: selects provider
src/stores/llm/LLMProviderFactory.py - Project records → PostgreSQL: reads and writes
- Asset records → PostgreSQL: reads and writes
- Chunk records → PostgreSQL: reads and writes
- NLP controller → Vector DB factory: uses client
- NLP controller → LLM factory: uses clients