How achintya1205/ai-study-planner works
1. The repository is a split full-stack application with two runtimes: a React 19 frontend in study-planner-frontend and an Express/Node.js backend in backend. The frontend is the presentation layer; the backend owns all business rules, persistence, authentication, and AI orchestration.
2. The frontend is a Vite app organized around route-level pages: Dashboard, Subjects, Topics, Tests, StudySession, Studyplan, Analytics, and Auth. Shared UI is minimal and centralized in components/navbar.jsx, with global styling through Tailwind, App.css, and index.css.
3. Frontend data access is isolated in src/api. axios.js configures the HTTP client, while auth.api.js and study.api.js wrap calls to backend REST endpoints. This keeps page components focused on rendering and state, not request construction.
4. The backend entrypoint is server.js, which wires Express, database connection, routes, and middleware. config/db.js handles the MongoDB Atlas connection, making MongoDB the system of record for all user academic data.
5. Authentication is JWT-based. routes/auth.js handles register/login, and middleware/auth.js protects private routes by verifying the token and binding requests to the authenticated user. This creates a strict per-user data boundary across subjects, topics, tests, and sessions.
6. The data model is centered on five Mongoose collections: User, Subject, Topic, Test, and StudySession. Subjects own topics; tests can belong either to a topic or directly to a subject; study sessions are tracked separately as productivity records.
7. The backend is organized by domain routes rather than by UI page. routes/subjects.js, topics.js, tests.js, and sessions.js expose CRUD-style endpoints for the study workflow, while routes/ai.js exposes AI-generated analysis and planning endpoints. This is the main API surface consumed by the frontend.
8. A key architectural detail is the automatic progress synchronization layer in backend/utils. updateTopicScore.js and updateSubjectProgress.js are shared business-logic helpers that recalculate mastery after new tests or changes in related records, avoiding duplicated scoring logic inside route handlers.
9. The scoring model is not manual; it is derived from assessment history. Topic mastery is updated from recent tests, subject mastery aggregates topic and subject-level exams, and the system supports whole-subject tests without forcing them into a topic. This is what drives dashboard stats, analytics, and weak-area detection.
10. The AI subsystem is backend-orchestrated and data-driven. routes/ai.js collects the authenticated user’s subjects, topics, tests, and study sessions, builds a contextual prompt, and sends it to Google Gemini. The frontend only requests analysis or study plans and renders the returned text or plan output.
11. The main data flow is: user action in React → Axios API call → Express route → MongoDB read/write and/or utility recalculation → optional Gemini call for AI features → response back to the React page. Most pages therefore behave as thin clients over a centralized backend.
12. Deployment is intentionally separated: the frontend is configured for Vercel (vercel.json), while the backend is designed for a Node hosting platform such as Render, with MongoDB Atlas and Gemini as external services. The architecture is a classic MERN-style split, but with added AI and automated progress-synchronization subsystems.
Main entry points: server.js Server · subjects.js Study routes · ai.js AI routes · App.jsx App shell
Components 16
Frontend
React/Vite presentation layer and API client
- App shell · Top-level frontend composition and routing entry.
study-planner-frontend/src/App.jsx - Pages · Dashboard, subjects, topics, tests, sessions, planning, analytics, and auth screens.
study-planner-frontend/src/pages - API layer · Centralized HTTP client and request helpers for backend calls.
study-planner-frontend/src/api - Navbar · Shared navigation component used across the app.
study-planner-frontend/src/components/navbar.jsx - Styling · Tailwind and global CSS for app-wide presentation.
study-planner-frontend/src/index.css
Backend
Express API, domain logic, persistence, and AI orchestration
- Server · Bootstraps the API server, middleware, routes, and database connection.
backend/server.js - Auth routes · Register and login endpoints that issue and verify tokens.
backend/routes/auth.js - Study routes · Core REST endpoints for subjects, topics, tests, and sessions.
backend/routes/subjects.js - AI routes · Builds context from user data and returns analysis or study plans.
backend/routes/ai.js - Auth guard · Verifies tokens and binds requests to the authenticated user.
backend/middleware/auth.js - Mongo connect · MongoDB Atlas connection setup.
backend/config/db.js - Data model · User, Subject, Topic, Test, and StudySession collections.
backend/models - Progress sync · Shared recalculation logic for topic score and subject progress.
backend/utils
External Services
Hosted services used by the application
- MongoDB Atlas · System of record for user academic data.
- Gemini · Generates analysis and planning outputs from user context.
- Vercel · Frontend deployment target.
Connections 19
- App shell → Pages: renders · App composes the route-level pages.
- App shell → Navbar: shares UI · Common navigation is used across pages.
- App shell → Styling: styles with · Global styling is applied at app level.
- Pages → API layer: fetches via · Pages delegate backend communication to API wrappers.
- API layer → Server: calls · HTTP requests go to the Express backend.
- Server → Mongo connect: connects · Server initializes the Mongo connection.
- Server → Auth routes: mounts · Auth routes are exposed by the server.
- Server → Study routes: mounts · Study workflow routes are exposed by the server.
- Server → AI routes: mounts · AI endpoints are exposed by the server.
- Auth routes → Data model: uses · Auth flow reads and writes user data.
- Study routes → Auth guard: protects with · Private study endpoints require authentication.
- Study routes → Data model: persists · Study CRUD operates on the Mongoose collections.
- Study routes → Progress sync: recalculates · Progress and mastery are synchronized after changes.
- AI routes → Auth guard: protects with · AI requests are scoped to the authenticated user.
- AI routes → Data model: reads · AI context is built from stored academic data.
- AI routes → Gemini: invokes · Prompts are sent to Gemini for analysis and planning.
- Mongo connect → MongoDB Atlas: connects to · MongoDB Atlas is the backing datastore.
- Study routes → AI routes: feeds context · Shared user data powers both study tracking and AI features.
- App shell → Vercel: deploys to · Frontend is configured for Vercel hosting.