How ninjao9/crimson-scheduler works
Purpose and Entry Points
Crimson Scheduler is a WSU course-search and schedule-planning application. It caches WSU schedule data in a Django database, then serves a browser-based planner without querying WSU on each search. Operational entry points are the importer at main.py and Django server commands through web/manage.py; HTTP routing begins in web/web/urls.py.
Data Ingestion Pipeline
main.py initializes Django and orchestrates API-based collection. Collection handlers model the hierarchical WSU source data—campus, semester, subject, and course—under dataCollection/classHandler/campus.py, dataCollection/classHandler/semester.py, and dataCollection/classHandler/clas.py. The importer requests WSU schedule API endpoints, transforms responses, and upserts local records through dataCollection/dataHandler/data.py and dataCollection/dataHandler/storage.py.
The legacy scraper at dataCollection/dataHandler/scraper.py is explicitly not the primary ingestion path.
Persistent Course Catalog
The Django classes app owns the cached academic catalog and scheduling entities in web/classes/models.py. Its migrations establish the evolving schema for courses, sections, semester/campus/subject metadata, lecture/lab relationships, meeting details, enrollment data, and saved schedule-section structures; key later schema evolution is represented by web/classes/migrations/0012_course_has_required_lab_section_lab_metadata.py and web/classes/migrations/0013_expand_section_days_time.py.
PostgreSQL is the intended production datastore, with SQLite supported for local development. Database connection settings are consumed by web/web/settings.py.
Search and HTTP Application Layer
The application-facing behavior is concentrated in web/classes/views.py, mapped by web/classes/urls.py and included from web/web/urls.py. Search filters operate against the locally cached catalog by campus, term, subject, course number, and title. HTMX requests return incremental search-result markup rather than requiring full-page navigation, with the result fragment in web/classes/templates/classes/partials/search_results.html.
Rate limiting is a separate boundary in web/classes/rate_limit.py, backed by an atomic token-bucket Lua script at web/classes/redis_scripts/token_bucket.lua; this implies Redis as an optional/request-protection infrastructure dependency.
Schedule Construction Boundary
The server provides searchable section metadata; the interactive schedule is primarily client-managed. web/classes/templates/classes/schedule_build.html renders the planner shell and server-provided course/section results. web/classes/static/js/schedule_build.js owns section selection, lecture-plus-required-lab handling, weekly calendar rendering, overlap detection, credit totals, misc handling for unscheduled courses, JSON export, responsive navigation, and cookie persistence.
This design intentionally avoids user accounts and server-side schedule ownership: selected sections and display preferences remain in browser cookies.
UI Composition and Deployment Runtime
Django runs through standard WSGI or ASGI entry points at web/web/wsgi.py and web/web/asgi.py. Shared page layout is defined by web/classes/templates/classes/base.html; dynamic planner/search presentation is supported by web/classes/static/css/schedule_build.css and web/classes/static/js/schedule_build.js. Bootstrap and HTMX are UI dependencies, while JavaScript implements planner-specific state and rendering.
Primary Control Flow
1. An operator runs main.py to refresh WSU-derived catalog data into Django’s database.
2. A user reaches Django’s routed views and loads the schedule-builder page.
3. Search requests query local models and return full pages or HTMX search fragments.
4. The browser converts chosen sections into calendar state, validates temporal conflicts, and persists the plan locally.
5. Catalog refresh and user planning remain decoupled: WSU API access is confined to ingestion, while ordinary user traffic depends on the local database.
Main entry points: views.py Search views · models.py Catalog models · campus.py Hierarchy collectors · urls.py Root routing
Components 21
Catalog Ingestion
- Catalog importer · Operator-run catalog refresh.
main.py - WSU Schedule API
- Hierarchy collectors · Traverses campus, semester, subject, and course data.
dataCollection/classHandler/campus.py - Data transformation
dataCollection/dataHandler/data.py - Catalog upserts
dataCollection/dataHandler/storage.py
Django Application
- Catalog models · Owns courses, sections, meetings, enrollment, and schedule entities.
web/classes/models.py - Schema migrations · Includes required-lab and expanded meeting-time schema changes.
web/classes/migrations/0012_course_has_required_lab_section_lab_metadata.py - Database settings
web/web/settings.py - Root routing
web/web/urls.py - Classes routes
web/classes/urls.py - Search views · Filters the local catalog and serves planner pages or fragments.
web/classes/views.py - Rate limiting · Optional Redis-backed token bucket.
web/classes/rate_limit.py - Token bucket script
web/classes/redis_scripts/token_bucket.lua - WSGI server entry
web/web/wsgi.py - ASGI server entry
web/web/asgi.py
Browser Planner
- Planner shell
web/classes/templates/classes/schedule_build.html - Search results fragment
web/classes/templates/classes/partials/search_results.html - Client schedule planner · Owns selection, lab rules, calendar conflicts, credits, export, and persistence.
web/classes/static/js/schedule_build.js - Plan cookies · Stores selected sections and display preferences without accounts.
Other components
- Course catalog database · Production PostgreSQL with local SQLite support.
- Redis
Connections 19
- Catalog importer → Hierarchy collectors: orchestrates
- Hierarchy collectors → WSU Schedule API: requests
- Hierarchy collectors → Data transformation: normalizes responses
- Data transformation → Catalog upserts: prepares records
- Catalog upserts → Catalog models: upserts
- Catalog models → Course catalog database: persists catalog
- Schema migrations → Catalog models: evolves schema
- Database settings → Course catalog database: configures connection
- WSGI server entry → Root routing: serves HTTP
- ASGI server entry → Root routing: serves HTTP
- Root routing → Classes routes: includes
- Classes routes → Search views: maps requests
- Search views → Catalog models: queries local catalog
- Search views → Planner shell: renders
- Search views → Search results fragment: returns for HTMX
- Planner shell → Client schedule planner: loads
- Client schedule planner → Plan cookies: persists plan
- Rate limiting → Token bucket script: executes
- Rate limiting → Redis: uses