ThoughtSwap is a real-time classroom discussion tool that facilitates anonymous peer review of short answers ("thoughts") using Canvas for authentication.
- Client: React (Vite) + Tailwind CSS
- Server: Node.js (Express) + Socket.io + Prisma (PostgreSQL)
- Node.js (v18+ recommended)
- npm
- Docker & Docker Compose
- A Canvas LMS instance (or a Free-for-Teacher account) for developer keys.
The easiest way to build and deploy ThoughtSwap locally is using Docker Compose. This spins up the Postgres database, API server, and Client UI automatically.
Configure Environment: Copy the example environment file to
.env:cp env.example .env
Open
.envand populate the Canvas Configuration section (Client ID, Secret, URL). You can generally leave the Database and Port configurations at their defaults.Start the Application:
If running a demo (where you want others to connect and try out the app running on your computer)
- start ngrok first:
ngrok 5173 - get the ngrok URL from the
Forwardingoutput, e.g.https://9ca1-128-130-184-40.ngrok-free.app - update vite.config.js to add the ngrok hostname to the
allowedhosts
- start ngrok first:
Run the following command to build the images and start the services:
docker-compose up --build
Note: The server container will automatically apply database migrations upon startup.
Access:
- Client:http://localhost:5173
- Server:http://localhost:8000
Optional: Seed Data To create the "Dev Teacher" account without a real Canvas login, run the seed command inside the running server container:
docker-compose exec server npx prisma db seedTroubleshooting:
- Blocked request
- after adding the ngrok host to vite config (see above), you have to rebuild at least the frontend docker container, so maybe just kill the docker container and re-run
docker-compose up --build
- after adding the ngrok host to vite config (see above), you have to rebuild at least the frontend docker container, so maybe just kill the docker container and re-run
- Blocked request
If you prefer to run the Node applications directly on your host machine (while using Docker for the database), follow these steps.
Clone the repository:
git clone https://github.com/victor-hugo-dc/thoughtswap-ts.git cd thoughtswap-tsInstall dependencies: This will install dependencies for the root, client, and server workspaces.
npm install
Environment Configuration: Create a
.envfile in the root directory (orpackages/server/.envdepending on your preference, but the docker setup expects it at root or server level).# Server ConfigurationPORT=8000DATABASE_URL="postgresql://user:password@localhost:5432/thoughtswap?schema=public"FRONTEND_URL="http://localhost:5173"# Canvas OAuth Configuration# Obtain these from Canvas Admin -> Developer KeysCANVAS_CLIENT_ID="your_client_id"CANVAS_CLIENT_SECRET="your_client_secret"CANVAS_BASE_URL="https://<your-canvas-instance>.instructure.com"# IMPORTANT: Must match exactly what is configured in CanvasCANVAS_REDIRECT_URI="http://localhost:8000/accounts/canvas/login/callback/"
Use Docker to spin up the PostgreSQL database defined in docker-compose.yml.
docker-compose up -d postgresApply the Prisma schema to your database and seed the initial dev user.
# Run from the root
npm run dev --workspace=packages/server
# OR specifically for migrations:cd packages/server
npx prisma migrate dev
npx prisma db seedThe seed command creates a "Dev Teacher" account (teacher@dev.com) which allows you to test teacher features without a real Canvas login.
Run both the client and server concurrently from the root directory.
npm run dev- Client: http://localhost:5173
- Server: http://localhost:8000