How sinister815/acadex works
Purpose and Runtime Topology
A MERN platform for college students to upload, discover, discuss, bookmark, and report notes/PYQs. The React/Vite client calls a versioned Express API at /api/v1; the Node.js server persists domain data in MongoDB and stores uploaded files through Cloudinary. Primary runtime entry points are client/src/main.jsx, client/src/App.jsx, server/src/server.js, and server/src/app.js.
Client Application Shell and Navigation
The frontend is a React single-page application. Application routing and route protection are centralized in client/src/routes/AppRoutes.jsx and client/src/routes/ProtectedRoute.jsx. Public/authenticated UI boundaries use client/src/layouts/AuthLayout.jsx and client/src/layouts/DashboardLayout.jsx; the dashboard layout composes navigation from client/src/components/layout/Navbar.jsx and client/src/components/layout/Sidebar.jsx.
Client State and API Boundary
Client-server communication is isolated behind Axios configuration and endpoint definitions in client/src/api/axios.js and client/src/api/endpoints.js. Feature-specific service modules encapsulate API operations for notes, authentication, bookmarks, and comments, including client/src/features/notes/notesService.js, client/src/features/auth/authService.js, and client/src/features/comments/commentsService.js. Session and presentation state are held separately in Zustand stores: client/src/store/authStore.js and client/src/store/themeStore.js.
User-Facing Content Flows
Notes are the central resource: list/search, detail, upload, comment, bookmark, and report interactions are represented by client/src/pages/notes/NotesPage.jsx, client/src/pages/notes/NoteDetailPage.jsx, and client/src/pages/notes/UploadPage.jsx. Reusable note UI drives these flows through client/src/components/notes/NoteCard.jsx, client/src/components/notes/CommentsSection.jsx, and client/src/components/notes/ReportNoteModal.jsx. Dedicated pages expose saved content and user/admin functions at client/src/pages/bookmarks/BookmarksPage.jsx, client/src/pages/profile/ProfilePage.jsx, and client/src/pages/admin/AdminPage.jsx.
API Composition and Request Pipeline
Express application setup and API mounting occur in server/src/app.js and server/src/routes/index.js. Resource route modules define the HTTP boundary for auth, notes, comments, bookmarks, users, and administration, such as server/src/routes/note.routes.js, server/src/routes/auth.routes.js, and server/src/routes/admin.routes.js. Requests flow from routes to controllers, then services—for example server/src/controllers/note.controller.js to server/src/services/note.service.js—with validation, authentication, uploads, logging, and error normalization handled by middleware in server/src/middleware/.
Security, Identity, and Moderation
Authentication uses JWT access/refresh-token behavior, with refresh tokens in httpOnly cookies per the README. Token generation, auth business logic, and enforcement are separated across server/src/utils/generateToken.js, server/src/services/auth.service.js, and server/src/middleware/auth.middleware.js. Authorization-sensitive administration and reported-content handling are represented by server/src/controllers/admin.controller.js, server/src/services/admin.service.js, and persistence models server/src/models/Report.model.js and server/src/models/Notification.model.js.
Persistence and File Infrastructure
Mongoose models define the core document relationships for users, notes, comments, and bookmarks in server/src/models/User.model.js, server/src/models/Note.model.js, server/src/models/Comment.model.js, and server/src/models/Bookmark.model.js. MongoDB connectivity is configured in server/src/config/db.js. Upload requests pass through server/src/middleware/upload.middleware.js, then file-storage services and Cloudinary configuration in server/src/services/upload.service.js, server/src/services/cloudinary.service.js, and server/src/config/cloudinary.js.
Main entry points: AppRoutes.jsx Routes & guards · note.service.js Domain services · app.js Express app · auth.middleware.js Request middleware
Components 20
React Client
- Client entry
client/src/main.jsx - App shell
client/src/App.jsx - Routes & guards · Central routes and protected-route enforcement.
client/src/routes/AppRoutes.jsx - App layouts · Auth and dashboard shells compose navigation.
client/src/layouts/DashboardLayout.jsx - Notes flows · Browse, detail, upload, comments, bookmarks, and reports.
client/src/pages/notes/NotesPage.jsx - Account & admin UI
client/src/pages/admin/AdminPage.jsx - Feature services · Notes, auth, and comments operations.
client/src/features/notes/notesService.js - Axios API boundary · Versioned API configuration and endpoint definitions.
client/src/api/axios.js - Auth & theme state
client/src/store/authStore.js
Express API
- Server entry
server/src/server.js - Express app · Configures middleware and mounts the API.
server/src/app.js - API routes · Versioned resource boundary for auth, notes, comments, bookmarks, users, and admin.
server/src/routes/index.js - Controllers · Translate HTTP requests into service calls.
server/src/controllers/note.controller.js - Domain services · Note, auth, and admin workflows.
server/src/services/note.service.js - Request middleware · Authentication, validation, logging, errors, and multipart handling.
server/src/middleware/auth.middleware.js - JWT token handling · Access/refresh token generation and enforcement.
server/src/utils/generateToken.js
Data & Files
- Mongoose models · Users, notes, comments, bookmarks, reports, and notifications.
server/src/models/Note.model.js - MongoDB · Configured through the database connection module.
server/src/config/db.js - Upload pipeline · Uploads files through Cloudinary-backed services.
server/src/services/upload.service.js - Cloudinary
server/src/config/cloudinary.js
Connections 22
- Client entry → App shell
- App shell → Routes & guards
- Routes & guards → App layouts: selects shell
- Routes & guards → Notes flows: renders pages
- Routes & guards → Account & admin UI: renders pages
- App layouts → Auth & theme state: uses session
- Notes flows → Feature services: content actions
- Account & admin UI → Feature services: account actions
- Feature services → Axios API boundary: API calls
- Axios API boundary → Express app: /api/v1
- Server entry → Express app
- Express app → Request middleware: applies
- Express app → API routes: mounts
- API routes → Controllers: dispatches
- Request middleware → JWT token handling: auth enforcement
- Controllers → Domain services: delegates
- Domain services → Mongoose models: reads and writes
- Mongoose models → MongoDB: persists documents
- Request middleware → Upload pipeline: multipart files
- Domain services → Upload pipeline: stores note files
- Upload pipeline → Cloudinary: uploads
- Domain services → JWT token handling: issues tokens