How hardikmangal-9024/benefits-chat-app works
BenefitLens accepts PDFs or URLs, turns them into sectioned documents, and lets users ask questions with streaming answers and citations. Its main flow runs from the landing-page upload controls through document state and an ingestion API, into cached document context used by chat. The chat interface also presents extracted benefits and supports report export; demo mode is a documented capability. Source excerpts establish the central calls, while some client-to-API wiring and demo wiring were not shown, so those links are marked unverified.
Main entry points: app/page.tsx Landing page · chat/page.tsx Chat page · documentStore.ts Document state · route.ts PDF upload API
Components 24
Entry and ingestion
- Landing page
src/app/page.tsx - Upload controls
src/components/upload/DropZone.tsx - Document state
src/store/documentStore.ts
Document processing
- PDF upload API
src/app/api/upload/route.ts - URL upload API
src/app/api/upload-url/route.ts - PDF parser
src/lib/pdf.ts - URL processor
src/lib/urlFetcher.ts - Document cache
src/lib/documentCache.ts - Document model
src/lib/types.ts - Benefit extraction API
src/app/api/extract/route.ts - Benefit logic
src/lib/benefits.ts - Demo data
src/lib/demo.ts
Chat and AI
- Chat state
src/store/chatStore.ts - Streaming chat API
src/app/api/chat/route.ts - AI streaming
src/lib/gemini.ts
Results and export
- Chat page
src/app/chat/page.tsx - Chat window
src/components/chat/ChatWindow.tsx - Benefits panel
src/components/chat/BenefitsPanel.tsx - Message display
src/components/chat/MessageBubble.tsx - Follow-up suggestions
src/components/chat/FollowUpSuggestions.tsx - Citation badge
src/components/ui/CitationBadge.tsx - Export control
src/components/chat/ExportButton.tsx - Report generation
src/lib/exportReport.ts
Other components
- User
Connections 31
- User → Landing page: opens
src/app/page.tsx - Landing page → Upload controls: renders
src/app/page.tsx - Landing page → Document state: starts upload
src/app/page.tsx - Upload controls → Landing page: submits file or URL
src/app/page.tsx - Document state → PDF upload API: posts PDF
- Document state → URL upload API: posts URL
- PDF upload API → PDF parser: processes PDF
src/app/api/upload/route.ts - PDF upload API → Document cache: stores document
src/app/api/upload/route.ts - URL upload API → URL processor: processes URL
src/app/api/upload-url/route.ts - URL upload API → Document cache: stores document
src/app/api/upload-url/route.ts - PDF parser → Document model: produces
src/lib/pdf.ts - URL processor → Document model: produces
src/lib/urlFetcher.ts - PDF upload API → Document model: returns document
src/app/api/upload/route.ts - Landing page → Chat page: navigates after upload
src/app/page.tsx - Chat page → Chat window: renders
src/app/chat/page.tsx - Chat page → Document state: reads document
src/app/chat/page.tsx - Chat window → Chat state: reads and updates
src/components/chat/ChatWindow.tsx - Chat state → Streaming chat API: posts messages
src/store/chatStore.ts - Streaming chat API → Document cache: reads document
src/app/api/chat/route.ts - Streaming chat API → AI streaming: streams completion
src/app/api/chat/route.ts - Chat window → Message display: renders messages
src/components/chat/ChatWindow.tsx - Message display → Follow-up suggestions: renders suggestions
src/components/chat/MessageBubble.tsx - Message display → Chat state: sends follow-up
src/components/chat/MessageBubble.tsx - Chat page → Benefits panel: shows benefits
- Benefit extraction API → Document cache: reads document
src/app/api/extract/route.ts - Benefit logic → AI streaming: uses AI
src/lib/benefits.ts - Chat page → Export control: renders
src/app/chat/page.tsx - Export control → Chat state: reads messages
src/components/chat/ExportButton.tsx - Export control → Document state: reads document
src/components/chat/ExportButton.tsx - Export control → Report generation: generates and downloads
src/components/chat/ExportButton.tsx - Demo data → Landing page: provides demo content