Watchtower-Course-Project

WatchTower Onboarding Guide

Purpose

This guide is a practical, hands-on companion for the CSE 110 Team 09 private handoff video and for any future maintainer picking up WatchTower. It explains how to access, run, change, test, and deploy the project. For the product overview and full reference, start at the root README.md; for the documentation map, see docs/README.md.

Quick Start

Prerequisites: Node.js 18+ (CI runs Node 24) and npm.

  1. Clone the repo

    git clone https://github.com/cse110-sp26-group09/Watchtower-Course-Project.git
    cd Watchtower-Course-Project
    
  2. Install dependencies

    npm install
    
  3. Create your environment file

    cp .env.example .env
    
  4. Fill in env vars if needed. All are optional for a basic local run. Set CLERK_PUBLISHABLE_KEY for real sign-in, the SUPABASE_* vars for persistence, and the GMAIL_* vars for alert emails. With none of these the server runs in-memory with header-trust auth, which is enough for local development and tests.

  5. Start the server

    npm start
    

    This runs npm run config:clerk (generates src/frontend/auth/clerk-config.js) then boots src/backend/server.js on port 3000.

  6. Open the local URLs

    URL Description
    http://localhost:3000/ Redirects to the landing page
    http://localhost:3000/landing/ Public landing page
    http://localhost:3000/dashboard Dashboard (requires Clerk sign-in)
    http://localhost:3000/demo/ Monitored demo app that sends events
    http://localhost:3000/dashboard-demo/ Static dashboard preview (no sign-in)

Repo Tour

.github/        # Issue/PR templates, Dependabot config, and CI workflows
archive/        # Historical Prototype 1 & 2 code, kept for project history only
docs/           # Product, architecture, ADRs, process, research, sprint docs (+ this guide)
scripts/        # Build/startup helpers (e.g. generate-clerk-config.js)
src/
├── backend/    # Node.js HTTP server, event store, mailer, alert logic
├── frontend/   # dashboard/, landing/, auth/, demo/, dashboard-demo/, shared assets/
├── sdk/        # Browser SDK (watchtower.js) that monitored apps embed
└── shared/     # Cross-cutting utilities (event-utils.js)
tests/          # unit/ (Jest) and e2e/ (Playwright)

See src/README.md for the served routes and a deeper source breakdown.

Build and Test Pipeline

Command What it does
npm start Generates the Clerk config, then runs src/backend/server.js.
npm run test:unit Jest unit tests for the src/backend pure modules (no server needed).
npm run test:e2e Playwright end-to-end tests against a running server.
npm run docs:js Generates JSDoc API docs into docs/api/ (gitignored).

Making a Small Change

A safe, demo-friendly change for the handoff video, for example editing a piece of copy text on the landing page (src/frontend/landing/index.html) or a dashboard card label (src/frontend/dashboard/index.html):

  1. Create a branch: git checkout -b demo/small-copy-change.
  2. Edit the text in the chosen HTML file.
  3. Run the app and verify visually:

    npm start    # open http://localhost:3000/landing/
    
  4. Run the unit tests to confirm nothing broke:

    npm run test:unit
    
  5. Commit, push the branch, and open a pull request.
  6. GitHub Actions CI runs automatically on the PR; merge once checks are green.

Runtime Architecture

External test app ──► WatchTower SDK ──POST /api/events──► Node.js backend
                                                              │
                                                              ▼
                                                       Supabase / Postgres
                                                              │
                                                              ▼
                                              WatchTower dashboard (per user)

A monitored app embeds the SDK, which batches events to POST /api/events. The backend normalizes and stores them in Supabase (or in-memory when Supabase is not configured), and the Clerk-authenticated dashboard reads back only the signed-in user’s events.

Auth and Data Ownership

See docs/architecture/auth-workflow.md for the full flow.

Common Troubleshooting

Handoff Video Checklist

Future Work