This document outlines the recent structural changes made to the mind-mentor codebase to improve maintainability, separation of concerns, and alignment with modern architecture standards.
Note: No functionality was altered during this refactor. These changes are strictly organizational.
To prevent the src/components/ root directory from becoming cluttered, components have been grouped into feature-specific and domain-specific subdirectories:
- Layout:
Header.tsxandFooter.tsxmoved tosrc/components/layout/. - Marketing/Sections:
ReviewMarquee.tsx,SocialWall.tsx, andVideo.tsxmoved tosrc/components/sections/. - Study Plan:
StudyPlanDisplay.tsxandStudyPlanForm.tsxmoved tosrc/components/study-plan/. - Resources:
CurateResourcesForm.tsxandResourceCurator.tsxmoved tosrc/components/resources/. - PDF & Chat:
ChatInterface.tsx,PdfChat.tsx, andPdfViewer.tsxmoved tosrc/components/pdf/. - Providers:
PostHogPageView.tsxandposthog-provider.tsxmoved tosrc/providers/. - Data: Static data exports (
data.tsx) moved and renamed tosrc/lib/data.ts.
All associated imports across the app/ and components/ directories have been updated to reflect these new paths.
To maintain a cohesive and intuitive API namespace:
- The
src/app/api/users/statsendpoint was moved tosrc/app/api/user/stats. - This ensures all user-related endpoints live under the unified
/api/user/*namespace, avoiding confusion between/userand/users.
The Node.js Express server (/server) was transitioned to a strictly enforced Layered Architecture pattern (Routes -> Controllers -> Services -> Repositories -> Models), perfectly matching the architectural standard used in enterprise projects like netwin-pms.
- Repositories Added: A new
server/repositories/directory was created to handle all database interactions. Controllers and Services no longer touch Mongoose Models directly. Instead, they rely on Repositories likestudyPlanRepository.jsto execute queries. - Services Added: Core business logic and AI orchestration were extracted into a unified
server/services/layer (e.g.,studyPlanService.js,curatedResourceService.js,pdfDocumentService.js). - Thinned Controllers: Controllers (
generatePlanController.js,curateResourcesController.js,pdfChatController.js) were refactored to serve exclusively as HTTP interfaces. They now solely extract request parameters, call the corresponding Service methods, and return JSON responses. - Clean Routes: The files in
server/routes/remain completely pure, strictly defining API endpoint paths and mapping them to Controller functions.
Previously, the pre-trained machine learning weights downloaded by the Transformers.js library were cached inside the server/models/Xenova directory.
- Separation of Concerns: To prevent confusion between Mongoose database schemas and AI model weights, the Transformers cache directory was moved.
- New Location: AI models are now cached in a dedicated
server/ai-models/directory. - The configuration in
server/services/transformersEmbeddings.jswas updated (env.cacheDir = './ai-models') to reflect this change.