How shivanshsinghal06/folio works
Folio is a document-grounded Q&A application: users upload PDF/DOCX files, then ask questions over all ready documents or a selection. The API extracts and chunks files, embeds and stores passages, and answers questions through hybrid retrieval, reranking, and citation-aware generation; it also offers retrieval-only search and conversation management. The graph reflects documented capabilities and indexed module references. Some ingestion and persistence implementations were not excerpted, so their documented relationships cite the README.
Main entry points: pipeline.py Retrieval pipeline · documents.py Document service · answering.py Answer composition · api.ts API client
Components 25
Web interface
- Folio interface
frontend/src/App.tsx - API client
frontend/src/api.ts
HTTP API
- Document routes
backend/app/api/routes/documents.py - Conversation routes
backend/app/api/routes/conversations.py - Search route
backend/app/api/routes/search.py - Service wiring
backend/app/api/deps.py
Document ingestion
- Document service
backend/app/services/documents.py - Upload validation
backend/app/services/uploads.py - Text extraction
backend/app/services/ingestion/extract.py - Passage chunking
backend/app/services/ingestion/chunk.py - Embedding service
backend/app/services/embeddings/bedrock.py
Hybrid retrieval
- Retrieval pipeline
backend/app/services/retrieval/pipeline.py - Lexical search
backend/app/services/retrieval/lexical.py - Vector search
backend/app/services/retrieval/vector.py - Reranking
backend/app/services/reranking/feature.py - Rank fusion
backend/app/services/retrieval/fusion.py
Answering
- Conversation service
backend/app/services/conversations.py - Answer composition
backend/app/services/answering.py - Answer generation
backend/app/services/generation/bedrock.py - Prompt and history
backend/app/services/generation/prompt.py - Citation builder
backend/app/services/generation/citations.py
Models and integrations
- Domain tables
backend/app/models/tables.py - PostgreSQL + pgvector
- Amazon Bedrock
Other components
- User
Connections 33
- User → Folio interface: uses
- Folio interface → API client: calls
frontend/src/App.tsx - API client → Document routes: sends requests
- API client → Conversation routes: sends requests
- API client → Search route: sends requests
- Document routes → Document service: delegates
backend/app/api/routes/documents.py - Document routes → Upload validation: validates upload
backend/app/api/routes/documents.py - Document service → Text extraction: extracts text
- Document service → Passage chunking: splits passages
- Document service → Embedding service: embeds passages
- Document service → Domain tables: persists documents
- Text extraction → Passage chunking: provides text
- Embedding service → Amazon Bedrock: requests embeddings
backend/app/services/embeddings/bedrock.py - Conversation routes → Conversation service: delegates
backend/app/api/routes/conversations.py - Search route → Answer composition: delegates
backend/app/api/routes/search.py - Conversation service → Answer composition: composes answer
backend/app/services/conversations.py - Answer composition → Retrieval pipeline: retrieves passages
backend/app/services/answering.py - Retrieval pipeline → Embedding service: embeds query
- Retrieval pipeline → Lexical search: searches terms
- Retrieval pipeline → Vector search: searches vectors
- Retrieval pipeline → Rank fusion: fuses rankings
backend/app/services/retrieval/pipeline.py - Retrieval pipeline → Reranking: reranks candidates
- Lexical search → PostgreSQL + pgvector: queries full text
- Vector search → PostgreSQL + pgvector: queries vectors
- Answer composition → Answer generation: generates answer
backend/app/services/answering.py - Answer generation → Prompt and history: formats prompt
backend/app/services/generation/bedrock.py - Answer generation → Amazon Bedrock: requests completion
backend/app/services/generation/bedrock.py - Answer composition → Citation builder: builds citations
backend/app/services/answering.py - Conversation service → Domain tables: stores messages
backend/app/services/conversations.py - Domain tables → PostgreSQL + pgvector: maps database
- Service wiring → Embedding service: provides service
backend/app/api/deps.py - Service wiring → Lexical search: provides service
backend/app/api/deps.py - Service wiring → Vector search: provides service
backend/app/api/deps.py