Skip to content

About

An official school Youth League Committee Office site: yali-tongban.pages.dev

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

101 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YALI Project

Yali Youth League · One-Stop Platform

English · 简体中文

version license node Cloudflare Pages Vue 3 Vite Quality gates

A one-stop service and administration platform for the Youth League Committee of Yali High School, Changsha — issue reporting, announcements, activity feed, polling, finance, hall booking, duty attendance, membership management and an AI assistant, running entirely on the Cloudflare edge.

Note

This is the official platform of the Yali High School Youth League Committee. :)


Table of contents


Overview

The platform replaces the paper forms and group-chat workflows of a Youth League committee office: students report broken facilities, the office publishes announcements, events recruit volunteers, the school votes on proposals, the thousand-seat hall is booked by timeslot, and duty officers sign in and out for attendance scoring.

Version 4.0 was a complete front-end rewrite. The original site was hand-written HTML/CSS/vanilla-JS with no build step. It is now a Vite multi-page application whose UI is built on WinUIonWeb — a Vue 3 port of the WinUI 3 / Fluent Design control set — while the backend (Cloudflare Pages Functions + D1) and every public URL stayed unchanged.

Pages 27 HTML entries at the repository root — 22 application pages, plus 404/410 and 3 redirect stubs
Backend 22 modules · 134 routes on Cloudflare Pages Functions
Database Cloudflare D1 (SQLite) · 27 tables declared + 2 created on demand
Frontend Vue 3.5 SFC + Vite 7 — ~12.4k lines of page code on a 43.9k-line vendored control library
Achievements 36 hidden achievements, detected client-side and verified server-side
Quality 6 build-time guards · 24-page render regression · 303 interaction assertions
What changed in 4.0
  • Every application page now shares one Fluent shell: an adaptive NavigationView that becomes an icon rail on tablets and an overlay drawer on phones.
  • The design tokens moved from a single Material 3 stylesheet to the WinUI theme contract, bridged one-way from the existing --md-* tokens so no second design system was introduced.
  • Access guards, the site-wide dialog system, cookie consent and the class-name prompt were rebuilt as typed modules instead of scattered globals.
  • Six static guards and a two-layer browser test suite were added, because the rewrite's dominant failure mode was silent — pages rendered fine while features did nothing.

Feature modules

Module What it does
Issue reporting Categorised facility reports with photo evidence, status flow (pending → in progress → done), administrator assignment, and a comment thread shared by reporter and handler
Announcements Rich text with inline images, an approval workflow, categories and threaded comments
Activity feed Reverse-chronological timeline, image posts, cursor pagination, comments
Polling Single-choice, multiple-choice and free-text questions in one ballot, image options, anonymous mode, CSV export, anti-abuse captcha
Finance Income/expense ledger, monthly roll-up charts, tag filters, reimbursement workflow, department-level isolation
Hall booking Timeline drag-selection, automatic conflict detection, reviewer approval with a Gantt view of collisions
Duty attendance Two officers per slot, sign-in/sign-out, automatic scoring by duration, 60-day schedule generation, automatic absence marking, CSV exports and a weekly report
Review queue Image and announcement moderation, with rejection reasons surfaced back to the submitter
Membership Six-tier roles, registration approval, three-stage bulk import with concurrent bcrypt hashing, password resets
Notification centre Per-user notifications with unread badges, feature-gated behind an invitation system
AI assistant Streaming chat over SSE with tool calling — queries the site database, searches the web, and remembers long-term preferences
Achievements 36 hidden achievements spanning exploration, interaction, data accumulation and easter eggs
Personalisation Light/dark/system theme, accent colours, font scaling and an optional particle/animation layer
Feedback User suggestions with an administrator inbox
Site operations Maintenance overlay, feature flags, storage statistics, owner-only bulk reset

Duty attendance, in more detail

The most operationally complex module, and a good illustration of the platform's depth:

  • Scheduling — generates 60 working days ahead, skipping weekends, rotating two officers per day and continuing the rotation from the last existing row rather than restarting it.
  • Sign-in enforcement — the server refuses sign-in before the configured slot start time, computed in Beijing time regardless of the runtime's UTC clock.
  • Scoring — sign-out computes elapsed time; anything under two minutes scores -0.5. A period-end sweep marks non-attenders absent and writes -1, de-duplicated against existing score rows so repeated requests cannot charge a student twice.
  • Manual override — administrators can add, modify or cancel score records; cancellation requires re-authenticating with an administrator password and rolls back the attendance row.
  • Weekly report — a single endpoint feeds both the on-screen tables and three CSV exports (weekly roster, weekly deductions, all-time deductions), with an optional AI-written summary.

Architecture

flowchart TB
    subgraph browser["Browser · dist/ · Vite multi-page build"]
        direction TB
        entry["27 HTML entries<br/>repository root, URLs unchanged"]
        pages["Pages · src/pages/<br/>22 application pages + 404/410<br/>plus 3 redirect stubs"]
        comp["Components · src/components/<br/>shell, AI widget, dialogs"]
        bridge["Bridge · src/shared/<br/>api, guard, nav, confirm, ai-chat"]
        legacy["Legacy runtime · public/js/<br/>api.js, captcha.js, modal.js"]
        vendor["Vendored controls · src/winui/<br/>WinUIonWeb, GPL-3.0"]
        entry --> pages --> comp
        pages --> bridge --> legacy
        comp --> vendor
    end

    subgraph edge["Cloudflare edge"]
        direction TB
        fn["Pages Functions · functions/api/<br/>22 modules · 134 routes"]
        utils["_utils.js<br/>JWT · bcrypt · rate limiting · captcha"]
        fn --- utils
    end

    subgraph data["Data and upstream services"]
        d1[("D1 · SQLite<br/>27 + 2 tables")]
        ai["DeepSeek / Workers AI"]
        tavily["Tavily search"]
        ts["Cloudflare Turnstile"]
    end

    bridge -- "fetch /api/*" --> fn
    fn --> d1
    fn --> ai
    fn --> tavily
    fn --> ts
Loading

Two deliberate architectural choices

  1. The legacy layer was kept, not rewritten. public/js/*.js (~10k lines) still owns the network client, the icon set, the self-hosted captcha widget, the achievement engine and the personalisation store. src/shared/api.ts wraps those globals in typed functions. This was the only realistic way to migrate the site's 27 page entries without re-implementing and re-testing 10k lines of behaviour that was already proven in production.

  2. One-way theme bridge. The site already had a complete Material 3 token set under --md-*. Rather than introduce a second design system, a small bridge in src/theme/ mirrors the site's .dark class onto the theme-dark / theme-light classes the Fluent controls expect, and pins the icon font. No token is duplicated.


Tech stack

Layer Choice Notes
Build Vite 7 Multi-page: every root *.html is an entry, hashed assets under assets/
UI framework Vue 3.5 SFC <script setup> with TypeScript
Component library WinUIonWeb Vendored under src/winui/ (GPL-3.0), ~100 controls; the app registry is trimmed to the 25 tags actually used
Design language WinUI 3 / Fluent Adaptive NavigationView, ContentDialog, InfoBadge, Expander …
Runtime Cloudflare Pages Functions Workers runtime, catch-all [[path]].js router
Database Cloudflare D1 SQLite, parameterised queries only
Auth jose JWT in an HttpOnly cookie token_version invalidates sessions on password change
Passwords bcryptjs, 10 rounds Concurrent hashing during bulk import
Captcha Self-hosted SVG captcha HMAC-signed token, 5-minute TTL, confusion-free alphabet
Bot protection Cloudflare Turnstile Optional; the self-hosted captcha is always available
AI OpenAI-compatible API or Workers AI Defaults to DeepSeek; streaming SSE with tool calling

Repository layout

.
├── *.html                       27 page entries (the URL surface), generated shells
├── functions/api/               Cloudflare Pages Functions
│   ├── [[path]].js              catch-all router — the route table lives here
│   ├── _utils.js                JWT, bcrypt, rate limiting, captcha, notifications
│   └── <22 modules>             auth, admin, duty, ai, polls, finance, halls …
├── src/
│   ├── winui/                   vendored WinUIonWeb control library (GPL-3.0)
│   ├── pages/<page>/            one folder per page: App.vue + main.ts
│   ├── components/              site-specific shell and dialogs
│   ├── shared/                  api, guard, nav, confirm, theme, icons, ai-chat
│   └── theme/                   Fluent ⇄ Material token bridge and page styles
├── public/
│   ├── js/                      legacy runtime still in service (~10k lines)
│   ├── css/material/            design tokens and legacy component styles
│   ├── fonts/ icon/ images/     subset icon font, emblems
│   ├── version.js               APP_VERSION / APP_DEPLOYED
│   └── _headers                 CSP, HSTS and cache policy
├── scripts/                     18 build, guard and test scripts
├── schema.sql                   D1 schema (27 tables)
├── vite.config.ts               multi-page config, dev-build define
└── wrangler.toml                Pages + D1 binding

Data model

27 tables are declared in schema.sql; the AI module creates two more on first use.