Introducing a new way to review your PRs.

Read the announcement

nusmodifications / nusmods

🏫 Official course planning platform for National University of Singapore.

View on GitHub

20 documents · Updated Nov 6, 2026

docs / export-and-operations

Export and operations

NUSMods delivers timetable files through a separate export service and runs its product services across hosted and self-managed systems. The operating model keeps the website and export requests easy to deploy while the timetable data pipeline and public data hosting run independently.

Service boundary

The product has two main delivery paths. The website serves the planning experience, while the export service turns a timetable selected in the browser into a file; both depend on public timetable data but do not share a live session or database.

Timetable export delivery

The browser sends the export service the smallest state needed to reproduce the selected timetable. The service validates that state, renders a timetable-only page, and returns a PNG image or PDF download. This makes export a one-request delivery path rather than a second timetable editor.

The timetable export service explains the rendering contract and output behavior in more detail.

The delivery flow connects the user's current view to a portable file.

flowchart LR
    Browser[Timetable in browser] --> State[Export state]
    State --> Request[Image or PDF request]
    Request --> Export[Export service]
    Export --> Data[Module data]
    Data --> Render[Rendered timetable]
    Render --> Download[File download]

References: website/…/export.ts• L9-43 website/…/export.ts• L8-28 export/…/data.ts• L60-75 export/…/render-serverless.ts• L50-93

Export request contract

The export request carries the active semester timetable together with display choices. These choices include course colors, hidden courses, teaching-assistant courses, theme settings, and color scheme. Image requests can also carry a pixel ratio and viewport size so the file fits the user's output needs.

The image and PDF endpoints use the same timetable data contract. They differ only in the output format and image-specific display options. The service returns the result as an attachment so the browser treats it as a download.

References: website/…/export.ts• L6-16 website/…/export.ts• L16-43 export/…/image.ts• L8-43 export/…/pdf.ts• L6-16

Export dependencies

The renderer needs two kinds of input beyond the request. It needs a timetable-only page that can display the supplied state, and it needs module details to label and place the selected lessons. It can read module data from its configured local source or use the public NUSMods data service as a fallback.

This creates a cross-service dependency: a successful download needs the export host, the timetable page, and the matching academic-year module data to be available at the same time.

References: export/…/config.ts• L2-19 export/…/data.ts• L12-36 export/…/render-serverless.ts• L26-66

Deployment hosting

NUSMods uses hosted functions for the website and export path, and self-managed hosts for the data pipeline and static API data. The deployment hosting page covers the hosting setup and operator tasks in more detail.

Hosted product services

The website and export service deploy through separate Vercel projects. A branch or pull request can produce a preview, while the production branch configured in Vercel produces the live service. The website exposes the main user experience and API routes; the export project exposes the file rendering endpoints.

The export workspace defines the build, start, development, and validation commands used to create and serve the export service. The hosting configuration also gives export functions a bounded execution time. This is important because each request starts a browser render rather than returning a stored file.

References: DEPLOYMENT.md• L7-27 website/vercel.json• L1-8 export/vercel.json• L1-20 export/package.json• L9-18

Data pipeline hosting

The scraper and static API data are operated outside the hosted website and export projects. The scraper fetches current module and timetable data, while a web server makes generated JSON available through api.nusmods.com. Search infrastructure is an additional operational service used by the product.

This split lets the website and export service remain stateless. A data refresh changes the public data files without requiring a website session or an export service database update.

References: DEPLOYMENT.md• L37-47 DEPLOYMENT.md• L78-101 ARCHITECTURE.md• L66-80

Request routing

The public request path can pass through a reverse proxy before it reaches a product service. The proxy keeps the main website, export path, and public API under stable host and path rules, while HTTPS termination and certificate handling remain at the machine boundary.

In the self-hosted layout, the instance proxy sends website traffic to the website service, removes the /export prefix before sending export traffic to the export service, and forwards /api traffic to the public API host. The machine-level proxy provides the shared HTTPS entry point for services on the host.

References: infra/…/Caddyfile• L1-28 infra/…/docker-compose.yml• L3-25 infra/…/traefik.toml• L1-48

Operational lifecycle

Deployment is a change flow from source to a running product service. Operators first build the service with the repository's workspace tools, then validate the user paths that cross service boundaries.

The main operational stages are:

  1. A branch or production change starts a hosted build, or an operator updates a self-managed host.
  2. The website and export service build their deployable output.
  3. The data pipeline refreshes or serves the data needed by the product.
  4. The operator checks module search, timetable rendering, PNG export, PDF export, and error reporting.
  5. The operator checks the scraper and public API when the data path changed.

The deployment hosting page is the child guide for host setup and service operations. Local production-like website checks can serve the built static output before a hosted release.

References: DEPLOYMENT.md• L19-35 DEPLOYMENT.md• L115-130 export/README.md• L83-110

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the browser export state shape aligned with export validation and the timetable-only page.
  • Keep the export service's academic-year setting aligned with the module data source used for rendering.
  • Keep Vercel build settings and function limits aligned with the time and files needed for browser rendering.
  • Keep reverse-proxy path rules aligned with the public website, export host, and /api data route.
  • Keep data-pipeline output paths aligned with the static API server and the URLs consumed by the website and export service.
  • Recheck both hosted and self-managed health paths when a service boundary changes.

Important failure modes

TriggerConsequenceGuard
Export input does not match the supported timetable shapeThe user receives a 422 response instead of a file.Validate the request before starting the browser render.
The timetable-only page cannot loadImage and PDF exports fail with a server error.Keep the configured page reachable and check export after deployment.
Module data is missing for a selected courseThe rendered timetable can be incomplete or the request can fail.Keep local module data current or preserve access to the public data API.
Export rendering exceeds the hosted function limitThe download does not complete.Keep the render path within the configured Vercel function duration and test both formats.
Proxy rules do not remove or preserve the expected path prefixWebsite, export, or API requests reach the wrong route.Check the public URL path through the reverse proxy after routing changes.
The scraper stops updating generated JSONThe website and export service can show stale or missing academic data.Check the scraper process and public static API after data-pipeline changes.

Key files

FileWhy to read it
DEPLOYMENT.mdGives the deployment split, release checks, self-managed data setup, and update flow.
website/…/export.tsShows how the website creates the public image and PDF export requests.
website/…/export.tsDefines the browser state that crosses into the export service.
export/README.mdGives the export service purpose, local workflow, API shape, and deployment context.
export/package.jsonDefines the commands used to build, serve, develop, and validate the export service.
export/…/handler.tsShows the shared validation, browser lifecycle, and error boundary for exports.
export/…/render-serverless.tsShows how supplied timetable state becomes an image or PDF.
export/…/config.tsDefines the operational settings that connect rendering to page, data, and error services.
website/vercel.jsonDefines hosted website function inclusion, API routing, and cache headers.
export/vercel.jsonDefines hosted export build behavior, routes, and function limits.
infra/instance/CaddyfileDefines the self-hosted routing between website, export, and public API paths.
infra/…/traefik.tomlDefines the machine-level HTTPS entry point and public API route.