coursekit-lms 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +258 -2
  4. package/dist/cli/index.js +5170 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/server/index.js +4944 -0
  7. package/dist/server/index.js.map +1 -0
  8. package/dist/types/server/app.d.ts +4 -0
  9. package/dist/types/server/auth/session.d.ts +18 -0
  10. package/dist/types/server/config.d.ts +31 -0
  11. package/dist/types/server/context.d.ts +24 -0
  12. package/dist/types/server/db/index.d.ts +11 -0
  13. package/dist/types/server/db/migrations/001_initial.d.ts +7 -0
  14. package/dist/types/server/db/node-sqlite.d.ts +6 -0
  15. package/dist/types/server/db/schema.d.ts +253 -0
  16. package/dist/types/server/db/types.d.ts +4 -0
  17. package/dist/types/server/index.d.ts +64 -0
  18. package/dist/types/server/lib/events.d.ts +86 -0
  19. package/dist/types/server/lib/http.d.ts +21 -0
  20. package/dist/types/server/lib/password.d.ts +3 -0
  21. package/dist/types/server/lib/schemas.d.ts +23 -0
  22. package/dist/types/server/lib/storage.d.ts +10 -0
  23. package/dist/types/server/lib/util.d.ts +18 -0
  24. package/dist/types/server/paths.d.ts +10 -0
  25. package/dist/types/server/routes/activities.d.ts +3 -0
  26. package/dist/types/server/routes/admin.d.ts +3 -0
  27. package/dist/types/server/routes/auth.d.ts +3 -0
  28. package/dist/types/server/routes/categories.d.ts +3 -0
  29. package/dist/types/server/routes/content.d.ts +4 -0
  30. package/dist/types/server/routes/courses.d.ts +5 -0
  31. package/dist/types/server/routes/files.d.ts +3 -0
  32. package/dist/types/server/routes/forums.d.ts +3 -0
  33. package/dist/types/server/routes/grades.d.ts +3 -0
  34. package/dist/types/server/routes/me.d.ts +3 -0
  35. package/dist/types/server/routes/quizzes.d.ts +3 -0
  36. package/dist/types/server/seed/demo.d.ts +19 -0
  37. package/dist/types/server/services/access.d.ts +24 -0
  38. package/dist/types/server/services/activity-types.d.ts +20 -0
  39. package/dist/types/server/services/courses.d.ts +7 -0
  40. package/dist/types/server/services/grades.d.ts +11 -0
  41. package/dist/types/server/services/notify.d.ts +10 -0
  42. package/dist/types/server/services/progress.d.ts +9 -0
  43. package/dist/types/server/services/quiz.d.ts +28 -0
  44. package/dist/types/server/services/serialize.d.ts +13 -0
  45. package/dist/types/server/services/settings.d.ts +5 -0
  46. package/dist/types/server/services/users.d.ts +15 -0
  47. package/dist/types/shared/constants.d.ts +11 -0
  48. package/dist/types/shared/permissions.d.ts +13 -0
  49. package/dist/types/shared/types.d.ts +452 -0
  50. package/dist/web/assets/ActivityEditor-BVSZUV8l.js +3 -0
  51. package/dist/web/assets/ActivityPage-DPmSV_mU.js +1 -0
  52. package/dist/web/assets/AdminCoursesPage-uaSHNtzf.js +1 -0
  53. package/dist/web/assets/AdminLayout-DqoShZGn.js +1 -0
  54. package/dist/web/assets/AdminOverviewPage-DnTrdGbr.js +1 -0
  55. package/dist/web/assets/AdminSettingsPage-B82cX8xU.js +1 -0
  56. package/dist/web/assets/AdminUsersPage-3d2F9AEl.js +1 -0
  57. package/dist/web/assets/AnnouncementsPage-BKW30k0Z.js +1 -0
  58. package/dist/web/assets/CalendarPage-CLRWyTNT.js +1 -0
  59. package/dist/web/assets/CatalogPage-BiMgSSBR.js +1 -0
  60. package/dist/web/assets/CourseContentPage-BIDH0UbG.js +1 -0
  61. package/dist/web/assets/CourseLayout-ql01LEmj.js +1 -0
  62. package/dist/web/assets/CourseSettingsPage-CReoPqOa.js +1 -0
  63. package/dist/web/assets/CreateCoursePage-DFCHlq5M.js +1 -0
  64. package/dist/web/assets/DiscussionPage-CWwVpFQV.js +1 -0
  65. package/dist/web/assets/GradesPage-Bu5vphcG.js +1 -0
  66. package/dist/web/assets/MyCoursesPage-Dd-Oaygv.js +1 -0
  67. package/dist/web/assets/NotFoundPage-BRquC7-l.js +1 -0
  68. package/dist/web/assets/NotificationsPage-LJvqb6Dj.js +1 -0
  69. package/dist/web/assets/ParticipantsPage-wFxiphna.js +1 -0
  70. package/dist/web/assets/ProfilePage-CzfhacAX.js +1 -0
  71. package/dist/web/assets/QuizAttemptPage-CEAV6wAL.js +1 -0
  72. package/dist/web/assets/QuizEditorPage-DS_czQVM.js +3 -0
  73. package/dist/web/assets/SubmissionsPage-CQjcx09G.js +1 -0
  74. package/dist/web/assets/arrow-up-LHDup5m4.js +1 -0
  75. package/dist/web/assets/ban-D3Vsxg_g.js +1 -0
  76. package/dist/web/assets/chevron-left-D6IMQD6N.js +1 -0
  77. package/dist/web/assets/constants-DLDWTvvN.js +1 -0
  78. package/dist/web/assets/context-BLVW7NB7.js +1 -0
  79. package/dist/web/assets/copy-Bxxjq6zo.js +1 -0
  80. package/dist/web/assets/ellipsis-c2POIN-Y.js +1 -0
  81. package/dist/web/assets/frame-CGabirLa.js +1 -0
  82. package/dist/web/assets/hooks-BBARn-DA.js +1 -0
  83. package/dist/web/assets/index-B29bTBiJ.js +50 -0
  84. package/dist/web/assets/index-WxCvsbJq.css +2 -0
  85. package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  86. package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  87. package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  88. package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  89. package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  90. package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  91. package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  92. package/dist/web/assets/key-round-B_KI-brR.js +1 -0
  93. package/dist/web/assets/library-3WG9oLCb.js +1 -0
  94. package/dist/web/assets/lock-BjbqwA_0.js +1 -0
  95. package/dist/web/assets/markdown-ykrkPMbn.js +83 -0
  96. package/dist/web/assets/message-square-text-fe24gbEU.js +1 -0
  97. package/dist/web/assets/misc-DvgDEI3I.js +1 -0
  98. package/dist/web/assets/pencil-p0GQmIMo.js +1 -0
  99. package/dist/web/assets/pin-DlYC3uec.js +1 -0
  100. package/dist/web/assets/send-mxSHcdcD.js +1 -0
  101. package/dist/web/assets/settings-DRKWzSHN.js +1 -0
  102. package/dist/web/assets/trophy-Cch2iF1m.js +1 -0
  103. package/dist/web/favicon.svg +12 -0
  104. package/dist/web/index.html +26 -0
  105. package/package.json +108 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ Fixes found while verifying the first release from the npm registry.
