The backend API powering CourseMate — an intelligent academic advising platform for universities.
- Overview
- Live Deployment
- Tech Stack
- Architecture
- Features
- API Modules
- Getting Started
- Environment Variables
- Scripts
- Testing
- API Documentation
- Project Structure
- Contributors
CourseMate Server is a RESTful API built with Node.js, Express 5, TypeScript, and MongoDB. It serves as the backbone of the CourseMate academic platform, managing student data, course registration, AI-powered recommendations, academic plans, schedules, notifications, and more.
The server integrates LangChain with Google Generative AI (Gemini) to deliver intelligent course recommendations and a RAG-based (Retrieval-Augmented Generation) knowledge base assistant for students and supervisors.
Environment URL Production API https://coursemate-server-3a4x.onrender.com Swagger UI Docs https://coursemate-server-3a4x.onrender.com/api-docs Frontend App https://coursemate.xyz
Layer Technology Runtime Node.js (ESM) Language TypeScript 5.x Framework Express 5.x Database MongoDB via Mongoose 9.x Authentication JWT + Passport.js + Google OAuth 2.0 AI / LLM LangChain + Google Generative AI (Gemini) RAG Pipeline LangChain + PDF-Parse + Text Splitters Validation Zod API Docs Swagger (swagger-jsdoc + swagger-ui-express) File Uploads Multer Logging Morgan Security Helmet + CORS Testing Vitest + Supertest + mongodb-memory-server + MSW
The server follows a feature-based (horizontal) folder structure, where each domain concern is fully encapsulated in its own module with dedicated routes, controllers, services, models, and schemas.
src/ ├── config/ # Database connection & environment config ├── features/ # Feature modules (see below) ├── shared/ # Middlewares, types, utilities │ ├── middlewares/ │ ├── types/ │ └── utils/ └── seed.ts # Database seeding script
- Authentication & Authorization — JWT-based auth with Google OAuth 2.0 SSO support and role-based access control (Student, Supervisor, Admin)
- Course Management — Full CRUD for courses, sections, departments, and enrollment
- Academic Planning — Personalized academic plan generation and management per student
- Academic Warnings — Automated detection and management of students at academic risk
- Important Dates — University-wide important dates and deadlines management
- Analytics & Reports — Aggregated statistics and performance reports for admins and supervisors
- Notifications — Real-time notification system for students and staff
- AI Recommendations — LLM-powered course recommendations tailored to each student's academic history
- AI Chat (RAG) — Retrieval-Augmented Generation assistant trained on university documents (PDFs)
- Knowledge Base — Document upload and management to feed the RAG pipeline
- Schedule Management — Weekly schedule generation and conflict detection
Module Description authLogin, logout, Google OAuth, token refresh userUser profiles, roles, student/supervisor management courseCourse CRUD, prerequisites, credit hours course-sectionSection creation, capacity, enrollment departmentDepartment management academic-planStudent academic plan generation & tracking academic-ruleUniversity academic rules and policies academic-warningWarning issuance and tracking scheduleWeekly schedule management important-datesKey academic calendar dates analyticsPerformance metrics and reports notificationPush notifications and alerts aiAI chat endpoint (RAG-based assistant) ai-recommendationPersonalized course recommendation engine knowledge-baseDocument uploads to power the AI assistant
- Node.js >= 18
- MongoDB instance (local or Atlas)
- Google OAuth credentials (for SSO)
Google Generative AI API key (for AI features)
# Clone the repository git clone https://github.com/Mais-A-A/CourseMate-Server.git cd CourseMate-Server # Install dependencies npm install # Build TypeScript npm run build # (Optional) Seed the database npm run seed# Development (with nodemon) npm run start:dev # Production npm run start:prod
Create a
.env.developmentand.env.productionfile in the root. Required variables:# Server PORT=5000 NODE_ENV=development # Database MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/coursemate # Authentication JWT_SECRET=your_jwt_secret JWT_EXPIRES_IN=7d # Google OAuth GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_CALLBACK_URL=http://localhost:5000/auth/google/callback # Google Generative AI (Gemini) GOOGLE_GENAI_API_KEY=your_gemini_api_key # Frontend CLIENT_URL=http://localhost:5173
Script Description npm run buildCompile TypeScript to JavaScript npm run start:devStart server in development mode (nodemon) npm run start:prodStart server in production mode npm run seedSeed the database with initial data npm run test:unitRun unit tests (mocked dependencies) npm run test:integrationRun integration tests (real dependencies) npm run test:watchRun tests in watch mode npm run test:uiOpen Vitest UI npm run coverageGenerate test coverage report npm run context:dumpDump AI context for debugging
The project uses Vitest as the test runner with:
- Unit tests — Dependencies mocked via MSW and Vitest mocks
Integration tests — Uses
mongodb-memory-serverfor an in-memory MongoDB instance andsupertestfor HTTP assertions # Run all unit tests npm run test:unit # Run all integration tests npm run test:integration # Generate coverage report npm run coverageTests are located in the
tests/directory at the project root.
The API is fully documented with Swagger / OpenAPI 3.0.
Access the interactive docs at: https://coursemate-server-3a4x.onrender.com/api-docs
When running locally, visit:
http://localhost:5000/api-docsDocumentation: Google Drive Doc
CourseMate-Server/ ├── src/ │ ├── config/ # DB connection, env config │ ├── features/ │ │ ├── academic-plan/ │ │ ├── academic-rule/ │ │ ├── academic-warning/ │ │ ├── ai/ │ │ ├── ai-recommendation/ │ │ ├── analytics/ │ │ ├── auth/ │ │ ├── course/ │ │ ├── course-section/ │ │ ├── department/ │ │ ├── important-dates/ │ │ ├── knowledge-base/ │ │ ├── notification/ │ │ ├── schedule/ │ │ └── user/ │ ├── shared/ │ │ ├── middlewares/ │ │ ├── types/ │ │ └── utils/ │ └── seed.ts ├── tests/ ├── app.ts # Express app setup ├── index.ts # Server entry point ├── swagger.ts # Swagger configuration ├── tsconfig.json ├── vitest.config.ts └── package.json
Name GitHub Mais Arafeh @Mais-A-A Hasan Al-Saafin @HasanAlsaafen Hasan Alsaafin @Hasan2005-CS
Mais-A-A/CourseMate-Server
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|