A full-stack application for document-based Q&A, built with Node.js (Express, MongoDB) for the backend and Vite + React for the frontend.
- User registration and login (student, faculty, admin roles)
- JWT-based authentication and protected routes
- Role-based access control (backend-ready, UI coming soon)
- Upload PDF documents with metadata (faculty and students)
- View list of documents and document details
- Public/private document visibility (faculty uploads are public by default)
- Secure file storage and access
- Chat with AI about uploaded documents
- View chat history (previous Q&A)
- All frontend features communicate with the backend via RESTful API endpoints
- Authentication:
- Secure JWT-based authentication for all protected routes
- Passwords are hashed using bcrypt before storage
- Role-Based Access:
- User roles: student, faculty, admin
- Backend checks user roles for sensitive actions (e.g., uploading documents)
- Error Handling:
- Consistent error responses for failed operations
- User-friendly error messages for common issues (e.g., invalid PDF, unauthorized access)
- File Security:
- Only authenticated users can upload or access documents
- Uploaded files are validated (PDF only, size limits)
- Environment Variables:
- Sensitive configuration (JWT secret, DB URI) is stored in environment variables
| Method | Endpoint | Description | Required Fields |
|---|---|---|---|
| POST | /api/auth/register | Register a new user | username, email, password, full_name, role |
| POST | /api/auth/login | Login user | username, password |
| GET | /api/auth/me | Get current user | (JWT token in Authorization header) |
| Method | Endpoint | Description | Required Fields / Notes |
|---|---|---|---|
| POST | /api/files/upload | Upload a PDF document | file (PDF), title, description, subject, course_code, is_public (form-data, JWT required) |
| GET | /api/files/ | List documents | JWT required |
| GET | /api/files/:id | Get document details | JWT required, :id = document ID |
| Method | Endpoint | Description | Required Fields / Notes |
|---|---|---|---|
| POST | /api/chat/ask | Ask a question to the AI | question (string), document_ids (optional, array), JWT required |
| GET | /api/chat/history | Get chat history | JWT required |
- Role-based UI and permissions (e.g., only faculty can upload, students can only view)
- Enhanced document visibility controls (public/private toggle)
- Improved UI/UX and error handling (UI enhancements, loading states, notifications)
- Admin dashboard and management tools
- Code refactoring and performance improvements
- More granular permissions and audit logging
- Node.js (v20.19.0 or higher recommended)
- MongoDB (local or cloud instance)
cd backend- Install dependencies:
npm install
- Configure your environment variables (see
env_example.txt). - Start the backend server:
node server.js # or, for auto-reload: npx nodemon server.js - Backend runs by default on http://localhost:5000
cd frontend- Install dependencies:
npm install
- Ensure
vite.config.jsproxies/apito your backend (default:http://localhost:5000). - Start the frontend dev server:
npm run dev
- Frontend runs by default on http://localhost:5173
- Register as a student or faculty (faculty can upload documents, students can view public documents).
- Upload and view documents.
- Chat with the AI about your documents.
- View your chat history.
- Make sure both backend and frontend servers are running for full functionality.
- For future role-based features and UI/UX improvements, see the "Planned Features" section above.
- For any issues, check backend and frontend logs for error messages.
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - NoSQL database
- JWT - Authentication
- Multer - File upload handling
- pdf-parse - PDF text extraction
- Groq API - High-performance AI inference
- RAG Pipeline - Retrieval-Augmented Generation
- Text Chunking - Intelligent document processing
- Similarity Search - Keyword-based content retrieval
- Node.js (v16 or higher)
- MongoDB (v4.4 or higher)
- Groq API key
-
Clone the repository
git clone https://github.com/ayushh8/AI-doubt-solver.git cd AI-doubt-solver -
Install dependencies
cd backend npm install -
Set up environment variables Create a
.envfile in thebackenddirectory:PORT=5000 MONGODB_URI=mongodb://localhost:27017/doubt_solver JWT_SECRET=your_jwt_secret_here GROQ_API_KEY=your_groq_api_key_here
-
Start MongoDB
# On Windows mongod --dbpath C:\data\db # On macOS/Linux sudo systemctl start mongod
-
Start the server
npm start
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/profile- Get user profile
POST /api/files/upload- Upload PDF documentGET /api/files/- List user's documentsGET /api/files/:id- Get specific documentDELETE /api/files/:id- Delete documentPOST /api/files/:id/reprocess- Reprocess document
POST /api/chat/ask- Ask a questionGET /api/chat/history- Get chat historyGET /api/chat/health- Check AI service healthGET /api/chat/debug- Debug AI memory
Visit http://localhost:5000/test.html for an interactive testing interface.
backend/
βββ models/ # Database models
βββ routes/ # API routes
βββ services/ # Business logic
βββ middleware/ # Custom middleware
βββ uploads/ # File storage
βββ server.js # Main server file
βββ package.json # Dependencies
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 5000 |
MONGODB_URI |
MongoDB connection string | mongodb://localhost:27017/doubt_solver |
JWT_SECRET |
JWT signing secret | Required |
GROQ_API_KEY |
Groq API key | Required |
- Maximum file size: 50MB
- Supported formats: PDF only
- Processing limit: 10MB for text extraction
npm run devnpm start- Set up MongoDB Atlas or local MongoDB
- Get Groq API key from Groq Console
- Configure environment variables
- Deploy to your preferred platform
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- Groq for high-performance AI inference
- MongoDB for database
- Express.js for web framework
- pdf-parse for PDF processing
If you have any questions or need help, please open an issue on GitHub.
Made with β€οΈ for students everywhere!