How pranav1632/alumhub works
1. Overall shape
AlumHub is a two-tier application: a React/Vite frontend in alumni-frontend and an Express/Mongoose backend in alumni-backend. The frontend is a routed single-page app; the backend is a REST API with a Socket.IO realtime layer.
2. Frontend boundary
The frontend is organized around route pages in src/pages, shared UI in src/components, and application-wide auth state in src/context/AuthContext.jsx. ProtectedRoute and the dashboard pages enforce role-based navigation for student, alumni, and admin users.
3. API access pattern
Client-server communication goes through src/utils/axiosInstance.js, which centralizes API calls and likely attaches auth tokens. This keeps page components thin and makes the backend appear as a set of domain APIs rather than direct model access.
4. Backend request pipeline
Incoming HTTP traffic enters server.js, passes through security and auth middleware, and is dispatched by route modules to controllers. The key boundaries are routes/ -> controllers/ -> models/, with middleware handling authentication, authorization, and error normalization.
5. Domain data model
MongoDB/Mongoose is the system of record. The main collections are centered on users and role-specific profiles (User, StudentProfile, AlumniProfile), plus interaction objects such as MentorshipRequest, ChatRequest, Message, Discussion, Event, Notification, and Feedback.
6. Identity, signup, and verification flow
Authentication is handled by authController and authRoutes, with JWT-backed sessions and a verification/approval process before users fully participate. The readme and utility files indicate email-based OTP or verification code flows, plus document uploads for signup verification through Cloudinary unsigned uploads on the frontend.
7. Role-based access and college isolation
Authorization is enforced with middleware/authMiddleware.js and related verification flags. The architecture is intentionally multi-tenant at the college level: collegeId scopes access so directories, chats, events, and admin actions remain isolated to a specific institution.
8. Realtime chat subsystem
Private messaging is split between REST endpoints (chatRoutes, chatController) and a Socket.IO service in socket/chatSocket.js. The backend also has chat request permissions and read/delivery-state support, so the realtime channel is not just transport—it is part of the authorization and message state model.
9. Community, mentorship, events, and notifications
Core engagement features are separated into their own modules: discussions/replies/likes, mentorship request lifecycle, event CRUD, and notifications. These modules are connected by shared user identity and notification creation, so actions in one domain often emit records into another.
10. Admin and dashboard layer
Admin functionality is isolated in adminController and adminRoutes, covering verification, moderation, and feedback handling. Dashboard endpoints aggregate metrics for student, alumni, and college views, which the frontend consumes via dedicated dashboard pages.
11. Supporting services
External services matter here: Nodemailer/SMTP supports account verification and email delivery, while Cloudinary is used for document and profile image uploads. CORS allowlisting and rate limiting are part of the API perimeter, reflecting an internet-facing app with multiple deployed origins.
12. Deployment/runtime split
The frontend is built with Vite and configured for browser deployment, including Vercel support. The backend is a Node.js runtime service deployed separately, with environment-driven configuration for MongoDB, JWT, mail, and allowed client origins.
13. Non-core artifacts
The repo also includes Postman testing docs and project/report documents, which support validation and documentation but are not runtime parts of the architecture. A local btm.db file appears present, but the primary database architecture described by the codebase is MongoDB.
Main entry points: pages Pages · server.js Server · controllers Controllers · axiosInstance.js API client
Components 19
Frontend
React/Vite single-page app with routed pages, shared UI, and auth state.
- App shell · Top-level client app wiring routing and layout.
alumni-frontend/src/App.jsx - Pages · Primary routed screens for login, profile, chat, directory, discussions, events, mentorship, and dashboards.
alumni-frontend/src/pages - Shared UI · Reusable interface components such as header, footer, chat widget, notifications, and protected routing.
alumni-frontend/src/components - Auth state · Application-wide authentication and user state.
alumni-frontend/src/context/AuthContext.jsx - API client · Centralized HTTP client used by the frontend to call backend APIs.
alumni-frontend/src/utils/axiosInstance.js - Dashboards · Student, alumni, and college dashboard pages built on role-aware navigation.
alumni-frontend/src/pages/dashboards
Backend
Express/Mongoose API with controllers, middleware, models, and realtime chat.
- Server · HTTP entrypoint that boots the API, middleware, routes, and Socket.IO.
alumni-backend/server.js - Auth middleware · JWT, role, and verification enforcement for protected routes.
alumni-backend/middleware/authMiddleware.js - Error middleware · Central error normalization and response handling.
alumni-backend/middleware/errorMiddleware.js - Routes · REST endpoint grouping for auth, users, admin, chat, dashboards, discussions, events, feedback, mentorship, alumni, and notifications.
alumni-backend/routes - Controllers · Domain controllers that implement API behavior across identity, community, chat, events, and admin flows.
alumni-backend/controllers - Models · MongoDB collections for users, profiles, messaging, engagement, and feedback.
alumni-backend/models - Chat socket · Socket.IO realtime channel for private messaging and delivery state.
alumni-backend/socket/chatSocket.js - Domain utils · Support functions for chat permissions, notifications, verification, profiles, and email sending.
alumni-backend/utils
External services
Email, file storage, database, and deployment/runtime dependencies.
- MongoDB · Primary system of record for users, profiles, chats, events, notifications, and community content.
- Email service · Outbound email delivery for verification and account communication.
- Cloudinary · External document and image upload storage used during signup and profile flows.
- Deploy targets · Separate browser deployment for the frontend and Node.js deployment for the backend.
alumni-frontend/vercel.json - Docs · Testing and project documentation supporting the application but not part of runtime architecture.
README.md
Connections 19
- App shell → Pages: renders · The app shell mounts routed pages and views.
- App shell → Shared UI: uses · The app shell composes shared UI and layout components.
- Pages → Auth state: reads auth · Pages and dashboards rely on shared auth state for user identity and role.
- Shared UI → Auth state: guards UI · ProtectedRoute and related components enforce client-side access patterns.
- Pages → API client: calls API · Route pages fetch and mutate data through the centralized axios client.
- Dashboards → API client: loads metrics · Dashboard views request role-specific aggregate data from the backend.
- API client → Server: HTTP · Client-server communication enters the backend via REST endpoints.
- Server → Auth middleware: passes through · Incoming requests are filtered by authentication and authorization middleware.
- Server → Routes: dispatches to · The server forwards requests to route modules.
- Routes → Controllers: invokes · Routes delegate business logic to controllers.
- Controllers → Models: persists via · Controllers read and write MongoDB collections through Mongoose models.
- Controllers → Domain utils: uses · Controllers rely on helpers for verification, notifications, mail, and profile logic.
- Controllers → Chat socket: emits realtime · Chat operations coordinate with the Socket.IO messaging layer.
- Chat socket → Models: reads/writes · Realtime messaging state is backed by chat and message documents.
- Domain utils → Email service: sends email · Verification and account flows use outbound email delivery.
- Pages → Cloudinary: uploads docs · Signup and profile flows include cloud-hosted uploads.
- Models → MongoDB: stores data · The Mongoose models persist the application data model in MongoDB.
- Server → Deploy targets: deploys on · Frontend and backend are deployed as separate runtime targets.
- Docs → Routes: describes · Repository documentation and testing notes explain the API surface.