Developer Documentation ๐Ÿ“š

Everything you need to understand, set up, and contribute to Schedulr.

Prerequisites

You should be familiar with or have a basic understanding of:

HTML / CSS / JavaScript Web Scraping Google Calendar API Cloudflare Workers GitHub Actions Chrome Extension (MV3)

System Architecture

The diagram below shows the high-level system architecture of Schedulr:

Schedulr System Architecture Diagram

Project Structure

schedulr/
โ”œโ”€โ”€ backend/                    # Backend code
โ”‚   โ”œโ”€โ”€ cloudflare-workers/     # Cloudflare Worker API
โ”‚   โ”‚   โ”œโ”€โ”€ dist/               # Built output files
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.ts        # Main Worker entrypoint
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ lib/            # Reusable helper functions
โ”‚   โ”‚   โ”œโ”€โ”€ .dev.vars           # Dev environment secrets
โ”‚   โ”‚   โ”œโ”€โ”€ .dev.vars.prd       # Production environment secrets
โ”‚   โ”‚   โ””โ”€โ”€ wrangler.jsonc      # Wrangler config
โ”‚   โ””โ”€โ”€ db/                     # Database schema & migrations
โ”œโ”€โ”€ docs/                       # This website
โ”œโ”€โ”€ frontend/                   # Chrome extension client code
โ”‚   โ”œโ”€โ”€ dist/                   # Built extension files
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ backgrounds/        # Service worker scripts
โ”‚       โ”œโ”€โ”€ popup/              # Extension popup UI
โ”‚       โ””โ”€โ”€ scripts/
โ”‚           โ”œโ”€โ”€ auth/           # OAuth authentication flow
โ”‚           โ”œโ”€โ”€ calendar/       # Google Calendar integration
โ”‚           โ”œโ”€โ”€ scraper/        # CliC timetable scraper
โ”‚           โ””โ”€โ”€ utils/          # Shared utilities
โ”œโ”€โ”€ images/                     # Project images & diagrams
โ”œโ”€โ”€ rollup.config.js            # Bundler config
โ”œโ”€โ”€ Makefile                    # Build shortcut commands
โ”œโ”€โ”€ manifest.json               # Extension manifest (MV3)
โ””โ”€โ”€ package.json                # Root package config

Program Flow

The sequence diagram below illustrates both the authentication and calendar import processes:

Schedulr Program Flow Sequence Diagram

Entity Relationship Diagram

In this schema, each account is treated as a separate user even when logged in from the same IP.

Schedulr Entity Relationship Diagram

Table relationships:

Note: Each user can only have one oauth_tokens and sessions record because the program upserts (overwrites) the previous token and session on each login. See backend/db/schema.sql for table definitions.

Secret Management

Project secrets are stored as GitHub Secrets and injected as environment variables during the build process via GitHub Actions. Never commit secrets to the repository.

Build Process

Building and deploying is handled by GitHub Actions:

Schedulr GitHub Actions Build Pipeline

Getting Started

Note: This guide is based on Google Chrome. Some steps (especially manifest.json format) may not apply directly to other browsers โ€” refer to their documentation as needed.

1. Clone the repository

git clone https://github.com/sycanz/schedulr
cd schedulr

2. Load the extension into Chrome

  1. Open Chrome and navigate to chrome://extensions/
  2. Enable Developer mode (toggle in the top right)
  3. Click Load unpacked and select the cloned repository
  4. Note the Extension ID (Item ID) โ€” you'll need it for the Google OAuth redirect URI

3. Set up Google Calendar API

  1. Create a new project in the Google Cloud Console
  2. Enable the Google Calendar API
  3. Create OAuth 2.0 credentials (Web application type) and add the authorised redirect URI:
    https://<YOUR-EXTENSION-ID>.chromiumapp.org/oauth
  4. Copy the Client ID and Client Secret

4. Set up the development environment

  1. Install all dependencies from the root directory:
    npm run setup
  2. Create a .env file in the root directory (frontend secrets):
    # Refer to .env.example for required variables
    cp .env.example .env
  3. Create a .dev.vars file in backend/cloudflare-workers/ (backend secrets):
    cp backend/cloudflare-workers/.dev.vars.example backend/cloudflare-workers/.dev.vars

Development Tips

Backend (Cloudflare Workers)

There are two ways to develop and test the Cloudflare Worker:

Local development (recommended for dev)

  1. In terminal 1 (project root): npm run watch:scraper โ€” watches for file changes
  2. In terminal 2 (backend/cloudflare-workers/): npm run dev โ€” starts the Worker locally

Note: Set the CFW endpoint to http://localhost:8787 in your .env when using local dev.

Push to dev / production environment

  1. Authenticate: npx wrangler login
  2. Deploy with Makefile shortcuts:
    make deploy-dev   # deploy to dev environment
    make deploy-prd   # deploy to production

Note: You need to re-run the deploy command after each change to update the remote Worker.

Git Hooks (pre-commit)

Husky is configured to automatically run on every commit:

Manual execution

Tech Stack ๐Ÿš€

JavaScript (ES6+) Google Calendar API OAuth 2.0 HTML / CSS Cloudflare Workers Supabase Rollup

Contributing ๐Ÿค

Schedulr is open-source and welcomes contributions! Check out the contribution guidelines to get started. Bug fixes, feature requests, documentation improvements, and code contributions are all welcome.