Architecture overview
A Courser deployment consists of two applications and several external services:| Component | Technology | Role |
|---|---|---|
| Backend | Node.js + Express | API server, business logic, vector ingestion |
| Frontend | Next.js 13 + Tailwind CSS | Professor dashboard, student chat interface |
| Database | MongoDB | User accounts, course metadata, chatbot config |
| Vector database | Pinecone | Stores lecture embeddings for semantic search |
| AI / LLM | OpenAI | Embeddings (text-embedding-ada-002) and chat (gpt-3.5-turbo-16k) |
| Auth | Firebase + JWT | Google OAuth and email/password sign-in |
| File storage | Cloudinary | Background image uploads for chatbot customization |
Prerequisites
Before you start, make sure you have the following:Node.js 18 or later
Node.js 18 or later
The backend and frontend both require Node.js. Download it from nodejs.org or use a version manager like
nvm.MongoDB instance
MongoDB instance
You need a running MongoDB database. The easiest option is a free MongoDB Atlas cluster, which gives you a hosted connection string. You can also run MongoDB locally.Have your connection string (the
MONGO_URI) ready before proceeding.Pinecone account and index
Pinecone account and index
Courser stores lecture embeddings in Pinecone. You need a free or paid Pinecone account.The index name is hardcoded in the source as
courser. You must create an index with that exact name in your Pinecone project. Use the following settings when creating it:- Index name:
courser - Dimensions:
1536(matches OpenAItext-embedding-ada-002) - Metric:
cosine
OpenAI API key
OpenAI API key
Courser uses OpenAI for both embeddings and chat completions. You need an OpenAI API key with access to:
text-embedding-ada-002gpt-3.5-turbo-16k
Firebase project
Firebase project
Courser uses Firebase Authentication for Google OAuth and email/password sign-in.
- Create a new project in the Firebase console.
- Enable Authentication and turn on the Google and Email/Password providers.
- Copy your Firebase project configuration object (found in Project Settings → Your apps → Web app).
- Replace the
firebaseConfigobject inendpoints/auth.jswith your own config.
Cloudinary account
Cloudinary account
Courser uses Cloudinary to store chatbot background images uploaded by professors.Create a free Cloudinary account and copy your
CLOUDINARY_URL from the dashboard. It has the format cloudinary://API_KEY:API_SECRET@CLOUD_NAME.Setup
Configure environment variables
Create a For the full variable reference, see Environment variables.For the frontend, create a
.env file in the repository root with all required backend variables:.env.local file in the client directory:Set up your Pinecone index
In the Pinecone console, create a new index with these settings:
- Name:
courser - Dimensions:
1536 - Metric:
cosine
Update the Firebase config
Open You can find this object in the Firebase console under Project Settings → Your apps → Web app → SDK setup and configuration.
endpoints/auth.js and replace the firebaseConfig object with the configuration from your own Firebase project:Update CORS origins
The backend currently allows requests only from these origins:If you deploy the frontend to a custom domain, add it to this array in
app.js. Requests from unlisted origins will be blocked by the browser.Start the backend
From the repository root:This runs
node app.js. The server listens on the port defined by the PORT environment variable, or 8000 if PORT is not set.CORS configuration
The CORS allowlist inapp.js is hardcoded. For a self-hosted deployment on a custom domain, you must update it before going to production:
Production deployment
Backend
Backend
Any Node.js host works: Railway, Render, Fly.io, a VPS, or your own server. Recommended steps:
- Set all environment variables in your host’s dashboard or secret manager.
- Set
NODE_ENV=production. - Run
npm startas the start command. - Expose the port defined by
PORT(or8000). - Update the CORS allowlist in
app.jsto include your frontend domain.
Frontend
Frontend
The Next.js frontend can be deployed to Vercel, Netlify, or any Node-capable host.
- Set
NEXT_PUBLIC_API_URLto your production backend URL. - Run
npm run buildas the build command. - Run
npm startas the start command.
MongoDB
MongoDB
Use MongoDB Atlas for a managed production database. Make sure your backend host’s IP is in the Atlas network access allowlist, or set it to allow all IPs (
0.0.0.0/0) for simplicity.Process management
Process management
For VPS deployments, use a process manager like
pm2 to keep the backend running and restart it on crashes:What’s next
Environment variables
Full reference for every backend and frontend environment variable
API reference
Explore the REST API exposed by the backend