How krisnasetyadi/doculens-server works
DocuLens is a FastAPI document and chat Q&A service: users upload or connect sources, the backend indexes searchable content, and hybrid queries retrieve evidence from PDFs, PostgreSQL, and chat logs before producing an LLM answer. The graph also captures the separate agnostic multi-source RAG pipeline and documented API capabilities such as collection management, authentication, and persisted chat sessions. Some route and processor implementations were not sampled, so their links reflect README claims or explicit entry-point wiring rather than inferred internal call chains.
Main entry points: main.py FastAPI app · hybrid.py Hybrid query · chat_ingest.py Chat indexing · pipeline.py Agnostic RAG
Components 26
API and Accounts
- FastAPI app
main.py - Authentication
router/auth.py - Chat sessions
router/sessions.py
Source Ingestion
- PDF upload
router/upload.py - PDF collections
router/collections.py - PDF processing
processor.py - Chat imports
router/chat.py - Chat parsing
chat_parser.py - Chat indexing
chat_ingest.py - Telegram sync
router/telegram.py - DB connections
router/database_connections.py
Retrieval and Answers
- Hybrid query
router/hybrid.py - Agnostic RAG
agnostic/pipeline.py - Source adapters
agnostic/adapters.py - Runtime indexing
agnostic/indexer.py - Chunk retrieval
agnostic/retriever.py - Answer generation
agnostic/generator.py - Database search
database.py - Answer with sources
Persistence
- Storage wrapper
storage.py - App database
app_db.py - Vector indices
External Services
- PostgreSQL
- Supabase storage
- LLM providers
Other components
- User
Connections 35
- User → FastAPI app: sends requests
- FastAPI app → Authentication: dispatches auth
- FastAPI app → PDF upload: dispatches upload
- FastAPI app → PDF collections: dispatches collection requests
- FastAPI app → Hybrid query: dispatches queries
- FastAPI app → Chat imports: dispatches chat imports
- FastAPI app → Telegram sync: dispatches Telegram routes
- FastAPI app → Chat sessions: dispatches session requests
- FastAPI app → DB connections: dispatches connection requests
- PDF upload → PDF processing: processes PDFs
- PDF processing → Vector indices: builds index
- PDF collections → Storage wrapper: manages collection files
- Chat imports → Chat parsing: parses exports
- Chat imports → Chat indexing: ingests messages
- Telegram sync → Chat indexing: ingests synced messages
- Chat indexing → Vector indices: saves chat index
- Chat indexing → Storage wrapper: persists chat data
- Hybrid query → PDF processing: searches PDF collections
- Hybrid query → Database search: searches database
- Hybrid query → Chat indexing: searches chat collections
- Database search → PostgreSQL: queries
- DB connections → App database: stores connection records
- DB connections → PostgreSQL: inspects external schema
- Agnostic RAG → Source adapters: loads source data
- Agnostic RAG → Runtime indexing: builds index
- Agnostic RAG → Chunk retrieval: retrieves chunks
- Agnostic RAG → Answer generation: generates answer
- Source adapters → PostgreSQL: reads database sources
- Runtime indexing → Vector indices: creates FAISS index
- Chunk retrieval → Vector indices: searches index
- Answer generation → LLM providers: requests completion
- Answer generation → Answer with sources: returns answer
- Hybrid query → Answer with sources: returns results
- Chat sessions → App database: stores session history
- Storage wrapper → Supabase storage: reads and writes