How dhruvkachhadiya3350/ai-workspace works
AI Workspace is a multi-model chat and document-RAG product. Users authenticate, organize conversations and projects, select a Bedrock model, and stream responses; optional uploaded documents are validated, stored, extracted and indexed for scoped retrieval and citations. The graph also preserves model discovery, usage tracking and diagnostics. README statements support the frontend/backend and cloud-service boundaries; source-index references support several backend calls. Some frontend internals and RAG stages are unsampled, so their links are limited to documented relationships.
Main entry points: db.py PostgreSQL and pgvector · chat_service.py Chat orchestration · attachments.py Attachment routes · WorkspaceApp.tsx Workspace UI
Components 31
Workspace interface
- Workspace UI
frontend/src/components/WorkspaceApp.tsx - API client
frontend/src/services/api.ts - Auth screens
frontend/src/components/AuthScreen.tsx - Message rendering
frontend/src/components/MessageItem.tsx
Backend API
- Authentication routes
backend/app/routes/auth.py - Conversation routes
backend/app/routes/conversations.py - Project routes
backend/app/routes/projects.py - Chat routes
backend/app/routes/chat.py - Attachment routes
backend/app/routes/attachments.py - Model routes
backend/app/routes/models.py - Usage routes
backend/app/routes/usage.py - Diagnostics route
backend/app/routes/health.py - Auth and JWT
backend/app/utils/auth.py
Chat and models
- Chat orchestration
backend/app/services/chat_service.py - Model discovery
backend/app/services/bedrock/discovery.py - Chat adapter registry
backend/app/services/bedrock/adapters/registry.py - Converse adapter
backend/app/services/bedrock/adapters/converse_adapter.py - Invoke adapter
backend/app/services/bedrock/adapters/invoke_adapter.py - Embedding adapter
backend/app/services/bedrock/adapters/embedding_adapter.py
Documents and retrieval
- Upload validation
backend/app/services/storage/validators.py - Document extraction
backend/app/services/rag/extractors.py - Chunk and index
backend/app/services/rag/indexer.py - Semantic retrieval
backend/app/services/rag/retriever.py - Optional OCR
backend/app/services/rag/ocr_service.py
Persistence and cloud
- Attachment storage
backend/app/services/storage/s3_service.py - Usage tracking
backend/app/services/usage/tracker.py - PostgreSQL and pgvector
backend/app/utils/db.py - Amazon S3
- Amazon Bedrock
- Amazon Textract
Other components
- Workspace user
Connections 36
- Workspace user → Workspace UI: uses
- Workspace UI → API client: requests
- API client → Authentication routes: REST and SSE
- Workspace user → Auth screens: signs in
- Auth screens → API client: authenticates
- Workspace UI → Message rendering: renders
- Chat routes → Chat orchestration: delegates
backend/app/routes/chat.py - Conversation routes → Chat orchestration: uses
backend/app/routes/conversations.py - Chat orchestration → Chat adapter registry: resolves adapter
backend/app/services/chat_service.py - Chat adapter registry → Converse adapter: selects
backend/app/services/bedrock/adapters/registry.py - Chat adapter registry → Invoke adapter: selects
backend/app/services/bedrock/adapters/registry.py - Converse adapter → Amazon Bedrock: invokes
- Invoke adapter → Amazon Bedrock: invokes
- Chat orchestration → Semantic retrieval: retrieves context
backend/app/services/chat_service.py - Chat orchestration → Usage tracking: records usage
backend/app/services/chat_service.py - Model routes → Model discovery: syncs models
backend/app/routes/models.py - Model discovery → Amazon Bedrock: discovers catalog
- Model discovery → PostgreSQL and pgvector: persists catalog
backend/app/services/bedrock/discovery.py - Attachment routes → Upload validation: validates upload
backend/app/routes/attachments.py - Attachment routes → Attachment storage: stores files
backend/app/routes/attachments.py - Attachment storage → Amazon S3: reads and writes
- Attachment routes → Document extraction: extracts text
backend/app/routes/attachments.py - Attachment routes → Chunk and index: indexes document
backend/app/routes/attachments.py - Chunk and index → Embedding adapter: generates vectors
- Embedding adapter → Amazon Bedrock: embeds text
- Chunk and index → PostgreSQL and pgvector: stores chunks
- Semantic retrieval → Embedding adapter: embeds query
backend/app/services/rag/retriever.py - Semantic retrieval → PostgreSQL and pgvector: searches vectors
backend/app/services/rag/retriever.py - Optional OCR → Amazon Textract: requests OCR
- Authentication routes → Auth and JWT: hashes and verifies
backend/app/routes/auth.py - Auth and JWT → PostgreSQL and pgvector: checks user
backend/app/utils/auth.py - Conversation routes → PostgreSQL and pgvector: reads and writes
backend/app/routes/conversations.py - Project routes → PostgreSQL and pgvector: reads and writes
backend/app/routes/projects.py - Usage routes → Usage tracking: requests summaries
backend/app/routes/usage.py - Usage tracking → PostgreSQL and pgvector: stores usage
backend/app/services/usage/tracker.py - Diagnostics route → PostgreSQL and pgvector: checks health
backend/app/routes/health.py