DoubtSetu is a MERN + Gemini AI study assistant. It supports sessions, document upload, AI chat, summaries, quick quizzes, exam panic mode, learning paths, AI teacher mode, memory heatmaps, retention suggestions, and confusion detection.
- Frontend: React + Vite
- Backend: Node.js + Express
- Database: MongoDB + Mongoose
- AI: Gemini API
- Auth: JWT
- Uploads: Multer with PDF/DOCX/TXT parsing
DoubtSetu/
client/ React frontend
server/ Express API
README.md
package.json
- Node.js 18+
- MongoDB Atlas or local MongoDB
- Gemini API key from Google AI Studio
- Install dependencies:
npm run install:all- Create backend environment file:
cp server/.env.example server/.envThen edit server/.env:
PORT=5001
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_long_random_jwt_secret
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.5-flash-lite
GEMINI_ALLOW_FALLBACK=false
CLIENT_URL=http://localhost:5173,http://127.0.0.1:5173- Create frontend environment file:
cp client/.env.example client/.envThen edit client/.env if needed:
VITE_API_URL=http://localhost:5001/api- Run the full project:
npm run devFrontend runs on http://localhost:5173.
Backend runs on http://localhost:5001.
- Register or log in.
- Create a new study session.
- Upload PDF, DOCX, or TXT notes.
- Ask doubts in chat.
- Use Quick Quiz, Exam Panic Mode, Learning Path, AI Teacher Mode, AI Suggestions, Memory Heatmap, and Confusion Detection from each session.
Open the backend terminal and check whether it printed:
DoubtSetu API running on http://localhost:5001
If you see a MongoDB error such as querySrv ECONNREFUSED or ENOTFOUND, the server crashed before opening port 5001. Fix one of these:
- Make sure
server/.envhas a validMONGO_URI. - If using MongoDB Atlas, add your current IP address in Atlas Network Access.
- If using Atlas temporarily for development, allow
0.0.0.0/0. - If using local MongoDB, start MongoDB and use
mongodb://127.0.0.1:27017/doubtsetu.
After fixing MongoDB, restart:
npm run serverThen test:
curl http://localhost:5001/api/healthYou should get:
{"status":"ok","app":"DoubtSetu API"}If the server logs show:
429 Too Many Requests
Quota exceeded
limit: 0
the API key or Google Cloud project currently has no usable quota for that model. Code cannot bypass that quota. Enable Gemini quota/billing in Google AI Studio, create a new API key in a project with available quota, or change GEMINI_MODEL to a model available to your key.
If the server logs show:
model is not found
update server/.env:
GEMINI_MODEL=gemini-2.5-flash-liteDoubtSetu now reports Gemini quota/model errors clearly instead of silently returning demo/static answers. Set GEMINI_ALLOW_FALLBACK=true only when you intentionally want demo answers during setup.
The backend uses Gemini when GEMINI_API_KEY is present. GEMINI_MODEL defaults to gemini-2.5-flash-lite, and you can change it if your API key supports a different model. Set GEMINI_ALLOW_FALLBACK=true only if you want DoubtSetu to show demo fallback answers when Gemini is unavailable.
Important endpoints:
POST /api/auth/registerPOST /api/auth/loginGET /api/sessionsPOST /api/sessionsGET /api/sessions/:idPOST /api/sessions/:id/uploadPOST /api/sessions/:id/chatPOST /api/sessions/:id/quizPOST /api/sessions/:id/exam-panicPOST /api/sessions/:id/learning-pathPOST /api/sessions/:id/teacherPOST /api/sessions/:id/actionGET /api/sessions/:id/insights
npm run build
npm startFor production, set strong secrets, restrict CORS, and store uploaded files in cloud storage instead of local disk.