How ai-builders-iran/chemlib-ai works
ChemLib AI combines a chemistry-library RAG product with a separate structured-extraction demo. The primary workflow is admin ingestion into a persistent vector index, followed by user chat or source comparison that retrieves passages, applies a grounding threshold, and returns cited answers. The Streamlit UI and REST API expose these capabilities; extraction reuses document loading and processing before producing validated schemas. Relationships for unsampled subsystems are included only where documented in the README or named by the source index; optional OCR and provider fallback are marked dashed.
Main entry points: services.py UI backend services · ingestion.py RAG ingestion · rag_service.py RAG service · pipeline.py Extraction orchestration
Components 23
User Interfaces
- Streamlit app
app/streamlit_app/app.py - Chat view
app/streamlit_app/docai_ui/chat_view.py - Admin panel
app/streamlit_app/docai_ui/admin_view.py - REST API
app/api/api_app.py - UI backend services
app/streamlit_app/docai_ui/services.py - Extraction demo
app/streamlit_app/extraction_demo.py
Document Ingestion
- RAG ingestion
rag/ingestion.py - Document loading
src/loaders/document_loader.py - Scanned PDF OCR
src/loaders/ocr.py - Cleaning and chunking
src/processing/pipeline.py - Recursive chunker
src/processing/chunking/recursive.py
Grounded RAG
- RAG service
rag/rag_service.py - RAG and compare prompts
rag/prompts.py
Structured Extraction
- Extraction orchestration
src/pipeline/pipeline.py - Document extractor
src/extraction/extractor.py - Validated schemas
src/schemas/common.py
Shared Services
- BGE-M3 embeddings
src/embedding/embedding.py - Chroma vector store
src/retrieval/vector_store.py - Private session store
src/retrieval/session_store.py - Gemini provider
src/extraction/providers/gemini_provider.py - OpenRouter provider
src/extraction/providers/openrouter_provider.py
Other components
- Students
- Library admins
Connections 31
- Students → Streamlit app: use chat
README.md - Library admins → Streamlit app: manage library
README.md - Streamlit app → Chat view: renders
app/streamlit_app/app.py - Streamlit app → Admin panel: renders
app/streamlit_app/app.py - Chat view → UI backend services: requests services
app/streamlit_app/docai_ui/chat_view.py - Admin panel → UI backend services: manages documents
app/streamlit_app/docai_ui/admin_view.py - REST API → RAG ingestion: ingests files
app/api/api_app.py - REST API → RAG service: serves chat and compare
app/api/api_app.py - REST API → Extraction orchestration: runs extraction
README.md - UI backend services → RAG ingestion: starts ingestion
app/streamlit_app/docai_ui/services.py - UI backend services → RAG service: creates service
app/streamlit_app/docai_ui/services.py - UI backend services → Chroma vector store: creates store
app/streamlit_app/docai_ui/services.py - UI backend services → Private session store: holds private documents
app/streamlit_app/docai_ui/services.py - RAG ingestion → Document loading: loads documents
rag/ingestion.py - RAG ingestion → Cleaning and chunking: cleans documents
rag/ingestion.py - RAG ingestion → Recursive chunker: chunks documents
rag/ingestion.py - RAG ingestion → Chroma vector store: indexes chunks
rag/ingestion.py - Document loading → Scanned PDF OCR: uses for scanned PDFs
README.md - Chroma vector store → BGE-M3 embeddings: embeds and searches
src/retrieval/vector_store.py - RAG service → Chroma vector store: retrieves passages
rag/rag_service.py - RAG service → RAG and compare prompts: builds prompts
rag/rag_service.py - RAG service → Gemini provider: requests structured output
rag/rag_service.py - RAG service → OpenRouter provider: falls back on failure
rag/rag_service.py - Extraction demo → Extraction orchestration: submits documents
README.md - Extraction orchestration → Document loading: loads documents
src/pipeline/pipeline.py - Extraction orchestration → Cleaning and chunking: processes text
src/pipeline/pipeline.py - Extraction orchestration → Recursive chunker: chunks text
src/pipeline/pipeline.py - Extraction orchestration → Document extractor: extracts fields
src/pipeline/pipeline.py - Document extractor → Validated schemas: validates output
src/extraction/extractor.py - Document extractor → Gemini provider: tries providers
README.md - Document extractor → OpenRouter provider: fallback provider
README.md