How 24wh1a0583/campusconnect works
Purpose and Runtime Topology
CampusConnect is a two-process full-stack campus-opportunity platform: a React/Vite browser client and a Node.js/Express API backed by MongoDB through Mongoose. Users authenticate with JWTs, then create, browse, and delete events, internships, resources, and community posts. Backend entry point: backend/server.js; frontend bootstrap: frontend/src/main.jsx.
Frontend Application Shell
The React application is rooted in frontend/src/App.jsx, with client pages under frontend/src/pages/. It provides navigation and feature-specific screens for authentication, dashboard recommendations, events, internships, resources, and feed content. Shared presentation units map API entities into cards: frontend/src/components/EventCard.jsx, frontend/src/components/InternshipCard.jsx, and frontend/src/components/PostCard.jsx.
API Client Boundary
All browser-to-server communication is centralized in frontend/src/services/api.js, using Axios. This is the primary boundary for API base URL configuration, request dispatch, and likely JWT attachment. UI pages consume this service rather than directly interacting with MongoDB or Express, separating rendering/state concerns from transport concerns.
Express API Composition
backend/server.js initializes Express, database connectivity, and route mounting. Feature route modules define the public API surface and delegate to controllers: backend/routes/authRoutes.js, backend/routes/eventRoutes.js, and backend/routes/internshipRoutes.js; equivalent route/controller pairs exist for posts and resources. Controllers hold request orchestration and domain operations, including create/list/delete behavior.
Authentication and Authorization
Authentication is handled by backend/controllers/authController.js and exposed through backend/routes/authRoutes.js. JWT validation is an explicit middleware boundary in backend/middleware/authMiddleware.js; protected content mutations and owner-only deletion should flow through this middleware before controllers. User identity, credentials, and interests are persisted by backend/models/User.js, enabling login and interest-based dashboard behavior.
Content Domains and Persistence
MongoDB collections are modeled independently for each shareable campus domain: backend/models/Event.js, backend/models/Internship.js, backend/models/Resource.js, and backend/models/Post.js. Corresponding controllers—such as backend/controllers/eventController.js and backend/controllers/resourceController.js—translate HTTP operations into Mongoose reads/writes. Events and internships form a time-sensitive boundary: expired records are filtered from active views.
Primary Flow
1. A visitor registers or logs in through frontend/src/pages/Register.jsx or frontend/src/pages/Login.jsx.
2. The auth API persists/validates User data and returns a JWT.
3. Authenticated frontend pages invoke frontend/src/services/api.js for content retrieval or mutation.
4. Express routes apply JWT middleware where required, then controllers access Mongoose models.
5. Returned entities render in feature pages and reusable cards; frontend/src/pages/Dashboard.jsx aggregates personalized or quick-access content.
Infrastructure and External Dependencies
The backend requires MONGO_URI, JWT_SECRET, and optional PORT environment variables; MongoDB connection setup resides in backend/config/db.js. Development defaults are frontend Vite on port 5173 and Express on port 5001. MongoDB is the persistent external service; JWT is the session/identity mechanism, with no separate cache, queue, file store, or third-party API indicated.
Components 19
React Browser Client
- Vite bootstrap
frontend/src/main.jsx - Application shell
frontend/src/App.jsx - Login and registration
frontend/src/pages/Login.jsx - Dashboard · Aggregates personalized and quick-access content.
frontend/src/pages/Dashboard.jsx - Content pages · Events, internships, resources, and feed screens.
- Entity cards · Reusable event, internship, and post presentation.
frontend/src/components/EventCard.jsx - Axios API client · Centralizes API dispatch and JWT attachment.
frontend/src/services/api.js
Express API
- Express server · Initializes Express, database connectivity, and route mounting.
backend/server.js - Feature routes · Auth and content API surface.
backend/routes/authRoutes.js - JWT middleware · Guards protected mutations and owner-only deletion.
backend/middleware/authMiddleware.js - Auth controller · Registers users, validates credentials, and issues JWTs.
backend/controllers/authController.js - Content controllers · Orchestrate create, list, delete, and active-record filtering.
backend/controllers/eventController.js - Mongo connection
backend/config/db.js
Persistence
- User model · Persists identity, credentials, and interests.
backend/models/User.js - Event model
backend/models/Event.js - Internship model
backend/models/Internship.js - Resource model
backend/models/Resource.js - Post model
backend/models/Post.js - MongoDB · Persistent service configured through MONGO_URI.
Connections 26
- Vite bootstrap → Application shell: mounts
- Application shell → Login and registration: renders
- Application shell → Dashboard: renders
- Application shell → Content pages: renders
- Content pages → Entity cards: uses
- Login and registration → Axios API client: auth requests
- Dashboard → Axios API client: loads content
- Content pages → Axios API client: queries and mutates
- Axios API client → Express server: HTTP API
- Express server → Mongo connection: connects
- Express server → Feature routes: mounts
- Feature routes → JWT middleware: protects mutations
- Feature routes → Auth controller: auth endpoints
- Feature routes → Content controllers: content endpoints
- JWT middleware → Content controllers: authorizes
- Auth controller → User model: reads and writes
- Content controllers → Event model: manages
- Content controllers → Internship model: manages
- Content controllers → Resource model: manages
- Content controllers → Post model: manages
- Mongo connection → MongoDB: MONGO_URI
- User model → MongoDB: persists
- Event model → MongoDB: persists
- Internship model → MongoDB: persists
- Resource model → MongoDB: persists
- Post model → MongoDB: persists