How sachin-prasad-29/ai-document-assistant works
AI Document Assistant is a FastAPI backend for authenticated document management and question answering. Users upload files or submit text; the backend stores document records, extracts and chunks content, and indexes it for semantic search. Users can then list, retrieve, summarize, or ask questions about documents; agent tools provide retrieval and gated deletion. The graph captures routes and service calls visible in excerpts and the source index. Chat-to-agent dispatch is not shown in the available chat excerpt, so that connection is omitted.
Main entry points: documents.py Document routes · vector_store.py Vector search · crud.py Document CRUD · tools.py Document tools
Components 21
API and identity
- FastAPI application
backend/app/main.py - Document routes
backend/app/api/documents.py - Chat routes
backend/app/api/chat.py - JWT authorization
backend/app/auth.py - Runtime settings
backend/app/config.py - API schemas
backend/app/schemas.py
Document processing
- Document ingestion
backend/app/services/ingestion.py - Document lifecycle
backend/app/services/documents.py - Document summaries
backend/app/services/summarizer.py
AI assistant
- Agent orchestration
backend/app/agent/agent.py - Agent prompts
backend/app/agent/prompts.py - Document tools
backend/app/agent/tools.py - Vector search
backend/app/services/vector_store.py
Persistence
- Document CRUD
backend/app/db/crud.py - Document model
backend/app/db/models.py - SQLite database
backend/app/db/database.py - Chroma index
backend/app/services/vector_store.py
Other components
- Client user
- NVIDIA embeddings
- Google Gemini
- Supabase JWKS
Connections 30
- Client user → FastAPI application: sends requests
backend/app/main.py - FastAPI application → Document routes: mounts routes
backend/app/main.py - FastAPI application → Chat routes: mounts routes
backend/app/main.py - FastAPI application → Agent orchestration: builds at startup
backend/app/main.py - Document routes → JWT authorization: checks identity
backend/app/api/documents.py - JWT authorization → Supabase JWKS: fetches signing keys
backend/app/auth.py - Document routes → Document CRUD: creates and queries
backend/app/api/documents.py - Document routes → Document ingestion: ingests documents
backend/app/api/documents.py - Document routes → Document summaries: requests summaries
backend/app/api/documents.py - Document routes → Document lifecycle: deletes documents
backend/app/api/documents.py - Document routes → API schemas: validates responses
backend/app/api/documents.py - Document ingestion → Document CRUD: loads and updates records
backend/app/services/ingestion.py - Document ingestion → Vector search: indexes chunks
backend/app/services/ingestion.py - Document lifecycle → Vector search: removes indexed chunks
backend/app/services/documents.py - Document summaries → Document CRUD: reads and caches summary
backend/app/services/summarizer.py - Document summaries → Google Gemini: generates summary
backend/app/services/summarizer.py - Agent orchestration → Agent prompts: uses prompts
backend/app/agent/agent.py - Agent orchestration → Document tools: registers tools
backend/app/agent/agent.py - Document tools → Document CRUD: lists and retrieves
backend/app/agent/tools.py - Document tools → Vector search: searches passages
backend/app/agent/tools.py - Document tools → Document summaries: requests summaries
backend/app/agent/tools.py - Document tools → Document lifecycle: deletes with approval
backend/app/agent/tools.py - Vector search → NVIDIA embeddings: embeds text
backend/app/services/vector_store.py - Vector search → Chroma index: stores and searches
backend/app/services/vector_store.py - Document CRUD → Document model: queries model
backend/app/db/crud.py - Document CRUD → SQLite database: persists records
backend/app/db/crud.py - SQLite database → Runtime settings: reads data directory
backend/app/db/database.py - Document ingestion → Runtime settings: reads chunk settings
backend/app/services/ingestion.py - Vector search → Runtime settings: reads index settings
backend/app/services/vector_store.py - Document summaries → Runtime settings: reads model setting
backend/app/services/summarizer.py