How ashankgupta/peertopeerai works
Purpose and Entry Points
Student onboarding platform for authentication, profile/interest capture, course recommendations, and cluster-based peer grouping. It is a React/Vite single-page client backed by an Express/MongoDB API.
• Client bootstrap and root UI: frontend/src/main.jsx, frontend/src/App.jsx
• Server bootstrap: backend/app.js
• Database connection boundary: backend/config/ConnectDb.js
Frontend Application
The frontend provides distinct user and administrator flows. React screens likely own page-level state and invoke backend APIs rather than relying on a separate frontend service layer.
• Authentication and registration: frontend/src/login.jsx, frontend/src/register.jsx, frontend/src/AdminLogin.jsx
• Student workspace/profile flow: frontend/src/Dashboard.jsx, frontend/src/EditProfile.jsx, frontend/src/AddInterest.jsx
• Recommendation and visibility screens: frontend/src/ChooseCourses.jsx, frontend/src/ViewUser.jsx
• Admin operational UI: frontend/src/AdminDashboard.jsx
HTTP API and Routing Boundary
Express routes partition the API by domain and delegate request handling to controllers. backend/app.js is the composition point for middleware, database initialization, and route mounting.
• User identity/profile API: backend/routes/User.routes.js, backend/controllers/User.controller.js
• Administrative API: backend/routes/Admin.routes.js, backend/controllers/Admin.controller.js
• Course and interest APIs: backend/routes/Course.routes.js, backend/routes/Interest.routes.js
• Peer-group API: backend/routes/PeerGroup.routes.js, backend/controllers/PeerGroup.controller.js
Domain Persistence
MongoDB is the system of record, accessed through model definitions. The core persisted entities align with the application’s onboarding, recommendation, and grouping workflow.
• Student/user records: backend/models/User.js
• Administrator records: backend/models/Admin.js
• Course catalog and user-interest data: backend/models/Course.js, backend/models/Interest.js
• Cluster/group assignments: backend/models/PeerGroup.models.js
Recommendation and Peer-Grouping Pipeline
Users register and maintain profiles, select interests, and request courses. User attributes and interests can feed clustering; resulting assignments support peer pairing/group views. Course selection and grouping remain separate API domains but are coupled through user data.
• Clustering computation: backend/utils/Calculate_Cluster.js
• Cluster reference artifacts: backend/utils/centroids.json, backend/utils/cluster_label_map.json
• Group orchestration endpoint/controller: backend/routes/PeerGroup.routes.js, backend/controllers/PeerGroup.controller.js
Authentication and Error Contract
Authentication is custom API-based, with route protection centralized in middleware. Controllers should use shared response/error wrappers to keep client-facing API behavior consistent.
• Authentication gate: backend/utils/isauthenticated.js
• Structured API errors/responses: backend/utils/ApiError.js, backend/utils/ApiResponse.js
• Identity handlers: backend/controllers/User.controller.js, backend/controllers/Admin.controller.js
Runtime and External Dependencies
The client runs as a Vite-served React application; the backend runs on Node.js/Express. MongoDB is the material external infrastructure dependency. K-Means logic is implemented or invoked from backend utilities; the README’s LLM chatbot/OpenAI/Cloudflare plans are future-facing and are not represented in the repository tree.
Main entry points: app.js Express server · App.jsx Root application · PeerGroup.controller.js Peer-group controller · Calculate_Cluster.js Clustering engine
Components 22
React client
- Client bootstrap
frontend/src/main.jsx - Root application
frontend/src/App.jsx - Authentication UI · Student registration/login and administrator login.
frontend/src/login.jsx - Student workspace · Profile, interests, recommendations, and user visibility.
frontend/src/Dashboard.jsx - Admin operations UI
frontend/src/AdminDashboard.jsx
Express API
- Express server · Composes middleware, database initialization, and API routes.
backend/app.js - User API routes
backend/routes/User.routes.js - Admin API routes
backend/routes/Admin.routes.js - Course & interest routes
backend/routes/Course.routes.js - Peer-group routes
backend/routes/PeerGroup.routes.js - Authentication gate
backend/utils/isauthenticated.js - API response contract · Standardizes client-facing success responses and errors.
backend/utils/ApiResponse.js
Domain logic
- User controller · Handles identity and profile operations.
backend/controllers/User.controller.js - Admin controller
backend/controllers/Admin.controller.js - Peer-group controller · Orchestrates group assignment and views.
backend/controllers/PeerGroup.controller.js - Clustering engine · Computes peer clusters from user attributes and interests.
backend/utils/Calculate_Cluster.js - Cluster reference data · Centroids and cluster-label mappings.
backend/utils/centroids.json
Persistence
- User & admin models · Persisted student and administrator identities.
backend/models/User.js - Course & interest models · Course catalog and selected interests.
backend/models/Course.js - Peer-group model · Stores cluster/group assignments.
backend/models/PeerGroup.models.js - MongoDB connection
backend/config/ConnectDb.js - MongoDB · System of record.
Connections 31
- Client bootstrap → Root application: renders
- Root application → Authentication UI: hosts
- Root application → Student workspace: hosts
- Root application → Admin operations UI: hosts
- Authentication UI → Express server: API requests
- Student workspace → Express server: API requests
- Admin operations UI → Express server: API requests
- Express server → User API routes: mounts
- Express server → Admin API routes: mounts
- Express server → Course & interest routes: mounts
- Express server → Peer-group routes: mounts
- Express server → Authentication gate: applies protection
- User API routes → User controller: delegates
- Admin API routes → Admin controller: delegates
- Peer-group routes → Peer-group controller: delegates
- User controller → User & admin models: reads/writes
- Admin controller → User & admin models: reads/writes
- Course & interest routes → Course & interest models: accesses
- Peer-group controller → Clustering engine: runs
- Clustering engine → Cluster reference data: uses
- Clustering engine → User & admin models: uses profiles
- Clustering engine → Course & interest models: uses interests
- Peer-group controller → Peer-group model: stores assignments
- User controller → API response contract: formats
- Admin controller → API response contract: formats
- Peer-group controller → API response contract: formats
- Express server → MongoDB connection: initializes
- MongoDB connection → MongoDB: connects
- User & admin models → MongoDB: persists
- Course & interest models → MongoDB: persists
- Peer-group model → MongoDB: persists