doc-qa/
├── src/
│ ├── app/
│ │ ├── api/ # API routes using App Router
│ │ │ └── upload/
│ │ │ └── route.ts
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── components/
│ │ ├── ui/ # shadcn components
│ │ ├── chat/ # chat-related components
│ │ │ ├── chat-interface.tsx
│ │ │ └── message-list.tsx
│ │ └── doc/ # document-related components
│ │ ├── document-viewer.tsx
│ │ └── file-upload.tsx
│ ├── lib/ # utility functions
│ │ ├── utils.ts
│ │ ├── api-client.ts
│ │ └── doc-parser.ts
│ └── types/ # type definitions
│ └── index.d.ts
├── public/
└── // ...config files
npx create-next-app@latest doc-qa --typescript --tailwind --eslint
cd doc-qa
npx shadcn-ui@latest init
npm install @google/generative-ai react-pdf @microsoft/fast-react-wrapper uuid
npm install -D @types/uuid
Create .env.local
:
GOOGLE_API_KEY=your_gemini_api_key
- Create document upload endpoint
- Implement parsers for different file types
- Store processed documents in filesystem/cloud
- Generate embeddings using Gemini API
- Set up Gemini API client
- Create chat context management
- Implement streaming responses
- Store chat history
- Install required shadcn components:
npx shadcn-ui@latest add button input textarea toast dialog sheet scroll-area separator
- Create component hierarchy:
- Document viewer
- Chat interface
- File upload
- Navigation
- Configure API routes
- Set up document storage
- Implement basic UI layout
- Create upload mechanism
- Implement document parsers
- Set up document viewer
- Implement Gemini integration
- Create chat UI components
- Add streaming support
- Add error handling
- Implement loading states
- Add responsiveness
- Add dark mode support
- Document processing
- Chat functionality
- UI components
- File upload flow
- Chat completion flow
- Document viewing
- Configure production environment
- Set up cloud storage
- Deploy to Vercel/similar platform
- Implement rate limiting
- Add file type validation
- Set up authentication if needed
- Configure CORS policies
- Implement caching
- Add pagination for chat history
- Optimize document processing
- Configure proper chunking for large documents