A Next.js application that allows users to upload, manage, and ask questions about PDF documents using AI-powered analysis with the Gemini API.
- Secure Authentication: JWT-based user authentication and authorization
- Document Management: Upload, view, and organize PDF, DOC, and DOCX files
- AI-Powered Q&A: Ask questions about uploaded documents and get intelligent answers
- Real-time Interaction: Interactive chat interface for document queries
- Responsive Design: Mobile-friendly interface built with Tailwind CSS
- Server Status Monitoring: Smart server startup notifications for cold starts
- Framework: Next.js 15 with App Router
- Styling: Tailwind CSS
- Authentication: JWT tokens with automatic refresh
- HTTP Client: Axios for API communication
- UI Components: Custom React components
- Date Handling: date-fns for date formatting
- Deployment: Optimized for Vercel deployment
Before running this application, ensure you have:
- Node.js 18+ installed
- npm or yarn package manager
- A backend API server running (Django backend recommended)
- Gemini API access for document analysis
git clone https://github.com/Nakul-Jaglan/ai-document-frontend.git
cd ai-document-frontendnpm install
# or
yarn installCreate a .env.local file in the root directory:
NEXT_PUBLIC_API_URL=http://localhost:8000Replace the API URL with your backend server URL.
npm run dev
# or
yarn devOpen http://localhost:3000 in your browser.
npm run build
npm startβββ app/
β βββ dashboard/
β β βββ page.js # Main dashboard page
β βββ document/
β β βββ [id]/
β β βββ question/
β β βββ page.js # Document Q&A page
β βββ login/
β β βββ page.js # Login page
β βββ register/
β β βββ page.js # Registration page
β βββ globals.css # Global styles
β βββ layout.js # Root layout with AuthProvider
β βββ page.js # Home page (redirects)
βββ components/
β βββ DocumentCard.js # Document display component
β βββ Navbar.js # Navigation component
β βββ PrivateRoute.js # Route protection
β βββ ProtectedRoute.js # Alternative route protection
β βββ UploadModal.js # File upload modal
βββ contexts/
β βββ AuthContext.js # Authentication context
βββ lib/
β βββ api.js # API client and endpoints
βββ public/ # Static assets
- Registration/Login: Users create accounts or sign in
- JWT Tokens: Access and refresh tokens for secure API calls
- Automatic Refresh: Seamless token renewal on expiration
- Route Protection: Private routes require authentication
- Logout: Secure session termination
- PDF documents
- Microsoft Word (.doc, .docx)
- Drag-and-drop file upload
- Document metadata management
- File preview and organization
- Secure document storage
- Ask natural language questions about document content
- Get intelligent, context-aware responses
- Conversation history tracking
- Real-time answer generation
- Responsive Design: Works on desktop, tablet, and mobile
- Loading States: Smooth loading indicators
- Error Handling: User-friendly error messages
- Server Status: Cold start notifications with countdown timer
- Accessibility: Screen reader friendly components
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API base URL | http://localhost:8000 |
The application expects the following backend endpoints:
POST /api/auth/login/- User authenticationPOST /api/auth/register/- User registrationPOST /api/auth/refresh/- Token refreshGET /api/documents/- List user documentsPOST /api/documents/- Upload new documentGET /api/documents/{id}/- Get document detailsDELETE /api/documents/{id}/- Delete documentPOST /api/documents/{id}/ask/- Ask question about document
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard:
- Add
NEXT_PUBLIC_API_URLwith your backend URL
- Add
- Deploy automatically on push to main branch
Note: The project includes a vercel.json configuration file to ensure proper deployment.
npm run build
npm startnpm run dev- Start development servernpm run build- Create production buildnpm run start- Start production servernpm run lint- Run ESLint
- Uses ESLint for code quality
- Follows Next.js best practices
- Component-based architecture
- Tailwind CSS for styling
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Nakul Jaglan
- GitHub: @Nakul-Jaglan
- Portfolio: Resume
- Built with Next.js
- Styled with Tailwind CSS
- AI capabilities powered by Gemini API
- Icons from Heroicons
For questions or support, please open an issue on GitHub or contact the author.