How saqib632/bookshelf works
This is an authenticated book-chat application with document ingestion and grounded RAG/CRAG answers. The principal flow is upload → asynchronous extraction/chunking/indexing → scoped retrieval and corrective retry → answer with citations. The README describes the implementation as awaiting architecture approval, while the supplied tree and excerpts contain runtime code; unsampled frontend/API wiring and some route details are therefore shown only where documented or left unlinked.
Main entry points: api.py REST routes · tasks.py Processing worker · db.py MongoDB records · services.py Chat orchestration
Components 19
User experience
- Chat interface
frontend/src/app/page.tsx - HTTP client
frontend/src/lib/api.ts
API and identity
- REST routes
backend/app/api.py - Token identity
backend/app/auth.py - Request schemas
backend/app/models.py - API runtime
backend/app/main.py
Document ingestion
- Job dispatch
backend/app/api.py - Redis broker
- Processing worker
backend/app/workers/tasks.py - Extract and chunk
backend/app/processing.py - Temporary uploads
Grounded chat
- Chat orchestration
backend/app/services.py - CRAG retrieval
backend/app/services.py - Grounded answering
backend/app/providers.py
Persistence and providers
- Embedding provider
backend/app/providers.py - Vector search
backend/app/providers.py - MongoDB records
backend/app/db.py - Runtime settings
backend/app/config.py
Other components
- Book owner
Connections 27
- Book owner → Chat interface: asks and uploads
README.md - Chat interface → HTTP client: uses client
- HTTP client → REST routes: sends requests
README.md - API runtime → REST routes: registers routes
backend/app/main.py - REST routes → Token identity: authenticates
backend/app/api.py - REST routes → Request schemas: validates payloads
backend/app/api.py - Token identity → MongoDB records: loads user
backend/app/auth.py - REST routes → MongoDB records: reads and writes
backend/app/api.py - REST routes → Job dispatch: dispatches upload
backend/app/api.py - Job dispatch → Redis broker: queues job
- Processing worker → Redis broker: uses broker
backend/app/workers/tasks.py - Processing worker → MongoDB records: updates job records
backend/app/workers/tasks.py - Processing worker → Temporary uploads: reads and deletes
backend/app/workers/tasks.py - REST routes → Temporary uploads: stages upload
backend/app/api.py - Processing worker → Extract and chunk: extracts and chunks
backend/app/workers/tasks.py - Processing worker → Embedding provider: embeds chunks
backend/app/workers/tasks.py - Processing worker → Vector search: upserts vectors
backend/app/workers/tasks.py - REST routes → Chat orchestration: creates chat response
backend/app/api.py - Chat orchestration → CRAG retrieval: runs retrieval loop
backend/app/services.py - CRAG retrieval → MongoDB records: reads chunks
backend/app/services.py - CRAG retrieval → Embedding provider: embeds query
backend/app/services.py - CRAG retrieval → Vector search: searches vectors
backend/app/services.py - Chat orchestration → Grounded answering: generates answer
backend/app/services.py - Chat orchestration → MongoDB records: stores chat and citations
backend/app/services.py - API runtime → MongoDB records: opens database
backend/app/main.py - API runtime → Runtime settings: loads settings
backend/app/main.py - Embedding provider → Runtime settings: selects provider
backend/app/providers.py