-
Notifications
You must be signed in to change notification settings - Fork 353
Open
Description
Summary
We want to rewrite website to Next.js while reducing lock-in to the metaframework. This issue tracks extracting framework-agnostic domain logic into standalone modules before / during the rewrite.
Goals
- Isolate domain logic from routing, rendering, browser APIs, and Next.js runtime concerns.
- Improve reuse across frontend, server routes, and tooling.
- Reduce migration risk by moving high-confidence pure logic first.
Proposed module split
1) @nusmods/timetable-core (high priority)
Extract from website/src/utils:
timetables.tstimify.tscolors.tsoptimiser.ts
Scope:
- Timetable modeling / validation
- Lesson arrangement and clash logic
- Serialization / deserialization
- Optimiser data transformations
2) @nusmods/planner-core
Extract:
website/src/utils/planner.ts- Pure planner selectors from
website/src/selectors/planner.ts(after decoupling config/state access)
Scope:
- Prereq/conflict evaluation
- Planner domain invariants
- Planner text formatting for conflicts (non-UI)
3) @nusmods/nus-data-client
Extract:
website/src/apis/nusmods.js- Typed request clients from
website/src/apis/{nextbus,weather,optimiser}.ts
Scope:
- Endpoint builders
- API request/response typing
- Transport adapter boundary (
fetch/axios injectable)
4) @nusmods/route-schema
Extract:
- Pure path builders/parsers from
website/src/views/routes/paths.ts
Scope:
- Route generation / parsing
- Share URL construction
Note:
absolutePath()is browser-dependent and should remain as an app runtime helper.
Keep in Next.js app layer (not standalone)
- React view components (
website/src/views/**) - App entry/bootstrap (
website/src/entry/**,website/src/bootstrapping/**) - Redux wiring / persistence setup (
configure-store, persistence adapters) - Browser-only utilities (
insertScript, localStorage wrappers, window/document helpers) - Serverless platform wrappers (
website/src/serverless/**, Vercel-specific handler wrappers)
Refactor prerequisites
- Split React/text helpers from domain helpers:
website/src/utils/modules.tsandwebsite/src/utils/weekText.tscurrently depend onutils/react.tsx
- Remove side effects from reducers before extraction:
reducers/theme.tsandreducers/settings.tscall Matomo tracking; move tracking to middleware/effects.
Implementation plan (incremental)
- Extract
@nusmods/timetable-corewith tests migrated first. - Extract
@nusmods/nus-data-clientand@nusmods/route-schema. - Extract
@nusmods/planner-core. - Replace imports in
websitewith package imports. - Start Next.js app migration with extracted modules as stable dependencies.
Acceptance criteria
- New packages created under
packages/with clear public APIs. - Existing tests for extracted logic pass in package scope.
-
websiteconsumes extracted packages (no duplicated logic). - No framework-specific imports in extracted package entrypoints.
- Migration doc added describing dependency boundaries and ownership.
Out of scope
- Full React component rewrite
- Styling system migration
- Serverless deployment replatforming
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels