How tri1210/eduroom works
Project type and purpose
• EduRoom is a full-stack, web-based video conferencing and chat application.
• Frontend: React SPA (client/)
• Backend: Node.js + Express REST + Socket.io signaling (server/)
• Real-time video/audio: WebRTC via simple-peer
• Features: authentication, room management, multi-user video & text chat, screen sharing, AI chatbot
High-level architectural components
a. Client (Browser)
• React UI: pages (Home, Login, Register, Room…), reusable components (Navbar, Chat, VideoCard, BottomBar)
• State & context: AuthContext, API wrappers (api.js)
• WebSocket client: socket.js connecting to server for real-time signaling & chat
• WebRTC peers: simple-peer instances for media stream negotiation
• HTTP REST calls: user auth, profile update, news, room list
b. Server
• Express app (index.js)
• Middleware: auth.middleware.js for JWT validation
• REST routes: user, room, message, news, chatbot
• Socket.io server: attached to Express for signaling events (join-room, signal exchange, chat messages)
• Data models: User, Room, Message, PrivateMessage, News (likely MongoDB via Mongoose)
• AI Chatbot integration: chatbot.routes.js calls external AI service (e.g., OpenAI)
• Database: external (MongoDB) – not shown in code, but implied by models
c. External services
• Database server (MongoDB)
• AI Chatbot API (OpenAI or similar)
Relationships and data flows
1. User opens browser → React app served (public/index.html)
2. React → HTTP POST /api/auth (sign-in/up) → JWT issued
3. Authenticated React → HTTP GET /api/rooms, /api/news → server queries DB → returns JSON
4. User “Join Room”: React emits Socket.io “join-room” with JWT → server authorizes via auth.middleware → adds to Socket.io room
5. WebRTC signaling:
• Peer A emits “signal” → server broadcasts to other peers in room → Peer B receives → simple-peer handshake → direct P2P media streams
6. Text chat: React emits “chat-message” via Socket.io → server saves via Message.model → broadcasts to room
7. AI Chatbot: React posts to /api/chatbot → server routes to chatbot.routes → invokes external AI service → returns bot response
Architectural patterns and design principles
• Separation of concerns: frontend vs. backend vs. database vs. external services
• Component-based UI (React)
• MVC-like structure on server (routes → controllers embedded in routes → models)
• Event-driven, real-time layer via WebSocket (Socket.io)
• Peer-to-peer media streaming via WebRTC
• JWT-based stateless authentication