Skip to content

Commit 31179f1

Browse files
author
Nils Bars
committed
Split student-facing views and api.py into dedicated API packages
- Move JSON endpoints out of `view/api.py` into `services_api/` (SSH proxy + container callbacks) and `frontend_api/` (SPA `/api/v2/*` + scoreboard). `view/build_status.py` hosts the admin build-status poll. - Delete Flask-rendered registration, restore-key, scoreboard, and chooser landing pages along with their templates, static JS/CSS, and vendored chart assets; the SPA serves these under `/v2/*`. - Drop `SCOREBOARD_VIEW` setting and the view resolver — only one scoreboard renderer exists. - Redirect `/`, `/student`, and `/student/` straight to the configured SPA landing page; admin navbar drops its public student links. - Rework the Vue scoreboard charts to plot only per-team improvements, use distinct marker shapes, and support drag-pan / wheel-zoom / shift-drag box-zoom via `chartjs-plugin-zoom`; clamp the x-axis at the earliest data point and preserve zoom state across data polls. - Refresh `ARCHITECTURE.md`, `SCOREBOARD.md`, `CLAUDE.md`, and `README.md` to describe the current package layout.
1 parent ac43286 commit 31179f1

46 files changed

Lines changed: 2918 additions & 3756 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/CLAUDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ REF is a containerized platform for hosting programming exercises with isolated
152152
### Components
153153

154154
1. **Web Application** (`webapp/`) - Flask app on port 8000
155-
- `ref/view/` - Route handlers (API, exercises, grading, instances, file browser, visualization, system settings, etc.)
155+
- `ref/view/` - HTML route handlers (exercises, grading, instances, file browser, visualization, admin student management, system settings, etc.)
156+
- `ref/services_api/` - JSON endpoints called by services (SSH reverse proxy hooks in `ssh.py`, student container callbacks in `instance.py`)
157+
- `ref/frontend_api/` - JSON endpoints consumed by the Vue SPA (registration/restore-key in `students.py`, public scoreboard in `scoreboard.py`; mounted under `/api/v2/*` + `/api/scoreboard/*`)
156158
- `ref/model/` - SQLAlchemy models (users, groups, exercises, instances, submissions, grades, system settings)
157159
- `ref/core/` - Business logic managers (`ExerciseManager`, `InstanceManager`, `ExerciseImageManager`, `UserManager`, `DockerClient`, etc.)
158160

161+
Student-facing pages (registration, restore-key, public scoreboard) are served by the Vue SPA under `/v2/*` and talk to `ref/frontend_api/`. Admin pages live under `ref/view/` as Jinja-rendered HTML.
162+
159163
2. **SSH Reverse Proxy** (`ssh-reverse-proxy/`) - Rust-based SSH proxy on port 2222
160164
- Routes student SSH connections to exercise containers
161165
- Uses web API with HMAC-signed requests for authentication and provisioning
@@ -195,7 +199,7 @@ Client (ssh exercise@host -p 2222)
195199

196200
## Code Comments
197201

198-
- Do not reference line numbers in comments (e.g., "see api.py lines 397-404"). Line numbers change frequently and become outdated. Reference functions, classes, or use direct code references instead.
202+
- Do not reference line numbers in comments (e.g., "see ssh.py lines 397-404"). Line numbers change frequently and become outdated. Reference functions, classes, or use direct code references instead.
199203

200204
## Pending Tasks
201205

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@ The following features are disabled by default and can be enabled from the admin
184184
Allows students to be organized into named groups with a configurable maximum size. Students pick a group during registration, and admins can manage the available groups and reassign students afterwards. Enable via the `GROUPS_ENABLED` setting and configure the per-group capacity via `GROUP_SIZE`.
185185

186186
#### Scoreboard
187-
A public leaderboard at `/scoreboard` that ranks students based on their exercise submissions. Exercises can be grouped into assignments, the ranking strategy is selected via `SCOREBOARD_RANKING_MODE`, and the visual layout via `SCOREBOARD_VIEW`. Enable via `SCOREBOARD_ENABLED`; optionally set `LANDING_PAGE` to `scoreboard` to use it as the default landing page.
187+
A public leaderboard at `/v2/scoreboard` that ranks students based on their exercise submissions. Exercises can be grouped into assignments and the ranking strategy is selected via `SCOREBOARD_RANKING_MODE`. Enable via `SCOREBOARD_ENABLED`; optionally set `LANDING_PAGE` to `scoreboard` to use it as the default landing page.

docs/ARCHITECTURE.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@ Flask application providing the management interface.
2323

2424
**Key modules:**
2525

26-
- `ref/view/` - Route handlers
27-
- `api.py` - SSH proxy authentication, provisioning, instance introspection, submissions
26+
- `ref/view/` - HTML route handlers (admin + student dashboards)
27+
- `build_status.py` - `/api/build-status` poll used by the exercises admin UI
2828
- `exercise.py` - Exercise import, build, delete, toggle defaults
2929
- `file_browser.py` - Interactive file browser with load/save
3030
- `grading.py` - Submission grading with search
3131
- `graph.py` - Network topology visualization
3232
- `group.py` - User group management
3333
- `instances.py` - Instance lifecycle (create/start/stop/delete/review/submit)
3434
- `login.py` - Authentication
35-
- `student.py` - User management and SSH key generation/restoration
35+
- `student.py` - Admin user management + signed key download endpoints; root/`/` redirect to the SPA landing pages
3636
- `submission.py` - Submission history
3737
- `system.py` - Garbage collection for dangling containers/networks
3838
- `system_settings.py` - System configuration (general, group, SSH settings)
3939
- `visualization.py` - Analytics dashboards (submission trends, container graphs)
4040

41+
- `ref/services_api/` - JSON endpoints called by other services (not browsers)
42+
- `ssh.py` - SSH reverse-proxy hooks: `/api/ssh-authenticated`, `/api/provision`, `/api/getkeys`, `/api/getuserinfo`, `/api/header`
43+
- `instance.py` - Student container callbacks (HMAC-signed with per-instance keys): `/api/instance/reset`, `/api/instance/submit`, `/api/instance/info`
44+
45+
- `ref/frontend_api/` - JSON endpoints consumed by the Vue SPA (`/api/v2/*` + scoreboard)
46+
- `students.py` - `/api/v2/registration{,/meta}`, `/api/v2/restore-key`
47+
- `scoreboard.py` - `/api/scoreboard/config`, `/api/scoreboard/submissions`
48+
4149
- `ref/model/` - SQLAlchemy models
4250
- `user.py` - `User`, `UserGroup`
4351
- `exercise.py` - `Exercise`, `ExerciseService`, `ExerciseEntryService`, `RessourceLimits`

0 commit comments

Comments
 (0)