Spaces:
Running
solverforge-lessons WIREFRAME
This file is the architectural map for the lesson timetabling example.
README.md explains how to run and use the app. This document explains how the
pieces fit together and where each responsibility lives.
Documentation Roles
README.mdQuick start, dependency shape, API list, and user-facing orientation.WIREFRAME.mdArchitecture, execution flow, and file-map walkthrough.AGENTS.mdRepo-specific contribution, validation, and documentation rules.MakefileLocal development, validation, and Space/Docker command surface. Itstest-e2etarget contains the inline Playwright smoke for this app.DockerfileHugging Face Docker Space image definition.docs/screenshot.pngCurrent browser screenshot embedded by the README.
What This Repo Is Teaching
This repo is a complete solverforge-lessons scalar-variable SolverForge app
for weekly lesson timetabling.
It shows how to combine:
- a
Plansolution with two scalar planning variables per lesson - assignment-completeness, hard feasibility, and soft timetable-quality rules
- deterministic
LARGEdemo-data generation from domain facts - retained jobs with snapshots, analysis, cancel, pause, resume, and SSE
- a browser timetable workspace built on stock
solverforge-uiassets
SolverForge Concepts In Plain Language
Timeslot,Teacher,Group, andRoomInput facts. The solver reads them but does not move them.LessonPlanning entity. Each lesson receives a timeslot and a room.timeslot_idxandroom_idxThe two scalar planning variables onLesson.PlanPlanning solution. It holds facts, lesson entities, derived indexes, and the currentHardMediumSoftScore.- hard score Teacher/group availability, room capacity, and teacher/group/room conflicts.
- medium score Assignment completeness for timeslot and room decisions.
- soft score Room-kind fit, late slots, and repeated subject days.
- retained job A solve that lives in memory so the UI can stream events, fetch snapshots, pause/resume, cancel, analyze, and delete terminal jobs.
Runtime Flow
- The browser loads
static/index.html. static/app.jsloadsstatic/sf-config.json,static/generated/ui-model.json, andsolverforge-uiassets from/sf/*.- The app fetches
/demo-datato discover the defaultLARGEid, then loads the plan from/demo-data/LARGE. src/data/data_seed/entrypoints.rsdispatches tosrc/data/data_seed/large.rs.Plan::new()normalizes fact and lesson indexes and filters stale scalar assignment indexes.- The browser renders group, room, teacher, data, and REST API views.
- When the user clicks Solve, the browser posts the current plan to
POST /jobs. src/api/routes.rsdeserializesPlanDtoback intoPlan.SolverServicestarts a retained solve throughSolverManager<Plan>.- Solver events are converted by
src/solver/event_payload.rsinto UI-facing JSON. - The browser consumes
/jobs/{id}/eventsand fetches snapshots and analysis for exact snapshot revisions.
File Map
.
βββ Cargo.toml
β Rust 1.95 crate metadata for the app package and registry dependency
β requests.
βββ solver.toml
β Embedded search policy for construction and local search.
βββ solverforge.app.toml
β App metadata, demo IDs, model facts/entities, registry dependency sources,
β and the `solverforge 0.19.3` runtime target.
βββ Makefile
β Local build, validation, inline browser smoke, and Space/Docker commands.
βββ Dockerfile
β Multi-stage Rust 1.95 Docker image for Hugging Face Spaces.
βββ README.md
β Run guide, dependency shape, API list, and learning path.
βββ AGENTS.md
β Repo-specific rules for future edits.
βββ WIREFRAME.md
β This architectural walkthrough.
βββ docs/screenshot.png
β Current browser screenshot used by the README.
βββ src/
β βββ domain/
β β `planning_model!` manifest, facts, `Lesson`, `Plan`, and indexes.
β βββ constraints/
β β One timetable score rule per file plus the assembler in `mod.rs`.
β βββ data/
β β Deterministic `LARGE` demo-data generator and entrypoints.
β βββ solver/
β β Retained-job service and runtime event payload formatting.
β βββ api/
β DTOs, REST routes, and SSE streaming.
βββ static/
βββ index.html
βββ sf-config.json
βββ generated/ui-model.json
βββ app.js
β Browser controller, solver lifecycle, and REST API guide.
βββ views.js
Timetable view rendering for group, room, and teacher perspectives.
Demo Data
src/data/data_seed/entrypoints.rs exposes one demo ID:
LARGE
The generator is deterministic. It builds 40 weekly timeslots, 20 teachers, 12
student groups, 300 unassigned lessons, and 10 typed rooms. The initial score is
0hard/-600medium/0soft because each lesson starts without a timeslot and room.
API And Retained Runtime
The REST API handles discovery, job control, and snapshot reads:
/healthand/infoexpose liveness and app metadata./demo-dataand/demo-data/{id}expose the deterministic demo catalog./jobscreates a retained solver job./jobs/{id}and/jobs/{id}/statusexpose summary state./jobs/{id}/snapshotreturns an exact or latest snapshot./jobs/{id}/analysisruns constraint analysis for a snapshot./jobs/{id}/pause,/jobs/{id}/resume, and/jobs/{id}/cancelcontrol a live job.DELETE /jobs/{id}removes a terminal retained job./jobs/{id}/eventsstreams typed lifecycle events.
Frontend Layout
static/app.js owns the browser shell, tab state, demo loading, retained-job
controls, SSE handling, status bar, and visible REST API guide.
static/views.js owns lesson-specific presentation: group timetables, room
usage, teacher load, and data tables. The app intentionally uses an inline
Playwright smoke in Makefile instead of a tests/e2e/ directory.
Validation Surfaces
Use the Makefile as the repo-local workflow:
make fmt-checkmake clippymake build-releasemake testmake test-e2emake test-slowmake space-buildmake ci-localmake pre-release
make test runs Rust tests, frontend syntax checks, and the inline Playwright
browser smoke. make ci-local includes the Docker image build used by the
Hugging Face Space.