Project
BrainWave
I built an authenticated Express chat endpoint that adds course and page context to model prompts. A shared interface reads provider settings from MongoDB and routes requests to Gemini, OpenAI, or Anthropic.
How it’s built View architectureHow it’s built
BrainWave · AI-assisted online learning platform with courses, live classes and tutor chat
BrainWave is an online learning platform where students enrol in tutor-led courses, join live classes and use an AI assistant. I built the TypeScript Express backend with 88 routes across 16 route modules and 15 Mongoose models, Stripe and wallet payments, Jitsi JaaS tokens for live sessions and Socket.IO messaging. Its AI service routes chat to Gemini, OpenAI or Anthropic from a MongoDB setting and adds context from 6 skill files. I also built the student app and a separate admin console.
- Express API routes
- 88
- Mongoose models
- 15
- LLM providers behind one chat interface
- 3
- AI skill context files (plus 2 memory files)
- 6
- pages in student app and admin console
- 29 + 14
- lines of backend TypeScript
- ~6,600
Technology and what it does here
- Express 5 + TypeScript
- REST API for auth, courses, lessons, enrollment, payments, admin and AI
- Mongoose / MongoDB
- 15 models including courses, enrollments, coupons, transactions, live sessions and AI logs
- Gemini, OpenAI, Anthropic SDKs
- Provider chosen from a Setting document, with env and auto fallback
- LangChain
- ChatOpenAI client and shared HumanMessage/SystemMessage format
- Gemini TTS
- Gemini-2.5-pro-preview-tts speech generation in the AI service
- Stripe
- Payment intents and server-side payment verification
- Jitsi as a Service
- RS256-signed JWTs for live classroom access
- Socket.IO
- Join_chat and send_message events for direct messaging
- Nodemailer
- Transactional emails from templated service
- React + TanStack Query
- Student and tutor web app with Stripe Elements
- React 19 + Recharts
- Admin console dashboards
- Helmet + JWT
- HTTP hardening and route protection middleware
Implementation details
- Provider selection reads an aiProvider Setting from MongoDB, falls back to the AI_PROVIDER env var, then auto-selects whichever API key is present.
- A context loader caches markdown skill and memory files at startup and injects the relevant ones into assistant prompts.
- Live session access uses Jitsi JaaS tokens signed with RS256 and a kid header from a server-held private key.
System architecture
The AI tools run through an authenticated Node.js API that prepares course context and routes requests to language model providers through LangChain.
Technologies
- React
- Node.js
- Express
- MongoDB
- LangChain
