Communication & Messaging
Last updated August 2, 2026
Classgrid's Communication system is built around a RAG-powered AI chat assistant (chat.routes.js, 863 lines) that serves as the primary student-facing interface. The AI assistant has deep integration with 13 real-time data sources across the platform. Additionally, the platform supports real-time classroom chat, group messaging, threaded conversations, org-wide announcements, forums, and push notifications through dedicated route files.
AI Chat Assistant (Module 24 — RAG Engine)
API: POST /api/chat/stream (Server-Sent Events)
API: POST /api/chat/ (Standard request/response with file upload)
Roles: Any authenticated user
The AI chat uses Classgrid AI (model: classgrid-v3) with a comprehensive RAG (Retrieval-Augmented Generation) engine that pulls real-time context from 13 data sources.
RAG Data Sources
Request Format
New User Onboarding
When isFirstMessage: true and the user has zero enrolled classrooms, the AI automatically:
- Greets them by name: "Hi Rahul!"
- Explains how to join a classroom (10-digit code from teacher)
- Explains auto-linking to organization
- Lists available features (notes, quizzes, announcements, viva)
- Mentions the Classgrid Honor Code
Streaming Response
POST /api/chat/stream returns Server-Sent Events:
Classroom Context API
API: GET /api/chat/classroom-context/:classroomId
Roles: Any user
Returns recent classroom activity as structured JSON for the assistant's welcome screen:
Real-Time Chat System
The platform has multiple chat route files for different contexts:
Classroom Chat
- File:
classroom_chat.routes.js - Scope: Messages within a specific classroom between teacher and students
- Storage: Supabase
Organization Chat
- File:
org_chat.routes.js - Scope: Org-wide communication channels
Group Chat
- File:
group_chat.routes.js(59KB) - Scope: Custom groups within the organization
- Features: Group creation, member management, message history
Threaded Conversations
- File:
thread_chat.routes.js(123KB — largest route file) - Scope: Reply threads on messages
- Features: Nested replies, thread resolution, pagination
Direct Messaging
- File:
messaging.routes.js - Scope: 1:1 direct messages between users
Notifications System
In-App Notifications
Model: Notification (MongoDB)
Fields:
recipient— ObjectId reference to Usertype—assignment,result,attendance,library,quick_leave,system,request_approved,request_rejectedtitle— notification title with emojimessage— notification bodylink— deep link to relevant pagerelatedId— reference to the related entityemailSent— boolean tracking if email was dispatchedemailSentAt— timestamp of email dispatch
Push Notifications
Service: push.service.js + firebase.service.js
Route: push.routes.js
Uses Firebase Cloud Messaging (FCM) for native push notifications to mobile and desktop.
Central Notification Service
Service: notification.service.js
Two main functions used across all modules:
-
dispatchNotification()— sends to a single recipientJS -
bulkDispatchNotification()— sends to multiple recipientsJS
Scheduled Notifications
Model: ScheduledNotification
Supports scheduling notifications for future delivery (e.g., exam reminders, fee due reminders).
Organization Announcements
Model: OrganizationAnnouncement (MongoDB)
Fields:
organization_id— scoped to orgtitle,content— announcement texttype—general,holiday,event,noticestatus—draft,publishedtarget_type—allor specific targetstarget_classrooms— array of classroom ObjectIdssent_at— publication timestamp
Used by:
- Admin dashboard for org-wide communication
- RAG engine (Source #6) — feeds into AI chat context as academic calendar events
Forums
Models: ForumPost, ForumComment (MongoDB)
Community discussion boards within the organization. Features:
- Post creation with rich text
- Threaded comments on posts
- Accessible via
forum.routes.js