How debabratamishra/litemind-ui works
Project Type and Purpose
• LiteMindUI is a full-stack web application providing a hybrid LLM interface:
• Streamlit frontend (at localhost:8501) for interactive UI
• FastAPI backend (at localhost:8000) for REST + streaming API endpoints
• Modular Python services for RAG, embeddings, Ollama & Hugging Face (vLLM) integration
• Document ingestion pipeline (PDF/DOCX/TXT → extractor → vector store)
Main Components
a. Frontend Layer (Streamlit)
• Entrypoint: streamlit_app.py
• UI modules under app/frontend: pages, components (streaming handler, text renderer, voice input), services (chat_service, rag_service, backend_service)
b. API Layer (FastAPI)
• Entrypoint: main.py
• Routers under app/backend/api: chat.py, rag.py, health.py, models.py
• Core logic under app/backend/core: config, embeddings, CORS, health checks
• Pydantic models under app/backend/models
c. Service Layer
• app/services:
• host_service_manager.py (auto-failover between Ollama & vLLM)
• ollama.py (local LLM)
• vllm_service.py (Hugging Face)
• rag_service.py (vector search + retrieval)
• speech_service.py (optional voice I/O)
d. Ingestion Pipeline
• app/ingestion: file_ingest.py, enhanced_extractors.py, enhanced_document_processor.py
• Takes uploaded docs → extracts text → generates embeddings → stores in Chroma (uploads/chroma_db)
e. Persistence & External
• File storage: /uploads directory
• Vector DB: Chroma on disk
• External LLM endpoints: Ollama API (http://localhost:11434), Hugging Face (via vLLM)
Relationships & Data Flows
1. User interacts in browser → Streamlit frontend UI
2. Frontend invokes backend via HTTP (REST or streaming)
3. FastAPI routes request to appropriate API module
4. API handler calls Service Layer (chat, rag, embeddings)
5. Service Layer may:
– Hit local Ollama API or vLLM (external)
– Perform vector search on local Chroma DB
– Call ingestion pipeline for new uploads
6. Response (possibly streaming tokens) flows back through API to frontend
7. Frontend renders responses in real time
Architectural Patterns & Principles
• Layered separation: UI / API / Services / Persistence
• Modular “service” classes for extensibility
• Auto-failover manager for backend switching
• Async, non-blocking I/O in FastAPI for high throughput
• Containerized micro-services in Docker Compose (one container each for backend & frontend)