6
+
7
+ - **Stale tabs after an upgrade.** Requests for files that don't exist (such as page files from an older build) now get a 404 instead of the app page, and a tab opened before an upgrade reloads to pick up the new build instead of failing to open pages. It reloads at most once per build and three times in five minutes, so a file that is really missing shows the error screen (with a Reload button) rather than reloading over and over.
8
+ - **CommonJS.** `require('coursekit-lms')` now works on every supported Node version, 22.13+ (the package `exports` map has a `default` condition). It returns the same module as `import`.
9
+ - **TypeScript.** The published declarations now reference Node's types themselves, so they work even when `node` isn't listed in `"types"` (TypeScript 7's default is `[]`). Optional options accept an explicit `undefined`, so code like `databaseUrl: process.env.DATABASE_URL` compiles under `exactOptionalPropertyTypes`. The types the programmatic API uses are exported too: `CreateUserInput`, `SeedDemoOptions`, `SeedDemoResult`, `AppEnv`, `AppDeps`, `DB` and `DatabaseKind`. The declarations no longer import `kysely/migration`, which TypeScript's older `node10` module resolution (the default for `"module": "commonjs"` in TypeScript 5) can't find.
10
+ - **`createUser()` no longer returns the password hash.** The programmatic `lms.createUser()` now returns the public user (the same shape the API uses). The HTTP API never exposed it.
11
+ - Added `npm run check:package`, which loads the built package with `require()` and `import()` and type-checks consumer code against it, in CI and before publishing.
12
+
13
+ ## 0.1.0
14
+
15
+ First release: courses, lessons, resources, assignments, auto-graded quizzes, forums, gradebook, announcements, notifications, calendar and administration, with SQLite or PostgreSQL, a CLI and a programmatic API.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Coursekit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,259 @@
1
- # Temporary Holding Version
1
+ # Coursekit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/Donsimeone2206/coursekit/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Donsimeone2206/coursekit/actions/workflows/ci.yml)
4
+
5
+ **An open-source learning management system for Node.js.** Courses, lessons, assignments, auto-graded quizzes, forums and a gradebook, with a fast, modern interface. Think Moodle, rebuilt for today's web.
6
+
7
+ ```bash
8
+ npx coursekit-lms start
9
+ ```
10
+
11
+ Open http://localhost:3000 and the setup wizard walks you through creating your site, with optional demo content.
12
+
13
+ ![Dashboard](docs/screenshots/dashboard.jpg)
14
+
15
+ | Course page | Gradebook | Dark mode |
16
+ | ------------------------------------------- | -------------------------------------------- | -------------------------------------------- |
17
+ | ![Course page](docs/screenshots/course.jpg) | ![Gradebook](docs/screenshots/gradebook.jpg) | ![Dark mode](docs/screenshots/dark-mode.jpg) |
18
+
19
+ ## Features
20
+
21
+ **Teaching and learning**
22
+
23
+ - Courses organised into sections (weeks, topics or modules), with drafts, publishing and archiving
24
+ - Five activity types: **lessons** (Markdown with video embeds), **resources** (files or links), **assignments**, **quizzes** and **forums**
25
+ - Completion tracking (manual or automatic) with progress per section and per course
26
+ - Course catalog with categories, search, open enrolment, enrolment keys or invite-only courses
27
+ - Edit mode for teachers: add, reorder, move, hide and delete activities without leaving the course page
28
+
29
+ **Assessment**
30
+
31
+ - Assignments with online text and file submissions, due dates, late flags and a side-by-side grading workspace
32
+ - Quizzes with single and multiple choice, true/false, short answer (with wildcards) and numerical questions
33
+ - Time limits, attempt limits, highest/last/average grading, pass marks, shuffling and configurable review
34
+ - Gradebook with inline editing, feedback, class averages and CSV export; students see their own grades
35
+
36
+ **Community**
37
+
38
+ - Threaded forums with pinning, locking and moderation
39
+ - Course announcements, in-app notifications and a calendar with due dates and events
40
+
41
+ **Administration**
42
+
43
+ - People management with site roles, suspension and **"Log in as"** for support
44
+ - Categories, branding (site name, tagline, brand colour) and self-registration control
45
+ - Moodle-style capabilities per course role (teacher, teaching assistant, student)
46
+
47
+ **Platform**
48
+
49
+ - Zero-config SQLite via Node's built-in `node:sqlite` (no native modules to compile), or **PostgreSQL** for larger sites
50
+ - One npm package: CLI, REST API and a prebuilt web UI. Embed it in your own Node app if you like
51
+ - Typed event hooks for integrations (webhooks, analytics, email)
52
+ - Light and dark themes, responsive down to phones, keyboard shortcuts (`⌘K` / `Ctrl+K` search)
53
+
54
+ ## Getting started
55
+
56
+ ### Run it
57
+
58
+ Requires Node.js 22.13 or newer. The npm package is called `coursekit-lms`; once it's installed, the command is `coursekit`.
59
+
60
+ ```bash
61
+ npx coursekit-lms start
62
+ ```
63
+
64
+ Data (the SQLite database and uploads) is stored in `./data`. The first visit shows a setup wizard that creates the administrator account and can load demo content.
65
+
66
+ ### Create a site folder
67
+
68
+ ```bash
69
+ npx coursekit-lms init my-school --demo
70
+ cd my-school
71
+ npm install
72
+ npm start
73
+ ```
74
+
75
+ `init` creates a `package.json`, `.env` and data folder, then asks for the administrator's details (or pass `--email`, `--name` and `--password`).
76
+
77
+ ### Try the demo
78
+
79
+ ```bash
80
+ npx coursekit-lms seed --demo
81
+ ```
82
+
83
+ This adds six courses, two teachers, a teaching assistant and twelve students with submissions, quiz attempts, grades and forum threads. Every demo account uses the password `coursekit`. It is meant for local evaluation only, so don't load it on a public site.
84
+
85
+ | Account | Role |
86
+ | ----------------------------- | ------------------ |
87
+ | `admin@coursekit.test` | Administrator |
88
+ | `maya.chen@coursekit.test` | Instructor |
89
+ | `priya.raman@coursekit.test` | Teaching assistant |
90
+ | `alex.johnson@coursekit.test` | Student |
91
+
92
+ ## Configuration
93
+
94
+ Set these as environment variables or in a `.env` file next to where you run Coursekit.
95
+
96
+ | Variable | Default | Description |
97
+ | ------------------------- | ------------------------------ | ----------------------------------------------------------------- |
98
+ | `PORT` | `3000` | Port to listen on |
99
+ | `HOST` | `0.0.0.0` | Interface to bind |
100
+ | `DATABASE_URL` | `sqlite://./data/coursekit.db` | `sqlite://path/to/file.db` or `postgres://user:pass@host:5432/db` |
101
+ | `COURSEKIT_DATA_DIR` | `./data` | Uploaded files (and the default SQLite database) |
102
+ | `COURSEKIT_PUBLIC_URL` | (none) | Public URL; an `https://` URL turns on secure cookies |
103
+ | `COURSEKIT_MAX_UPLOAD_MB` | `50` | Maximum upload size |
104
+
105
+ The same options are available as CLI flags: `coursekit start --port 8080 --database-url postgres://...`.
106
+
107
+ ### PostgreSQL
108
+
109
+ Install the `pg` driver next to Coursekit, for example in a folder created with `coursekit init`:
110
+
111
+ ```bash
112
+ npm install pg
113
+ DATABASE_URL=postgres://user:password@localhost:5432/coursekit npm start
114
+ ```
115
+
116
+ Migrations run automatically on start (or explicitly with `coursekit migrate`). The schema only uses portable column types, so the same migrations run on SQLite and PostgreSQL.
117
+
118
+ ### Production checklist
119
+
120
+ - Put Coursekit behind a reverse proxy with HTTPS and set `COURSEKIT_PUBLIC_URL=https://...` so session cookies are marked `Secure`
121
+ - Back up the data folder (SQLite database and uploads), or your PostgreSQL database plus the uploads folder
122
+ - Keep self-registration off if your site is private (Administration → Site settings)
123
+
124
+ ## Use it as a library
125
+
126
+ Coursekit exports a programmatic API, so you can run it inside your own server, react to events or seed data from scripts. It is an ES module, and CommonJS code can `require('coursekit-lms')` too. Type definitions are included; TypeScript projects also need `@types/node`, which most Node projects already have. With TypeScript 5, `"module": "commonjs"` and `skipLibCheck` off, also set `esModuleInterop` (for zod's type definitions, which Coursekit's types use) and a `target` of ES2022 or newer (for kysely's).
127
+
128
+ ```ts
129
+ import { createCoursekit } from 'coursekit-lms';
130
+
131
+ const lms = await createCoursekit({
132
+ databaseUrl: process.env.DATABASE_URL,
133
+ publicUrl: 'https://learn.example.com',
134
+ });
135
+
136
+ // React to what happens in the LMS
137
+ lms.events.on('grade.updated', ({ userId, activityId, score }) => {
138
+ console.log(`User ${userId} scored ${score} on ${activityId}`);
139
+ });
140
+ lms.events.onAny((event, payload) => forwardToWebhook(event, payload));
141
+
142
+ await lms.listen(3000);
143
+ ```
144
+
145
+ Mount it in an existing app instead of calling `listen()`:
146
+
147
+ ```ts
148
+ // Express / Fastify / node:http
149
+ app.use(lms.handler);
150
+
151
+ // Hono
152
+ app.route('/', lms.app);
153
+
154
+ // Web-standard runtimes and tests
155
+ const response = await lms.fetch(new Request('http://localhost/api/health'));
156
+ ```
157
+
158
+ Coursekit expects to own the root path of its (sub)domain, e.g. `learn.example.com`.
159
+
160
+ **Events:** `user.created`, `user.login`, `course.created`, `course.updated`, `course.deleted`, `enrolment.created`, `enrolment.deleted`, `activity.created`, `activity.completed`, `submission.submitted`, `grade.updated`, `quiz.attempt.finished`, `forum.post.created`, `announcement.created`.
161
+
162
+ **File storage:** uploads go to `<dataDir>/uploads` by default. Pass `storage` with your own `put`/`get`/`delete` implementation to use S3, R2 or similar.
163
+
164
+ See [docs/api.md](docs/api.md) for the REST API.
165
+
166
+ ## Roles and permissions
167
+
168
+ Site roles decide what someone can do across the site; course roles decide what they can do inside a course.
169
+
170
+ | Site role | Can |
171
+ | ------------- | ------------------------------------------ |
172
+ | Administrator | Everything, in every course |
173
+ | Instructor | Create courses (and becomes their teacher) |
174
+ | Student | Enrol in courses |
175
+
176
+ | Capability | Teacher | Teaching assistant | Student |
177
+ | ----------------------------------- | :-----: | :----------------: | :-----: |
178
+ | View course, post in forums | ✓ | ✓ | ✓ |
179
+ | See hidden activities | ✓ | ✓ | |
180
+ | Edit content and settings | ✓ | | |
181
+ | Manage participants | ✓ | | |
182
+ | View and edit all grades | ✓ | ✓ | |
183
+ | Moderate forums, post announcements | ✓ | ✓ | |
184
+ | Submit assignments | | | ✓ |
185
+
186
+ Capabilities live in [`src/shared/permissions.ts`](src/shared/permissions.ts). The server enforces them and the UI reads the same table.
187
+
188
+ ## Development
189
+
190
+ ```bash
191
+ git clone <your fork>
192
+ cd coursekit
193
+ npm install
194
+ npm run dev # API on :3000 (tsx watch) + web UI on :5173 (Vite)
195
+ ```
196
+
197
+ Open http://localhost:5173. Run `npm run seed` first if you want demo data.
198
+
199
+ | Script | What it does |
200
+ | ------------------- | --------------------------------------------------------------- |
201
+ | `npm run dev` | API and web UI with live reload |
202
+ | `npm test` | API and grading tests (Vitest, in-memory SQLite) |
203
+ | `npm run typecheck` | Type-check server and web UI |
204
+ | `npm run build` | Build the web UI, bundle server and CLI, emit type declarations |
205
+ | `npm run format` | Format with Prettier |
206
+ | `npm start` | Run the built package |
207
+
208
+ ### Stack
209
+
210
+ - **Server:** [Hono](https://hono.dev) on Node, [Kysely](https://kysely.dev) query builder, [Zod](https://zod.dev) validation, scrypt password hashing, database-backed sessions
211
+ - **Web UI:** React 19, React Router, TanStack Query, Tailwind CSS v4, Radix UI primitives, Lucide icons
212
+ - **Tooling:** TypeScript, Vite, tsup, Vitest, Prettier
213
+
214
+ ### Project layout
215
+
216
+ ```
217
+ src/
218
+ shared/ Types, permissions and constants used by server and UI
219
+ server/
220
+ db/ Kysely setup, node:sqlite adapter, migrations
221
+ routes/ REST API (auth, admin, courses, content, activities, quizzes, forums, grades, files, me)
222
+ services/ Access control, progress, grading, quiz engine, notifications
223
+ seed/ Demo content
224
+ index.ts createCoursekit() programmatic API
225
+ cli/ The `coursekit` command
226
+ web/
227
+ components/ UI kit (buttons, dialogs, menus…) and app shell
228
+ pages/ Dashboard, catalog, course, activities, admin…
229
+ test/ API integration tests
230
+ ```
231
+
232
+ ## Security
233
+
234
+ - Passwords are hashed with scrypt; session tokens are random 256-bit values stored only as SHA-256 hashes
235
+ - Cookies are `HttpOnly` and `SameSite=Lax`; cross-site form posts are rejected by CSRF protection
236
+ - Every API route checks course capabilities on the server; hidden content and drafts are invisible to students
237
+ - Uploaded files are only served to people allowed to see them, with `nosniff`, and anything that could execute in a browser (HTML, SVG…) is served as a download
238
+ - Markdown is sanitised with DOMPurify before rendering; links in resources must be `http(s)`
239
+ - Credential endpoints are rate limited
240
+
241
+ Please report vulnerabilities privately to the maintainers rather than opening a public issue.
242
+
243
+ ## Roadmap
244
+
245
+ Coursekit covers the core of an LMS today. Things on the list:
246
+
247
+ - Email notifications and digests
248
+ - Groups/cohorts, course completion certificates and badges
249
+ - Question banks, more question types (essay, matching, ordering) and grade categories/weights
250
+ - LTI 1.3 and SCORM/xAPI packages
251
+ - Internationalisation
252
+ - Pluggable activity types in the web UI (the server-side registry is in `src/server/services/activity-types.ts`)
253
+ - S3-compatible storage adapter, Docker image
254
+
255
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
256
+
257
+ ## License
258
+
259
+ [MIT](LICENSE)