How arpitkatiyyar/intellistudy_ai works
1. High-level shape
IntelliStudy AI is a two-tier application: a React single-page frontend and an Express/Node backend API. The frontend is responsible for the user experience and stateful study UI, while the backend owns authentication, study generation, persistence, file processing, caching, and AI integration.
2. Frontend boundary
The frontend is organized around pages, reusable components, layouts, and context/services.
- pages/ holds route-level screens such as Dashboard, Study, Login, Register, Profile, History, and SessionDetails.
- components/ contains UI widgets like the flashcard player, sidebar, navbar, and question input.
- context/AuthContext.jsx indicates client-side auth state management.
- services/api.js is the API boundary from the browser to the backend.
3. Backend entry and API composition
The backend is structured as a classic Express application with a central app bootstrap and route modules.
- server.js is the process entry point.
- src/app.js likely wires middleware, routes, and shared error handling.
- Route modules split the API by domain: auth, dashboard, study, flashcard, test, analytics, and upload.
4. Request processing pipeline
Incoming requests pass through middleware before reaching controllers. The backend has explicit boundaries for:
- auth.middleware.js for protected routes and JWT verification
- rateLimit.middleware.js for request throttling
- validate.middleware.js for payload validation against schemas
This suggests a layered API where controllers stay thin and domain logic is pushed into services.
5. Authentication and session security
Auth is not just login/logout; it includes registration, OTP verification, JWT access tokens, refresh tokens, and HTTP-only cookies.
- Passwords are hashed with bcrypt.
- Refresh-token support is persisted in the database, which is reflected by the Prisma migrations.
- Redis is used for temporary authentication data such as OTPs or short-lived state.
This makes auth a distinct subsystem with both database-backed and cache-backed parts.
6. Study generation and AI orchestration
The core product feature is a study-content generation pipeline. The backend’s study-related controllers/services turn either a topic/question or extracted document text into:
- summaries
- flashcards
- multiple-choice quizzes
- analytics-friendly study data
Prompt construction and response parsing are separated into utility/service modules, which suggests the AI layer is treated as an external dependency rather than embedded business logic.
7. LLM integration boundaries
The repository supports multiple AI backends: Ollama/Llama 3 and Google Gemini.
- gemini.service.js and aiService.service.js imply an abstraction over model providers.
- promptBuilder.js and extractJSON.js indicate the app expects structured model output and normalizes it before persisting or returning it.
This abstraction is important in the diagram: the app’s AI layer sits behind a service boundary, not directly inside controllers.
8. Document upload and text extraction flow
Uploaded study materials are handled separately from plain question input.
- upload.controller.js and config/multer.js manage file ingress.
- utils/pdfExtractor.js, utils/documentExtractor.js, and the README’s support for PDF/DOCX/TXT show a text-extraction pipeline.
- The uploads/ directory is a local filesystem staging area.
After extraction, the text is fed into the same AI generation flow as manual prompts.
9. Persistence layer and domain model
Prisma is the ORM boundary between the backend and MySQL.
- prisma/schema.prisma and multiple migrations show the database is actively used for app state, not just auth.
- Migration names reveal key entities/features such as flashcard progress, cascade deletes, and refresh tokens.
This suggests persisted study sessions, user-linked flashcards, token records, and progress tracking are central to the data model.
10. Learning features as separate backend domains
The backend splits the learning experience into functional subsystems:
- Flashcards: review, known/difficult marking, progress tracking
- Tests/Quizzes: MCQ generation and answer checking
- Study sessions: creation, history, and session detail retrieval
- Analytics: mastery percentage, weak-topic detection, and aggregate stats
- Dashboard: summary metrics for the user’s study activity
These are distinct API domains, even though they share the same user/session data.
11. Redis as a performance and ephemeral-state layer
Redis is used for more than generic caching. The README and config layout imply it supports:
- document analysis cache
- OTP storage
- temporary authentication/session data
- faster repeat AI requests
In the architecture diagram, Redis should be shown as an auxiliary store alongside MySQL, not as the primary system of record.
12. What to show as the main boundaries
For an architecture diagram, the most important boundaries are:
- Browser / React UI
- Express API layer
- Middleware/security gate
- AI orchestration layer
- File extraction pipeline
- Prisma/MySQL persistence
- Redis ephemeral cache
- External/local model providers (Ollama, Gemini)
- Local uploads storage
The main data flows are: user input or uploaded document → backend validation/auth → text extraction or prompt building → AI generation → structured response → persistence → analytics/history returned to the frontend.
Main entry points: routes API Routes · schema.prisma Data Layer · study.controller.js Study Domain · App.jsx React App
Components 22
Frontend
React SPA for study workflows and user-facing state
- React App · Client entry and route shell
frontend/src/App.jsx - Pages · Dashboard, study, auth, profile, history, session views
frontend/src/pages - UI Components · Navbar, sidebar, flashcards, question input
frontend/src/components - Auth State · Client-side authentication state and session flow
frontend/src/context/AuthContext.jsx - API Client · Browser boundary to backend endpoints
frontend/src/services/api.js
Backend
Express API, services, persistence, and processing pipeline
- Server · Node process bootstrap
backend/server.js - Express App · Middleware and route composition
backend/src/app.js - Middleware · Auth, rate limiting, and validation
backend/src/middleware - API Routes · Domain route modules for auth, study, flashcards, tests, analytics, upload, dashboard
backend/src/routes - Auth Domain · Registration, OTP, JWT, refresh tokens, email verification
backend/src/controllers/auth.controller.js - Study Domain · Study generation and session orchestration
backend/src/controllers/study.controller.js - Flashcards · Review, progress, and card updates
backend/src/controllers/flashcard.controller.js - Tests · Quiz generation and answer checking
backend/src/controllers/test.controller.js - Analytics · Mastery stats, weak topics, and summaries
backend/src/controllers/analytics.controller.js - Upload Flow · File intake and document processing entry
backend/src/controllers/upload.controller.js - AI Orchestrator · Prompting, provider abstraction, and structured output parsing
backend/src/services/aiService.service.js - Text Extractors · PDF and document text extraction plus JSON normalization
backend/src/utils - Data Layer · Prisma schema and MySQL persistence
backend/prisma/schema.prisma - Redis Cache · OTP, temporary auth state, and cached analysis
backend/src/config/redis.js - Uploads Dir · Local storage for uploaded study files
backend/uploads
External
Datastores and model providers used by the app
- LLMs · Ollama/Llama and Google Gemini backends
llm.js - MySQL · Primary system of record
Connections 26
- React App → Pages: routes to · Renders page-level screens
- React App → UI Components: uses · Composes reusable widgets
- React App → Auth State: reads auth · Uses client auth state
- Pages → API Client: calls · Requests backend data and actions
- UI Components → API Client: submits · User actions invoke API requests
- Server → Express App: boots · Starts the Express app
- Express App → Middleware: applies · Runs cross-cutting middleware
- Express App → API Routes: mounts · Registers domain routers
- API Routes → Auth Domain: dispatches · Auth endpoints
- API Routes → Study Domain: dispatches · Study endpoints
- API Routes → Flashcards: dispatches · Flashcard endpoints
- API Routes → Tests: dispatches · Quiz endpoints
- API Routes → Analytics: dispatches · Analytics endpoints
- API Routes → Upload Flow: dispatches · File upload endpoints
- Study Domain → AI Orchestrator: builds prompts · Orchestrates generation flow
- Upload Flow → Text Extractors: extracts text · Converts uploaded files to study text
- AI Orchestrator → LLMs: invokes · Uses provider backends
- Auth Domain → Data Layer: persists · Users, tokens, and auth records
- Study Domain → Data Layer: persists · Sessions, generated content, progress
- Flashcards → Data Layer: updates · Card progress and review state
- Tests → Data Layer: reads/writes · Quiz attempts and results
- Analytics → Data Layer: aggregates · Computes stats from stored study data
- Upload Flow → Uploads Dir: stores files · Writes uploaded documents locally
- Auth Domain → Redis Cache: uses · OTP and temporary auth state
- Study Domain → Redis Cache: caches · Repeat analysis and intermediate results
- Data Layer → MySQL: backed by · Prisma ORM persistence target