How goeldivya2/karya- works
Karya is a collaborative document Q&A backend. Users authenticate, create or join rooms, upload PDFs, and ask room-scoped questions; the backend processes documents into searchable vectors and uses retrieved context to generate answers. MongoDB holds users, rooms, documents, and question history, while Socket.IO broadcasts document and question events. The README documents the full RAG stages; several service files were not excerpted, so those pipeline links rely on that documentation.
Main entry points: documentController.js Document lifecycle · questionController.js Question answering · app.js HTTP app · server.js HTTP and socket server
Components 30
API and access
- HTTP app
backend/app.js - Auth routes
backend/routes/authRoutes.js - Authentication
backend/controllers/authController.js - JWT access
backend/middleware/authMiddleware.js - HTTP and socket server
backend/server.js
Collaborative rooms
- Room routes
backend/routes/roomRoutes.js - Room management
backend/controllers/roomController.js
Document ingestion
- Document routes
backend/routes/documentRoutes.js - PDF upload
backend/middleware/uploadMiddleware.js - Document lifecycle
backend/controllers/documentController.js - PDF extraction
backend/services/pdfProcessor.js - Text chunking
backend/services/chunkService.js
Question answering
- Embedding generation
backend/services/embeddingService.js - Vector operations
backend/services/pineconeService.js - Question routes
backend/routes/questionRoutes.js - Question answering
backend/controllers/questionController.js - Answer generation
backend/services/llmService.js
Persistence and events
- User records
backend/models/User.js - Room records
backend/models/Room.js - Document records
backend/models/Documents.js - Question history
backend/models/Question.js - MongoDB connection
backend/config/db.js - Pinecone client
backend/config/pinecone.js - Socket access
backend/sockets/socket.js - Socket events
backend/sockets/socketHandler.js
Other components
- User
- MongoDB
- Pinecone
- Google Gemini
- Room participants
Connections 39
- User → HTTP app: sends requests
README.md - HTTP app → Auth routes: mounts
backend/app.js - HTTP app → Room routes: mounts
backend/app.js - HTTP app → Document routes: mounts
backend/app.js - HTTP app → Question routes: mounts
backend/app.js - Auth routes → Authentication: routes to
backend/routes/authRoutes.js - Room routes → Room management: routes to
backend/routes/roomRoutes.js - Document routes → Document lifecycle: routes to
backend/routes/documentRoutes.js - Document routes → PDF upload: accepts file
backend/routes/documentRoutes.js - Question routes → Question answering: routes to
backend/routes/questionRoutes.js - Room routes → JWT access: checks JWT
backend/routes/roomRoutes.js - Document routes → JWT access: checks JWT
backend/routes/documentRoutes.js - Question routes → JWT access: checks JWT
backend/routes/questionRoutes.js - Authentication → User records: uses
backend/controllers/authController.js - Room management → Room records: reads and writes
backend/controllers/roomController.js - Document lifecycle → Room records: checks membership
backend/controllers/documentController.js - Document lifecycle → Document records: creates and deletes
backend/controllers/documentController.js - Document lifecycle → PDF extraction: extracts text
backend/controllers/documentController.js - PDF extraction → Text chunking: provides text
README.md - Document lifecycle → Text chunking: chunks text
backend/controllers/documentController.js - Document lifecycle → Embedding generation: embeds chunks
backend/controllers/documentController.js - Document lifecycle → Vector operations: stores or deletes
backend/controllers/documentController.js - Embedding generation → Google Gemini: requests embeddings
backend/services/embeddingService.js - Vector operations → Pinecone client: uses client
backend/services/pineconeService.js - Vector operations → Pinecone: queries vectors
README.md - Question answering → Room records: checks membership
backend/controllers/questionController.js - Question answering → Embedding generation: embeds question
backend/controllers/questionController.js - Question answering → Vector operations: retrieves chunks
backend/controllers/questionController.js - Question answering → Answer generation: generates answer
backend/controllers/questionController.js - Answer generation → Google Gemini: invokes model
backend/services/llmService.js - Question answering → Question history: saves and reads
backend/controllers/questionController.js - HTTP and socket server → HTTP app: serves
backend/server.js - HTTP and socket server → MongoDB connection: connects database
backend/server.js - MongoDB connection → MongoDB: connects
README.md - HTTP and socket server → Socket events: initializes events
backend/server.js - HTTP and socket server → Socket access: sets socket
backend/server.js - Document lifecycle → Socket access: broadcasts document events
backend/controllers/documentController.js - Question answering → Socket access: broadcasts questions
backend/controllers/questionController.js - Socket events → Room participants: supports real-time collaboration
README.md