diff --git a/content/cli/commands.mdx b/content/cli/commands.mdx index 8683114..716785a 100644 --- a/content/cli/commands.mdx +++ b/content/cli/commands.mdx @@ -78,8 +78,8 @@ Backups are saved to `{installDir}/backups/learnhouse-backup-{timestamp}.tar.gz` Restore a database from a backup archive. This overwrites the current database. ```bash -npx learnhouse backup --restore npx learnhouse restore +npx learnhouse backup --restore ``` @@ -96,7 +96,7 @@ npx learnhouse deployments Features: - List all LearnHouse deployments with container status -- Scale resource limits (memory) for `learnhouse-app`, `db`, and `redis` +- Scale memory limits for `learnhouse-app`, `db`, and `redis` - View current resource usage via `docker stats` ## `shell` @@ -117,7 +117,7 @@ Interactive environment variable editor. Edit variables by category: - Database & Redis - Security - AI -- Email +- Email (Resend only — edit `.env` directly to set SMTP credentials) - S3 Storage - OAuth @@ -147,4 +147,29 @@ npx learnhouse dev | Flag | Description | | --- | --- | -| `--ee` | Enable Enterprise Edition features | +| `--ee` | Enable Enterprise Edition features (keeps the `ee/` folder active) | +| `--admin-email ` | Admin email (default: `admin@school.dev`) | +| `--admin-password ` | Admin password (skips the interactive prompt) | + +## `update` + +Update LearnHouse to the latest release or a specific version. See [Updates](/self-hosting/maintenance/updates) for details. + +```bash +npx learnhouse update +npx learnhouse update --version 1.4.2 +``` + +| Flag | Description | +| --- | --- | +| `--version ` | Pull a specific image tag from `ghcr.io/learnhouse/app` | +| `--migrate` | Run database migrations without prompting | +| `--no-migrate` | Skip database migrations without prompting | + +## `status` + +Show the status of each LearnHouse service. + +```bash +npx learnhouse status +``` diff --git a/content/cli/dev-mode.mdx b/content/cli/dev-mode.mdx index cb7380b..0329110 100644 --- a/content/cli/dev-mode.mdx +++ b/content/cli/dev-mode.mdx @@ -21,14 +21,16 @@ The command splits infrastructure and application services: - [bun](https://bun.sh/) (for web and collab dependencies) - [uv](https://docs.astral.sh/uv/) (for Python API dependencies) -The CLI auto-installs dependencies (`bun install`, `uv sync`) if `node_modules` or `.venv` are missing. + +`bun` and `uv` must be installed beforehand. The CLI runs `bun install` and `uv sync` to install project dependencies, but it does not install the package managers themselves. + ## Startup Flow 1. **Detect project root** — Looks for the monorepo structure (`apps/api`, `apps/web`, `apps/collab`) 2. **Start infrastructure** — Launches PostgreSQL and Redis containers (reuses existing ones if running) 3. **Health checks** — Waits for database and Redis to be ready -4. **Admin setup** — On first run, prompts for admin email and password. Credentials are saved and reused on subsequent runs. +4. **Admin setup** — When the database and Redis containers are created for the first time, prompts for an admin email and password. On subsequent runs with existing containers, the prompt is skipped and the existing credentials remain valid. You can also pass `--admin-email` and `--admin-password` to skip the prompt. 5. **Install dependencies** — Runs `bun install` and `uv sync` if needed 6. **Start services** — Launches API, Web, and Collab with color-coded output diff --git a/content/cli/setup-wizard.mdx b/content/cli/setup-wizard.mdx index 8bab7cc..1d28108 100644 --- a/content/cli/setup-wizard.mdx +++ b/content/cli/setup-wizard.mdx @@ -29,8 +29,7 @@ Choose local Docker containers or connect to external services. ### PostgreSQL - **Local Docker** (recommended): - - **AI-enabled** (recommended) — Uses `pgvector/pgvector:pg16` for RAG and vector search features - - **Standard** — Uses `postgres:16-alpine`, lighter footprint + - Uses `pgvector/pgvector:pg16` (PostgreSQL 16 with the pgvector extension, used for AI/RAG features when enabled) - Password is auto-generated - **External** — Provide a connection string (`postgresql://user:pass@host:5432/db`). The wizard tests connectivity before proceeding. @@ -88,8 +87,8 @@ Each deployment gets a unique 8-character ID for container and network isolation | Service | Image | Purpose | | --- | --- | --- | -| `learnhouse-app-{id}` | `ghcr.io/learnhouse/app` | Next.js + FastAPI application | -| `learnhouse-db-{id}` | `pgvector:pg16` or `postgres:16-alpine` | PostgreSQL database | +| `learnhouse-app-{id}` | `ghcr.io/learnhouse/app:latest` (or `:dev`) | Next.js + FastAPI application | +| `learnhouse-db-{id}` | `pgvector/pgvector:pg16` | PostgreSQL database | | `learnhouse-redis-{id}` | `redis:7.2.3-alpine` | Redis cache | | `learnhouse-caddy-{id}` | `caddy:2-alpine` | Reverse proxy with auto-SSL | | `learnhouse-nginx-{id}` | `nginx:alpine` | Reverse proxy (no auto-SSL) | @@ -102,6 +101,7 @@ The wizard optionally starts the deployment and waits up to 3 minutes for the he During setup you choose a release channel: -- **Stable** — Recommended for production -- **Dev** — Bleeding edge, latest features -- **Custom** — Specify an exact image tag +- **Stable** — Recommended for production (pulls `ghcr.io/learnhouse/app:latest`) +- **Dev** — Bleeding edge, latest features (pulls `ghcr.io/learnhouse/app:dev`) + +To pin to a specific image tag after setup, use `learnhouse update --version `. diff --git a/content/developers/api/authentication.mdx b/content/developers/api/authentication.mdx index 18f58e7..6670e07 100644 --- a/content/developers/api/authentication.mdx +++ b/content/developers/api/authentication.mdx @@ -6,22 +6,26 @@ The LearnHouse API supports **JWT cookies** for browser sessions and **API token ## JWT Authentication -Login to receive a JWT access token (HS256, expires in 8 hours): +The login endpoint accepts `application/x-www-form-urlencoded` data with `username` (the user's email) and `password` fields, and returns a JWT access token (HS256, expires in 8 hours): ```bash curl -X POST http://localhost:1338/api/v1/auth/login \ - -H "Content-Type: application/json" \ - -d '{"email": "you@example.com", "password": "your-password"}' + -F 'username=you@example.com' \ + -F 'password=your-password' ``` Then authenticate requests via the `Authorization` header: ```bash -curl http://localhost:1338/api/v1/users/me \ +curl http://localhost:1338/api/v1/users/profile \ -H "Authorization: Bearer " ``` -The token is also set as an `access_token_cookie` for browser-based sessions. Use `/api/v1/auth/refresh` to renew expired tokens within the 30-day refresh window. +The token is also set as an `access_token_cookie` for browser-based sessions. Use `GET /api/v1/auth/refresh` to renew expired tokens within the 30-day refresh window. + + +Logins are rate-limited by IP, and repeated failed attempts temporarily lock the account. SaaS deployments also require `email_verified=true` before login succeeds. + ## API Tokens @@ -32,7 +36,7 @@ API tokens are available on the **Pro plan**. Create and manage them in organiza For programmatic access, use API tokens (prefixed with `lh_`): ```bash -curl http://localhost:1338/api/v1/users/me \ +curl http://localhost:1338/api/v1/users/profile \ -H "Authorization: Bearer lh_your_api_token_here" ``` @@ -40,8 +44,9 @@ curl http://localhost:1338/api/v1/users/me \ | Method | Endpoint | Description | | --- | --- | --- | -| `POST` | `/api/v1/auth/login` | Login and receive a JWT | +| `POST` | `/api/v1/auth/login` | Login with form-encoded `username` + `password` | | `GET` | `/api/v1/auth/refresh` | Refresh an expired token | | `DELETE` | `/api/v1/auth/logout` | Invalidate the session | | `POST` | `/api/v1/auth/oauth` | Google OAuth login | | `POST` | `/api/v1/auth/verify-email` | Verify email address | +| `POST` | `/api/v1/auth/resend-verification` | Resend a verification email | diff --git a/content/developers/api/endpoints.mdx b/content/developers/api/endpoints.mdx index 7cc8cdf..bc15ea4 100644 --- a/content/developers/api/endpoints.mdx +++ b/content/developers/api/endpoints.mdx @@ -2,7 +2,7 @@ import { Callout } from 'nextra/components' # API Endpoints -This page provides an overview of all API endpoint groups available in LearnHouse. All endpoints are prefixed with `/api/v1/`. For the full interactive reference with request and response schemas, visit the Swagger UI at `/docs` on a development instance. +This page provides an overview of the API endpoint groups available in LearnHouse. All endpoints are prefixed with `/api/v1/`. For the full interactive reference with request and response schemas, visit the Swagger UI at `/docs` on a development instance. The complete, interactive API documentation is available at [http://localhost:1338/docs](http://localhost:1338/docs) in development mode only. It includes every endpoint, parameter, and response schema. @@ -15,10 +15,10 @@ The complete, interactive API documentation is available at [http://localhost:13 Login, logout, token refresh, OAuth, and email verification. ```bash -# Login +# Login (form-encoded, not JSON) curl -X POST http://localhost:1338/api/v1/auth/login \ - -H "Content-Type: application/json" \ - -d '{"email": "user@example.com", "password": "password"}' + -F 'username=user@example.com' \ + -F 'password=password' ``` See [Authentication](/developers/api/authentication) for full details. @@ -29,7 +29,7 @@ User CRUD, profile management, session info, and password reset. ```bash # Get current user profile -curl http://localhost:1338/api/v1/users/me \ +curl http://localhost:1338/api/v1/users/profile \ -H "Authorization: Bearer " ``` @@ -38,8 +38,8 @@ curl http://localhost:1338/api/v1/users/me \ Organization CRUD, user management, roles, invites, configuration, SEO settings, branding, API tokens, and custom domains. ```bash -# Get organization details -curl http://localhost:1338/api/v1/orgs/{org_slug} \ +# Get organization details by slug +curl http://localhost:1338/api/v1/orgs/slug/{org_slug} \ -H "Authorization: Bearer " ``` @@ -48,81 +48,56 @@ curl http://localhost:1338/api/v1/orgs/{org_slug} \ Course CRUD, cloning, export/import, and contributor management. ```bash -# List courses in an organization -curl http://localhost:1338/api/v1/courses \ +# List courses in an organization (paginated) +curl "http://localhost:1338/api/v1/courses/org_slug/{org_slug}/page/1/limit/20" \ -H "Authorization: Bearer " -# Create a new course -curl -X POST http://localhost:1338/api/v1/courses \ +# Create a new course (multipart form data) +curl -X POST "http://localhost:1338/api/v1/courses/?org_id=1" \ -H "Authorization: Bearer " \ - -H "Content-Type: application/json" \ - -d '{ - "name": "Introduction to Python", - "description": "A beginner-friendly Python course" - }' + -F 'name=Introduction to Python' \ + -F 'description=A beginner-friendly Python course' \ + -F 'public=false' \ + -F 'about=...' ``` ### Chapters Chapter CRUD and ordering within courses. -```bash -# List chapters in a course -curl http://localhost:1338/api/v1/chapters \ - -H "Authorization: Bearer " -``` - ### Activities -Activity CRUD -- individual content units within chapters (pages, videos, documents). - -```bash -# Get activities -curl http://localhost:1338/api/v1/activities \ - -H "Authorization: Bearer " -``` +Activity CRUD — individual content units within chapters. Activity types include dynamic pages, videos, documents, assignments, custom, and SCORM (1.2 and 2004). ### Blocks -Block CRUD -- content blocks within activities. +Block CRUD — content blocks within dynamic page activities. ### Collections Collections group related courses together for organization and discovery. -```bash -# List collections -curl http://localhost:1338/api/v1/collections \ - -H "Authorization: Bearer " -``` - ### Assignments -Assignment CRUD for course assessments. +Assignment CRUD for course assessments. Task types include file submissions, quizzes, and custom (`OTHER`) tasks. ### AI -AI-powered features including an assistant, magic blocks, course planning, and RAG (Retrieval-Augmented Generation). +AI-powered features including the course assistant, magic blocks, course planning, and RAG (Retrieval-Augmented Generation). All AI features are powered by Google Gemini. -```bash -# AI endpoints vary by configuration -curl http://localhost:1338/api/v1/ai/chat \ - -H "Authorization: Bearer " \ - -H "Content-Type: application/json" \ - -d '{"message": "Explain this concept"}' -``` +Routes live under `/api/v1/ai/` and include streaming endpoints such as `POST /api/v1/ai/stream/editor/message`. Refer to `/docs` for the full list. ### Analytics -Course analytics and usage tracking. +Course analytics and usage tracking (backed by Tinybird with a Redis cache layer). ### Search -Full-text search across courses and content. +Full-text search across courses and content. Results are paginated with a default page size of 10 and a maximum of 50 per page. ### Code Execution -Code execution endpoints powered by Judge0. +Code execution endpoints powered by Judge0 (used by the Code Playground editor block). ### Learning Trails @@ -140,7 +115,7 @@ Community forums for organizations. ### Discussions -Discussion threads within communities. +Discussion threads within communities, including pinning, locking, labels, votes, and reactions. ### User Groups @@ -154,15 +129,15 @@ Certificate generation and management for course completion. ### Boards -Collaborative whiteboards for interactive learning. +Real-time collaborative canvases (Miro/FigJam-style), powered by Yjs and Hocuspocus. ### Playgrounds -AI-generated interactive elements for hands-on learning. +AI-generated interactive HTML playgrounds (separate from the Judge0-powered Code Playground editor block). ### Podcasts -Podcast and episode CRUD for audio content delivery. +Podcast and episode CRUD for audio content delivery, exposing a standard RSS feed for manual submission to directories like Apple Podcasts and Spotify. ## Infrastructure Endpoints @@ -177,6 +152,7 @@ Podcast and episode CRUD for audio content delivery. - All endpoints are prefixed with `/api/v1/`. - Resources follow standard REST conventions: `GET` to list or retrieve, `POST` to create, `PUT` to update, `DELETE` to remove. +- Create/update endpoints commonly accept **multipart form data** rather than JSON, since many also accept file uploads (e.g. thumbnails, avatars). - Authenticated endpoints require either the `Authorization: Bearer ` header or the `access_token_cookie` cookie. - Programmatic access uses API tokens with the `lh_` prefix (Pro plan). - Responses are returned as JSON. diff --git a/content/developers/architecture/backend.mdx b/content/developers/architecture/backend.mdx index 8db468f..db42acb 100644 --- a/content/developers/architecture/backend.mdx +++ b/content/developers/architecture/backend.mdx @@ -6,13 +6,13 @@ The LearnHouse backend is a **FastAPI** application written in Python, located a ## Technology Stack -- **FastAPI** >= 0.135.1 -- High-performance Python web framework -- **Python 3.14.3** -- **SQLModel** >= 0.0.37 -- ORM for database interactions (built on SQLAlchemy and Pydantic) +- **FastAPI** 0.135.3 -- High-performance Python web framework +- **Python 3.14** +- **SQLModel** 0.0.38 -- ORM for database interactions (built on SQLAlchemy and Pydantic) - **Alembic** -- Database migration management - **PostgreSQL 16** with **pgvector** extension -- Primary relational database -- **Redis** >= 7.2.1 -- Caching layer and session storage -- **Uvicorn** 0.41.0 -- ASGI server +- **redis-py** 7.4.0 -- Python Redis client +- **Uvicorn** 0.44.0 -- ASGI server - **uv** -- Python package manager ## Key Dependencies @@ -20,7 +20,7 @@ The LearnHouse backend is a **FastAPI** application written in Python, located a - **psycopg2-binary** -- PostgreSQL adapter - **pyjwt[crypto]** -- JWT token handling - **pwdlib[argon2]** -- Password hashing with Argon2 -- **google-genai** >= 1.65.0 -- Gemini AI integration +- **google-genai** 1.71.0 -- Gemini AI integration (the only AI provider) - **llama-index-core + pgvector** -- RAG and vector embeddings - **stripe** -- Payment processing - **workos** -- Enterprise SSO @@ -89,8 +89,8 @@ apps/api/ The backend runs on **port 1338** by default during local development (configurable via `LEARNHOUSE_PORT`). In production Docker deployments, it runs on port 9000. Install dependencies and run the server: ```bash -uv sync # install dependencies -uv run uvicorn # start the dev server +uv sync # install dependencies +uv run python app.py # start the dev server (which calls uvicorn internally) ``` When using the LearnHouse CLI (`learnhouse dev`), the backend starts automatically with hot reload enabled. diff --git a/content/developers/architecture/frontend.mdx b/content/developers/architecture/frontend.mdx index 23470f9..8480e44 100644 --- a/content/developers/architecture/frontend.mdx +++ b/content/developers/architecture/frontend.mdx @@ -4,9 +4,9 @@ The LearnHouse frontend is a **Next.js 16** application located at `apps/web` in ## Technology Stack -- **Next.js 16.1.6** with the App Router (standalone output) -- **React 19.2.4** with Server Components -- **TypeScript 5.9.3** +- **Next.js 16.2.3** with the App Router (standalone output) +- **React 19.2.5** with Server Components +- **TypeScript 6.0.2** - **TailwindCSS v4** for styling - **Bun** as the package manager - **Turbopack** for development builds (`next dev --turbopack`) @@ -51,11 +51,15 @@ The frontend communicates with the FastAPI backend over HTTP. API calls are made ``` apps/web/ -├── app/ # App Router pages and layouts -├── components/ # Reusable UI components -├── services/ # API client and service functions -├── store/ # Client-side state management -└── public/ # Static assets +├── app/ # App Router pages and layouts +├── components/ # Reusable UI components +├── services/ # API client and service functions +├── hooks/ # Shared React hooks +├── lib/ # Utilities and client helpers +├── locales/ # i18next translation resources +├── styles/ # Global styles +├── ee/ # Enterprise Edition components +└── public/ # Static assets ``` ## Development diff --git a/content/developers/architecture/index.mdx b/content/developers/architecture/index.mdx index e7595b4..71f8d1a 100644 --- a/content/developers/architecture/index.mdx +++ b/content/developers/architecture/index.mdx @@ -10,13 +10,16 @@ LearnHouse is a multi-directory project with multiple applications that work tog ``` learnhouse/ ├── apps/ -│ ├── web/ # Next.js frontend -│ ├── api/ # FastAPI backend -│ ├── collab/ # Hocuspocus collaboration server -│ └── cli/ # LearnHouse CLI -└── community-edition/ # Docker Compose deployment config +│ ├── web/ # Next.js frontend +│ ├── api/ # FastAPI backend +│ ├── collab/ # Hocuspocus collaboration server +│ └── cli/ # LearnHouse CLI +├── docker/ # Production Dockerfile helpers (nginx config, start.sh) +└── Dockerfile # Monolithic image used by the CLI setup wizard ``` +Self-hosted deployments do not have a checked-in `docker-compose.yml`. The LearnHouse CLI (`apps/cli`) generates `docker-compose.yml`, `.env`, and reverse proxy config at setup time from the templates in `apps/cli/src/templates/`. + ## How It All Fits Together The platform consists of four applications backed by two core services: @@ -32,5 +35,5 @@ The platform consists of four applications backed by two core services: LearnHouse relies on two primary backing services: -- **PostgreSQL 16** -- The primary relational database for storing all application data including users, courses, organizations, and activity records. Uses the pgvector extension for AI embedding storage. -- **Redis 7.2** -- Used for caching, session management, collaboration state persistence, and message brokering between services. +- **PostgreSQL 16 (pgvector)** -- The primary relational database for storing all application data including users, courses, organizations, and activity records. Uses the pgvector extension for AI embedding storage. Both dev and self-host production use the `pgvector/pgvector:pg16` image. +- **Redis** -- Used for caching, session management, collaboration state persistence, and message brokering between services. Dev mode uses `redis:8.6.1-alpine`; the CLI-generated self-host production stack uses `redis:7.2.3-alpine`. diff --git a/content/developers/architecture/services.mdx b/content/developers/architecture/services.mdx index b2ee7a0..5675a94 100644 --- a/content/developers/architecture/services.mdx +++ b/content/developers/architecture/services.mdx @@ -1,10 +1,13 @@ # Supporting Services -LearnHouse relies on several supporting services that run alongside the main applications. In both development and production, these services are managed via Docker (configuration in the `community-edition/` directory). +LearnHouse relies on several supporting services that run alongside the main applications. + +- In **development** (`learnhouse dev`), PostgreSQL and Redis run in Docker via `.learnhouse/docker-compose.dev.yml` while the API, web, and collab processes run locally on the host. +- In **self-hosted production**, the LearnHouse CLI generates a `docker-compose.yml` from templates in `apps/cli/src/templates/` that runs PostgreSQL, Redis, a single `learnhouse-app` container (which bundles web + API + collab), and either nginx or Caddy as a reverse proxy. ## PostgreSQL -PostgreSQL 16 (Alpine) is the primary database for LearnHouse. It stores all persistent application data including: +`pgvector/pgvector:pg16` (PostgreSQL 16 with the pgvector extension) is the primary database for LearnHouse. It stores all persistent application data including: - Organizations and their configurations - User accounts and authentication records @@ -12,24 +15,26 @@ PostgreSQL 16 (Alpine) is the primary database for LearnHouse. It stores all per - Collections, trails, and progress tracking - AI vector embeddings (via the pgvector extension) -The backend connects to PostgreSQL through SQLModel. In development, the LearnHouse CLI automatically starts a PostgreSQL container. +The backend connects to PostgreSQL through SQLModel. **Default port:** `5432` ## Redis -Redis 7.2.3 (Alpine) serves as the caching, session management, and collaboration persistence layer: +Redis serves as the caching, session management, and collaboration persistence layer: - **Caching** -- Reduces database load by storing frequently accessed data in memory. - **Session storage** -- Manages user session data for fast access. - **Collaboration state** -- Stores Yjs document state from the Collab server with a 1-hour TTL before it is persisted to PostgreSQL. - **Pub/Sub** -- Enables communication between services when needed. +The dev compose uses `redis:8.6.1-alpine`; the CLI-generated self-host production compose uses `redis:7.2.3-alpine`. + **Default port:** `6379` ## Hocuspocus (Collaboration Server) -The Hocuspocus server, located at `apps/collab`, provides real-time collaborative editing capabilities. It is a Node.js + TypeScript application (run via tsx) built on [Hocuspocus](https://hocuspocus.dev/) ^3.0.0, which uses the Yjs CRDT library under the hood. It connects to Redis via ioredis ^5.9.3. +The Hocuspocus server, located at `apps/collab`, provides real-time collaborative editing capabilities. It is a Node.js + TypeScript application (run via `tsx` in dev) built on [Hocuspocus](https://hocuspocus.dev/) `^3.0.0`, which uses the Yjs CRDT library under the hood. It connects to Redis via `ioredis ^5.9.3`. **Default port:** `4000` (configurable via `COLLAB_PORT` env var) @@ -41,46 +46,46 @@ The Collab server performs JWT verification using the same secret as the API bac Document state follows a two-tier persistence strategy: -1. **Redis** -- Yjs state is first stored in Redis with a 1-hour TTL for fast access. -2. **PostgreSQL** -- State is persisted to the database via the API with a 5-second debounce to avoid excessive writes. +1. **Redis** -- Yjs state is first stored in Redis with a 1-hour TTL (`REDIS_YDOC_TTL = 3600`) for fast access. +2. **PostgreSQL** -- State is persisted to the database via the API with a 5-second debounce (`DB_FLUSH_DELAY = 5000`) to avoid excessive writes. ### Rate Limiting and Capacity -- **Max 10 concurrent users** per board -- **Rate limiting** of 30 connections per IP per minute +- **Max 10 concurrent users** per board (`MAX_BOARD_USERS`) +- **Rate limiting** of 30 connections per IP per minute (`RATE_LIMIT_MAX`, `RATE_LIMIT_WINDOW_MS`) ### Key Features -- **Real-time document synchronization** -- Multiple users can edit the same activity simultaneously. +- **Real-time document synchronization** -- Multiple users can edit the same board simultaneously. - **Conflict resolution** -- Yjs CRDTs handle concurrent edits without conflicts. - **Durable persistence** -- Document state survives server restarts through Redis and PostgreSQL. The frontend connects to Hocuspocus directly over WebSocket using the `@hocuspocus/provider` client for low-latency collaborative editing. -## nginx (Reverse Proxy) +## Reverse Proxy (nginx or Caddy) -In production deployments, nginx (Alpine) acts as the reverse proxy that routes incoming traffic to the appropriate service: +The CLI-generated self-host stack uses one of two reverse proxies depending on the SSL choice made during setup: -- Frontend requests go to the Next.js application -- API requests are forwarded to the FastAPI backend -- WebSocket connections for collaboration are routed to the Hocuspocus server +- **Caddy** (`caddy:2-alpine`) — selected when "Automatic SSL" is enabled; handles Let's Encrypt certificate issuance and renewal automatically. +- **nginx** (`nginx:alpine`) — selected for manual SSL or HTTP-only setups. -nginx also handles TLS termination and static asset serving in production environments. +Both route traffic to the single `learnhouse-app` container, which internally serves the Next.js frontend, the FastAPI backend, and the Hocuspocus collaboration server. ## Service Communication -All services communicate over a shared Docker network. The typical request flow is: +Logically, a request flows like this: ``` Client - └── nginx (reverse proxy) - ├── web (Next.js frontend, port 3000) - ├── api (FastAPI backend, port 9000) - │ ├── PostgreSQL (port 5432) - │ └── Redis (port 6379) - └── collab (Hocuspocus, port 4000) - ├── Redis (port 6379) - └── api (port 9000, for persistence & auth) + └── nginx / caddy (reverse proxy) + └── learnhouse-app (single container) + ├── Next.js (web) + ├── FastAPI (api) + │ ├── PostgreSQL (port 5432) + │ └── Redis (port 6379) + └── Hocuspocus (collab) + ├── Redis (port 6379) + └── FastAPI (for persistence & JWT-based auth) ``` -The frontend makes HTTP requests to the backend API. The collaboration server authenticates connections via JWT (shared secret with the API), verifies board membership through the API, and persists document state to both Redis and PostgreSQL (via the API). PostgreSQL is accessed directly only by the backend. +The Hocuspocus server authenticates connections via JWT (shared secret with the API), verifies board membership through the API, and persists document state to both Redis and PostgreSQL (via the API). PostgreSQL is accessed directly only by the backend. diff --git a/content/developers/contributing/dev-environment.mdx b/content/developers/contributing/dev-environment.mdx index 5e6214b..0cadb98 100644 --- a/content/developers/contributing/dev-environment.mdx +++ b/content/developers/contributing/dev-environment.mdx @@ -10,13 +10,15 @@ Make sure you have the following installed before proceeding: - **Docker** (with Docker Compose v2) - **Node.js 18+** +- **[Bun](https://bun.sh/)** — used to install and run the web and collab workspaces +- **[uv](https://docs.astral.sh/uv/)** — used to manage and run the Python API Make sure Docker has at least **4GB of RAM** allocated. You can check and adjust this in Docker Desktop under Settings > Resources. -You do **not** need to install Python, uv, Bun, or any other tooling manually. The `npx learnhouse dev` command handles all dependency installation automatically. +`npx learnhouse dev` runs `bun install` and `uv sync` to install project dependencies, but it does **not** install `bun` or `uv` themselves — install them on your host first. ## Setup Steps @@ -57,6 +59,6 @@ Press `Ctrl+C` in the terminal where `npx learnhouse dev` is running to stop all ## Troubleshooting -- **Port conflicts** -- Make sure ports 3000 and 1338 are not in use by other applications. +- **Port conflicts** -- Make sure ports 3000 (web), 1338 (API), 4000 (collab), 5432 (Postgres), and 6379 (Redis) are not in use by other applications. - **Docker not running** -- Ensure the Docker daemon is started before running `npx learnhouse dev`. - **Dependency issues** -- The CLI installs all dependencies automatically. If you encounter issues, try deleting `node_modules` and `.venv` directories and re-running `npx learnhouse dev`. diff --git a/content/enterprise/index.mdx b/content/enterprise/index.mdx index 6e3a059..c0e469c 100644 --- a/content/enterprise/index.mdx +++ b/content/enterprise/index.mdx @@ -17,6 +17,6 @@ Interested in the Enterprise Edition? Visit [learnhouse.app](https://www.learnho ## Enterprise Features -- **[Single Sign-On (SSO)](/enterprise/sso)** — Authenticate users through external identity providers like WorkOS, Okta, Auth0, Keycloak, or any SAML/OIDC-compatible provider. +- **[Single Sign-On (SSO)](/enterprise/sso)** — Authenticate users through WorkOS (which brokers SAML, Okta, Azure AD, and more) or any OIDC-compatible provider via the Custom OIDC integration. - **[Audit Logs](/enterprise/audit-logs)** — A full audit trail of all platform activity for compliance and security monitoring, with filtering and CSV export. - **[SCORM](/enterprise/scorm)** — Import and run SCORM 1.2 and 2004 learning packages from authoring tools like Articulate Storyline and Adobe Captivate. diff --git a/content/enterprise/sso/index.mdx b/content/enterprise/sso/index.mdx index 2a27883..1d55bad 100644 --- a/content/enterprise/sso/index.mdx +++ b/content/enterprise/sso/index.mdx @@ -32,7 +32,7 @@ When a user logs in via SSO for the first time, LearnHouse automatically creates - **First name, last name, and email** are mapped from the IdP. - **Avatar** is imported if available. -- **Default role** is assigned based on the SSO configuration (e.g., all new SSO users get the Student role). +- **Default role** is assigned based on the SSO configuration (e.g., all new SSO users get the `User` role). Existing users whose email matches are linked automatically — no duplicate accounts are created. diff --git a/content/getting-started/cloud-vs-self-hosting.mdx b/content/getting-started/cloud-vs-self-hosting.mdx index ec1a9f4..12a34f1 100644 --- a/content/getting-started/cloud-vs-self-hosting.mdx +++ b/content/getting-started/cloud-vs-self-hosting.mdx @@ -2,7 +2,7 @@ import { Callout } from 'nextra/components' # Cloud vs Self Hosting -LearnHouse is open-source software. You can use the managed **LearnHouse Cloud** platform or deploy the **Community Edition** on your own infrastructure. This page explains the differences so you can make an informed choice. +LearnHouse is open-source software. You can use the managed **LearnHouse Cloud** platform or self-host the core platform on your own infrastructure using the **LearnHouse CLI**. This page explains the differences so you can make an informed choice. ## Comparison @@ -49,7 +49,7 @@ Self hosting requires your team to manage updates, backups, security patches, an -Both options give you access to the same core feature set. Self-hosted instances can be upgraded at any time by pulling the latest release from the [Community Edition repository](https://github.com/learnhouse/community-edition). +Both options give you access to the same core feature set. Self-hosted instances can be upgraded at any time with `learnhouse update`, which pulls the latest release from the [LearnHouse GitHub repository](https://github.com/learnhouse/learnhouse). ## Next steps diff --git a/content/index.mdx b/content/index.mdx index e091d0d..ec0f217 100644 --- a/content/index.mdx +++ b/content/index.mdx @@ -22,7 +22,7 @@ import FeaturesGrid from '../components/FeaturesGrid/FeaturesGrid' | Backend | FastAPI, Python, SQLModel, Alembic | | Collaboration | Hocuspocus (Yjs/CRDT) | | Database | PostgreSQL 16 + pgvector | -| Cache | Redis 7.2 | +| Cache | Redis | | AI | Google Gemini, LlamaIndex | | CLI | Commander (Node.js) | diff --git a/content/platform/ai/for-teachers.mdx b/content/platform/ai/for-teachers.mdx index f244117..abd8017 100644 --- a/content/platform/ai/for-teachers.mdx +++ b/content/platform/ai/for-teachers.mdx @@ -20,4 +20,4 @@ Beyond content creation, the AI can assist with organizing and structuring cours ## Getting Started -The AI assistant is available from the course editor interface. Make sure your organization has an OpenAI API key configured in the [organization settings](/platform/organizations/settings). +The AI assistant is available from the course editor interface. Make sure your instance has a Google Gemini API key configured via `LEARNHOUSE_GEMINI_API_KEY` (see [AI Setup](/self-hosting/configuration/ai-setup)) and that AI is enabled for your organization. diff --git a/content/platform/ai/index.mdx b/content/platform/ai/index.mdx index a1a81a8..d7b7df9 100644 --- a/content/platform/ai/index.mdx +++ b/content/platform/ai/index.mdx @@ -2,14 +2,14 @@ import { Callout } from 'nextra/components' # AI -LearnHouse includes a context-aware AI assistant powered by OpenAI. The AI understands the content of your courses and activities, enabling it to provide relevant, targeted assistance to both students and teachers. +LearnHouse includes a context-aware AI assistant powered by **Google Gemini**. The AI understands the content of your courses and activities, enabling it to provide relevant, targeted assistance to both students and teachers. ## How It Works The AI assistant operates at the course and activity level. It reads the content of the current course or activity to provide contextually accurate responses. This means answers are grounded in your actual teaching material rather than generic knowledge. -AI features require an OpenAI API key to be configured in your organization settings. See [Organization Settings](/platform/organizations/settings) for details. +AI features require a Google Gemini API key to be configured at the instance level via `LEARNHOUSE_GEMINI_API_KEY`. See [AI Setup](/self-hosting/configuration/ai-setup) for details. ## Learn More diff --git a/content/platform/assignments/grading.mdx b/content/platform/assignments/grading.mdx index 7600f39..6e8c76a 100644 --- a/content/platform/assignments/grading.mdx +++ b/content/platform/assignments/grading.mdx @@ -6,11 +6,19 @@ LearnHouse provides a straightforward grading workflow for teachers to review an ## Submission Flow -1. A teacher creates an assignment with one or more tasks. -2. Students complete each task and submit their work (text, files, or code). +1. A teacher creates an assignment with one or more tasks (file upload or quiz). +2. Students complete each task and submit their work. 3. The teacher reviews submissions and assigns grades per task. 4. Grades are aggregated at the assignment level and reflected in the student's Trail. +## Grade Types + +Each assignment can be graded using one of three scales: + +- **Numeric** — raw number score (for example, 87 / 100). +- **Percentage** — score expressed as a percentage. +- **Alphabet** — letter grades (A, B, C, …). + ## Grading Options - **Task-level grading** — Assign a score to each individual task within an assignment. @@ -19,7 +27,13 @@ LearnHouse provides a straightforward grading workflow for teachers to review an ## Submission Status -Each submission is tracked with a status so teachers can see at a glance which students have submitted, which are pending, and which have been graded. +Each submission moves through a clear set of states so teachers can see at a glance where every learner stands: + +- **Not Submitted** — the student has not yet turned the task in. +- **Pending** — the student has saved work in progress. +- **Submitted** — the student has submitted and is awaiting a grade. +- **Late** — submitted after the deadline. +- **Graded** — the teacher has reviewed the submission and recorded a grade. Submissions are tied to the student's Trail, so all grading data contributes to the overall course progress view. diff --git a/content/platform/assignments/index.mdx b/content/platform/assignments/index.mdx index f854d07..3fa5250 100644 --- a/content/platform/assignments/index.mdx +++ b/content/platform/assignments/index.mdx @@ -6,7 +6,7 @@ Assignments let teachers create assessable tasks within courses. Students submit ## How Assignments Work -Each assignment is linked to a course activity and can contain one or more tasks. Students complete tasks, upload files, or write code, and then submit their work for grading. +Each assignment is linked to a course activity and can contain one or more tasks. Supported task types are **file uploads** and **quizzes**, with a generic `OTHER` fallback for custom submissions. Assignments must be enabled in your [Organization Settings](/platform/organizations/settings) to be available. @@ -22,4 +22,4 @@ Assignments must be enabled in your [Organization Settings](/platform/organizati ## Learn More - [Grading & Submissions](/platform/assignments/grading) — How the grading workflow works. -- [Code Execution](/platform/code-execution) — Auto-graded coding assignments with multi-language support. +- [Code Execution](/platform/code-execution) — Auto-graded code exercises are built into course content via the **Code Playground** editor block, not assignment tasks. diff --git a/content/platform/boards/index.mdx b/content/platform/boards/index.mdx index cd6146c..5e8f508 100644 --- a/content/platform/boards/index.mdx +++ b/content/platform/boards/index.mdx @@ -2,7 +2,7 @@ import { Callout } from 'nextra/components' # Boards -Boards are collaborative documents that multiple users can edit together in real time. They use the same block-based editor as course activities but are designed for freeform collaboration outside the course structure. +Boards are real-time collaborative **canvases** — a Miro / FigJam-style freeform workspace that multiple users can pan, zoom, and edit together. They are not document editors and do not reuse the course-activity block editor. Boards must be enabled in your [Organization Settings](/platform/organizations/settings) to be available. @@ -10,17 +10,18 @@ Boards must be enabled in your [Organization Settings](/platform/organizations/s ## How Boards Work -A board is a shared document with real-time synchronization powered by Yjs. Multiple users can view and edit a board simultaneously, with changes synced instantly across all participants. +Each board is an infinite canvas backed by Yjs CRDTs, so concurrent edits merge without conflicts. The collaboration server (Hocuspocus) syncs changes in real time over WebSockets and persists document state to Redis and PostgreSQL. ## Key Features -- **Real-time collaboration** — Multiple users can edit a board at the same time with live cursor tracking and instant sync. -- **Role-based access** — Board members can be assigned roles: **Owner**, **Editor**, or **Viewer**. -- **Block-based editing** — Boards use the same rich block editor as course activities, supporting text, media, and advanced blocks. +- **Real-time collaboration** — Multiple users can edit a board at the same time with live presence and cursor tracking. +- **Role-based access** — Board members are assigned one of three roles: **Owner**, **Editor**, or **Viewer**. +- **Canvas tools** — Drawing strokes, sticky notes, to-do cards, frames, and freeform pan/zoom navigation. +- **Rich embeds** — Drop in webpages, YouTube videos, podcasts, activities, AI-generated playgrounds, and other LearnHouse resources as cards on the canvas. - **Member management** — Board owners can invite members and manage their access levels. ## Use Cases -- **Group projects** — Students collaborate on shared documents for team assignments. -- **Meeting notes** — Teachers and staff maintain shared notes for planning and coordination. -- **Brainstorming** — Teams use boards as collaborative whiteboards for idea generation. +- **Group projects** — Students collaborate on shared boards for team assignments. +- **Planning and brainstorming** — Teachers and staff map ideas, lesson plans, or workflows visually. +- **Workshops** — Run live exercises where the whole class contributes to a single shared surface. diff --git a/content/platform/code-execution.mdx b/content/platform/code-execution.mdx index 7ee386c..de0b1cb 100644 --- a/content/platform/code-execution.mdx +++ b/content/platform/code-execution.mdx @@ -2,18 +2,22 @@ import { Callout } from 'nextra/components' # Code Execution -LearnHouse integrates with Judge0 to provide sandboxed code execution for coding assignments. Students can write and run code directly in the platform, and teachers can define test cases for automatic grading. +LearnHouse integrates with [Judge0](https://judge0.com/) to provide sandboxed code execution inside **Code Playground** blocks on Dynamic Page activities. Students can write and run code directly in the platform, and teachers can define test cases for automatic grading. ## Supported Languages -The code execution engine supports 30+ programming languages including Python, JavaScript, Java, C, C++, Go, Rust, Ruby, and many more. +The Code Playground block supports 30 languages: Python 3, JavaScript (Node), TypeScript, Java, C, C++, Rust, Go, PHP, Ruby, Kotlin, C#, Swift, Scala, Perl, R, Dart, Haskell, Lua, Elixir, Clojure, SQL, Bash, Objective-C, Pascal, Fortran, Prolog, Common Lisp, PowerShell, and Assembly (NASM). ## How It Works -1. A teacher creates an assignment task with one or more test cases (input/output pairs). -2. Students write their solution in the built-in code editor. -3. On submission, the code is executed against all test cases in a sandboxed environment. -4. Results are reported per test case — pass/fail, execution time, and memory usage. +1. A teacher inserts a **Code Playground** block into a Dynamic Page activity and (optionally) defines test cases as input/output pairs. +2. Students write their solution in the built-in code editor embedded in the activity. +3. On submission, the code is executed against all test cases in a sandboxed Judge0 environment. +4. Results are reported per test case — pass/fail, execution time, and memory usage. Submissions are stored per `activity_uuid` + `block_id`. + + +Code execution is surfaced as an editor block inside course content — it is **not** a standalone assignment task type. If you want graded code exercises, insert a Code Playground block into a Dynamic Page activity. + ## Test Cases @@ -30,4 +34,4 @@ Code execution requires a Judge0 instance to be configured. See the [Self-Hostin ## Batch Execution -For assignments with multiple test cases, the platform executes all test cases in a single batch request, providing a comprehensive results summary that shows which tests passed and which failed. +For blocks with multiple test cases, the platform executes all test cases in a single batch request, providing a comprehensive results summary that shows which tests passed and which failed. diff --git a/content/platform/courses/chapters-and-activities.mdx b/content/platform/courses/chapters-and-activities.mdx index 1b20161..20db1ea 100644 --- a/content/platform/courses/chapters-and-activities.mdx +++ b/content/platform/courses/chapters-and-activities.mdx @@ -24,9 +24,21 @@ Video activities let you upload video files directly to LearnHouse or embed vide Document activities display PDF files using a built-in viewer. Upload a PDF and students can read it directly within the platform without downloading. -### Quizzes +### Assignments -Quiz activities provide interactive assessments. Teachers can create questions and review student results. Quiz data is recorded in the student's [Trail](/platform/courses/trails) for progress tracking. +Assignment activities are gradable tasks — currently file uploads and quiz-style submissions. Teachers can grade submissions from the dashboard, and results are recorded in the student's [Trail](/platform/courses/trails). See [Assignments](/platform/assignments) for details on task types and grading. + +### SCORM + +SCORM activities embed SCORM 1.2 or SCORM 2004 learning packages. This activity type is part of the Enterprise Edition. + +### Custom + +An escape hatch for custom activity implementations maintained outside of the built-in types. + + +Quizzes are available two ways: as an inline **Quiz** editor block inside a Dynamic Page (ungraded, lightweight knowledge checks) and as an **Assignment task** (gradable, stored submissions). + You can mix and match activity types within a single chapter to create a varied learning experience. diff --git a/content/platform/courses/index.mdx b/content/platform/courses/index.mdx index 4d6050c..ee9df9a 100644 --- a/content/platform/courses/index.mdx +++ b/content/platform/courses/index.mdx @@ -11,10 +11,12 @@ Courses are the core content unit in LearnHouse. Each course is made up of chapt LearnHouse supports several activity types to accommodate different teaching styles: -- **Dynamic Pages** — Rich WYSIWYG content built with the block-based editor. +- **Dynamic Pages** — Rich WYSIWYG content built with the block-based editor (quizzes and code blocks can be embedded inline). - **Videos** — Upload video files directly or embed from YouTube and other external sources. - **Documents** — PDF documents displayed with a built-in viewer. -- **Quizzes** — Interactive assessments to test student understanding. +- **Assignments** — Gradable tasks such as file uploads and quizzes. See [Assignments](/platform/assignments). +- **SCORM** — SCORM 1.2 and SCORM 2004 learning packages (Enterprise Edition). +- **Custom** — Escape hatch for custom activity implementations. ## Getting Started diff --git a/content/platform/editor/blocks.mdx b/content/platform/editor/blocks.mdx index e2b9faa..8cee469 100644 --- a/content/platform/editor/blocks.mdx +++ b/content/platform/editor/blocks.mdx @@ -83,7 +83,7 @@ The LearnHouse editor supports a wide range of block types for building rich cou - + ## Using Blocks diff --git a/content/platform/index.mdx b/content/platform/index.mdx index c972bee..1ceb4f2 100644 --- a/content/platform/index.mdx +++ b/content/platform/index.mdx @@ -6,10 +6,11 @@ This section covers all the features and capabilities of the LearnHouse platform - **[Courses](/platform/courses)** — Create and manage courses, chapters, activities, collections, and trails. - **[Editor](/platform/editor)** — A block-based WYSIWYG editor for building rich course content. -- **[Assignments](/platform/assignments)** — Assessable tasks with grading, submissions, and auto-graded code execution. -- **[Playgrounds](/platform/playgrounds)** — Interactive code environments for hands-on practice and experimentation. +- **[Assignments](/platform/assignments)** — File-upload and quiz tasks with rubric-based grading and submissions. +- **[Code Execution](/platform/code-execution)** — Judge0-powered Code Playground blocks that run student code in 30 languages, with auto-graded test cases. +- **[Playgrounds](/platform/playgrounds)** — AI-generated interactive HTML experiences (distinct from Code Playground blocks). - **[Discussions](/platform/discussions)** — Community discussion threads with comments, voting, and reactions. -- **[Boards](/platform/boards)** — Real-time collaborative documents for group work and brainstorming. +- **[Boards](/platform/boards)** — Real-time collaborative canvases with sticky notes, drawings, frames, and embedded content. - **[Podcasts](/platform/podcasts)** — Audio content with episode management and streaming. - **[Certifications](/platform/certifications)** — Automatic certificate generation on course completion. - **[Analytics](/platform/analytics)** — Engagement tracking and usage metrics for your organization. diff --git a/content/platform/organizations/settings.mdx b/content/platform/organizations/settings.mdx index 4196d34..2c206f1 100644 --- a/content/platform/organizations/settings.mdx +++ b/content/platform/organizations/settings.mdx @@ -14,14 +14,14 @@ Customize the look and feel of your organization: ## AI Configuration -Configure the AI assistant for your organization: +Per-organization AI controls let admins: -- Enable or disable AI features -- Set your OpenAI API key -- Adjust AI behavior and context settings +- Enable or disable AI features for the organization +- Set a per-user request limit to cap usage +- Toggle individual AI surfaces (such as the admin copilot) -An OpenAI API key is required for AI features to function. Without one, the AI assistant will be unavailable to students and teachers. +The Google Gemini API key itself is a global, instance-level setting (`LEARNHOUSE_GEMINI_API_KEY`) — it is configured once at deployment and shared across all organizations. See [AI Setup](/self-hosting/configuration/ai-setup) for details. ## User and Access Settings @@ -30,7 +30,6 @@ Control how users interact with your organization: - **Signup mechanism** — Choose between open signup and invite-only registration. - **User limits** — Set maximum user counts if needed. -- **Default role** — Configure the default role assigned to new users. ## Managing Settings diff --git a/content/platform/playgrounds/index.mdx b/content/platform/playgrounds/index.mdx index 4cc3a93..739e45a 100644 --- a/content/platform/playgrounds/index.mdx +++ b/content/platform/playgrounds/index.mdx @@ -2,26 +2,36 @@ import { Callout } from 'nextra/components' # Playgrounds -Playgrounds are interactive code environments where users can write, run, and experiment with code directly in the browser. They can be created manually or generated by AI. +Playgrounds are **AI-generated interactive HTML experiences** that teachers can publish alongside their courses. They are not a multi-language code runner — for that, use the [Code Playground editor block](/platform/code-execution) instead. -Playgrounds must be enabled in your [Organization Settings](/platform/organizations/settings) to be available. +Playgrounds must be enabled in your [Organization Settings](/platform/organizations/settings) to be available. AI must also be enabled on the instance (see [AI Setup](/self-hosting/configuration/ai-setup)). ## How Playgrounds Work -A playground provides an in-browser coding environment where users can write code, execute it, and see results in real time. Playgrounds support multiple programming languages through the Judge0 code execution engine. +A playground is an interactive HTML/JS artifact generated by Google Gemini from a natural-language prompt. Teachers describe what they want — a visualization, a simulation, an interactive exercise — and LearnHouse stores the resulting HTML alongside the rest of the course material. + +Each playground supports up to 10 iterative refinements, so teachers can tweak prompts and regenerate without starting over. ## Key Features -- **AI-generated playgrounds** — Use AI to generate interactive playgrounds from a prompt or course context. -- **Multi-language support** — Write and execute code in 30+ programming languages. +- **AI-driven generation** — Prompt Gemini to produce custom interactive HTML experiences. +- **Iteration** — Refine a playground up to 10 times; each version is tracked. +- **Access control** — Each playground has one of three access modes: `PUBLIC`, `AUTHENTICATED`, or `RESTRICTED` (limited to specific user groups). - **Reactions** — Users can react to playgrounds to provide feedback. -- **Sharing** — Playgrounds can be shared with specific user groups or made available to the entire organization. -- **Multiple iterations** — Playgrounds support multiple response iterations, letting users refine and build on their work. ## Use Cases -- **Practice exercises** — Give students hands-on coding practice alongside course material. -- **Code demonstrations** — Teachers can create interactive examples that students can modify and run. -- **Experimentation** — Students can freely explore and test ideas in a sandboxed environment. +- **Custom simulations** — Generate physics, math, or chemistry visualizations on demand. +- **Interactive examples** — Ship hands-on widgets that reinforce reading material. +- **Prototype activities** — Quickly explore teaching ideas before building them into full activities. + +## Playgrounds vs Code Playground (editor block) + +These are two distinct features that share a name: + +| Feature | Purpose | Engine | +| --- | --- | --- | +| **Playgrounds** (this page) | AI-generated interactive HTML experiences | Google Gemini | +| **Code Playground** editor block | Multi-language "run this code" block inside Dynamic Page activities | Judge0 (see [Code Execution](/platform/code-execution)) | diff --git a/content/platform/podcasts/index.mdx b/content/platform/podcasts/index.mdx index 991449f..cd3f50c 100644 --- a/content/platform/podcasts/index.mdx +++ b/content/platform/podcasts/index.mdx @@ -16,7 +16,7 @@ Each podcast acts as a container for related episodes. You create a podcast, add - **Episode management** — Add, edit, reorder, and remove episodes within a podcast. - **Audio streaming** — Episodes are streamed with HTTP Range request support for efficient playback and seeking. -- **Deploy to Apple Podcasts & Spotify** — Publish your podcasts to Apple Podcasts and Spotify to reach a wider audience beyond your platform. +- **RSS feed** — Every podcast exposes a standard RSS feed at `/podcast/{shortUuid}/feed` that you can submit manually to Apple Podcasts Connect, Spotify for Podcasters, and other directories. LearnHouse does not publish to these services on your behalf. - **Metadata & discovery** — Each podcast and episode supports names, descriptions, and tags for easy browsing. - **Thumbnails** — Upload custom artwork for podcasts and episodes. diff --git a/content/platform/users/authentication.mdx b/content/platform/users/authentication.mdx index ad68f31..997b667 100644 --- a/content/platform/users/authentication.mdx +++ b/content/platform/users/authentication.mdx @@ -4,9 +4,16 @@ import { Callout } from 'nextra/components' LearnHouse supports multiple authentication methods to fit different deployment scenarios. -## OAuth Providers +## Login Methods -LearnHouse supports OAuth login with providers like Google, depending on your configuration. +- **Email and password** — the default authentication method for every LearnHouse instance. +- **Google OAuth** — the only third-party login provider currently supported outside of Enterprise SSO. + +For enterprise deployments, SAML (via WorkOS) and Custom OIDC are available — see [Enterprise SSO](/enterprise/sso). + +## Security + +Logins are rate-limited per IP, and accounts are temporarily locked after repeated failed attempts. SaaS-mode deployments additionally require users to verify their email address before they can sign in. ## Signup Mechanisms diff --git a/content/platform/users/index.mdx b/content/platform/users/index.mdx index 5061741..ee5943a 100644 --- a/content/platform/users/index.mdx +++ b/content/platform/users/index.mdx @@ -5,8 +5,8 @@ LearnHouse provides a user management system with role-based access control. Eac ## Key Concepts - **Users** — Individual accounts that can log in and interact with the platform. -- **Roles** — Each user has a role (Admin, Teacher/Staff, or Student) that defines their permissions. -- **Authentication** — Users authenticate via OAuth providers or standard credentials. +- **Roles** — LearnHouse seeds four default roles: **Admin**, **Maintainer**, **Instructor**, and **User**. Organizations can also define custom roles with their own permission matrix. +- **Authentication** — Users authenticate via email/password or Google OAuth. ## Learn More diff --git a/content/platform/users/roles-and-permissions.mdx b/content/platform/users/roles-and-permissions.mdx index 4791ea5..90183f5 100644 --- a/content/platform/users/roles-and-permissions.mdx +++ b/content/platform/users/roles-and-permissions.mdx @@ -1,6 +1,8 @@ # Roles and Permissions -LearnHouse uses a role-based access control model. Every user within an organization is assigned one of three roles. +LearnHouse uses a role-based access control model. Roles are stored as database rows with a per-resource permission matrix (courses, users, usergroups, collections, organizations, chapters, activities, roles, dashboard, communities, discussions, podcasts, boards, playgrounds), so organizations can customize permissions or create their own roles on top of the defaults. + +Every new instance is seeded with four default global roles: ## Admin @@ -11,24 +13,36 @@ Admins have full control over the organization. They can: - Configure organization settings (branding, AI, signup) - Access all platform features -## Teacher / Staff +## Maintainer -Teachers and staff members can create and manage educational content. They can: +Maintainers are mid-level managers who can operate most of the organization day-to-day but cannot change platform-level settings. They can: -- Create and edit courses, chapters, and activities -- View student Trails and quiz results +- Manage courses, collections, and published content +- Manage users within the organization +- Moderate community discussions and boards + +## Instructor + +Instructors focus on teaching and creating educational content. They can: + +- Create and edit their own courses, chapters, and activities +- View learner progress for their courses - Use the AI assistant for content creation -- Manage collections +- Manage collections they own -Teachers cannot modify organization-level settings or manage other users' roles. +Instructors cannot modify organization-level settings or manage other users' roles. -## Student +## User -Students are the primary learners on the platform. They can: +Users are the default learner role. They can: - Browse and enroll in available courses -- Complete activities and quizzes +- Complete activities, assignments, and quizzes - View their own Trail and progress - Interact with the AI assistant for learning support -Students cannot create or edit courses or access administrative features. +Users cannot create or edit courses or access administrative features. + +## Custom Roles + +Admins can create additional roles (global or organization-scoped) and fine-tune each permission individually from the dashboard. diff --git a/content/self-hosting/configuration/ai-setup.mdx b/content/self-hosting/configuration/ai-setup.mdx index 728ac0f..df8e5a5 100644 --- a/content/self-hosting/configuration/ai-setup.mdx +++ b/content/self-hosting/configuration/ai-setup.mdx @@ -2,14 +2,12 @@ import { Callout } from 'nextra/components' # AI Setup -LearnHouse includes AI-powered features for learning assistance and content editing. The primary AI provider is **Google Gemini**, with OpenAI also supported as an alternative. These features are optional and disabled by default. +LearnHouse includes AI-powered features for learning assistance and content editing, powered by **Google Gemini**. These features are optional and disabled by default. LearnHouse uses **llama-index** with **pgvector** for RAG (Retrieval-Augmented Generation), enabling AI assistants to answer questions using your course content as context. ## Enabling AI -### Using Google Gemini (Recommended) - Set the following environment variables in your `.env` file: ```env @@ -19,15 +17,6 @@ LEARNHOUSE_IS_AI_ENABLED=true To get a Gemini API key, visit [Google AI Studio](https://aistudio.google.com/apikey). -### Using OpenAI - -Alternatively, you can use OpenAI as your AI provider: - -```env -LEARNHOUSE_OPENAI_API_KEY=sk-your-openai-api-key -LEARNHOUSE_IS_AI_ENABLED=true -``` - After updating your `.env` file, restart your instance: ```bash @@ -36,32 +25,20 @@ learnhouse start ``` -AI features require a valid API key with sufficient credits. Usage costs are billed directly by your chosen provider based on the models and volume used. +AI features require a valid Gemini API key with sufficient quota. Usage costs are billed directly by Google based on the models and volume used. +## Models + +LearnHouse uses Gemini models directly — the model names are managed by LearnHouse and are not configurable: + +- `gemini-2.5-flash` — main assistant responses +- `gemini-2.0-flash-lite` — short tasks such as chat title generation and follow-up suggestions + ## Per-Organization AI Configuration -AI settings can also be configured on a per-organization basis through the organization configuration in the admin panel. This allows you to: - -- Enable or disable AI for specific organizations -- Select which AI model to use per organization -- Control which AI features are available - -## AI Feature Toggles - -The following AI features can be individually enabled or disabled per organization: - -| Feature | Description | -|---|---| -| `activity_ask` | AI assistant within learning activities, allows learners to ask questions about activity content | -| `course_ask` | AI assistant at the course level, answers questions using the full course material as context | -| `editor` | AI-powered writing assistance in the content editor | -| `global_ai_ask` | Global AI assistant available across the platform | +Once AI is enabled on the instance, each organization can toggle AI on or off and set usage limits from its admin settings. The Gemini API key itself is set once at deployment via `LEARNHOUSE_GEMINI_API_KEY` and is shared across organizations. ## Usage Limits -You can configure usage limits per organization to control API costs. Limits can be set on the number of AI requests per user per day, preventing unexpected charges on your provider account. - -## Model Selection - -The AI model used for generating responses can be configured per organization. This allows you to balance quality and cost by choosing different models for different use cases. +You can configure a per-organization request limit to control API costs. When a user exceeds the limit, further AI requests are rejected until the window resets. diff --git a/content/self-hosting/configuration/environment-variables.mdx b/content/self-hosting/configuration/environment-variables.mdx index f7f2885..6599064 100644 --- a/content/self-hosting/configuration/environment-variables.mdx +++ b/content/self-hosting/configuration/environment-variables.mdx @@ -72,8 +72,7 @@ Environment variables override any values set in configuration files. The `.env` | Variable | Description | Example | |---|---|---| -| `LEARNHOUSE_GEMINI_API_KEY` | Google Gemini API key (primary AI provider) | `AIza...` | -| `LEARNHOUSE_OPENAI_API_KEY` | OpenAI API key (alternative AI provider) | `sk-...` | +| `LEARNHOUSE_GEMINI_API_KEY` | Google Gemini API key | `AIza...` | | `LEARNHOUSE_IS_AI_ENABLED` | Enable AI features globally | `true` | ## Email @@ -112,6 +111,9 @@ Environment variables override any values set in configuration files. The `.env` |---|---|---| | `LEARNHOUSE_STRIPE_SECRET_KEY` | Stripe secret key | `sk_live_...` | | `LEARNHOUSE_STRIPE_PUBLISHABLE_KEY` | Stripe publishable key | `pk_live_...` | +| `LEARNHOUSE_STRIPE_WEBHOOK_STANDARD_SECRET` | Stripe webhook signing secret (standard account) | `whsec_...` | +| `LEARNHOUSE_STRIPE_WEBHOOK_CONNECT_SECRET` | Stripe webhook signing secret (Connect) | `whsec_...` | +| `LEARNHOUSE_STRIPE_CLIENT_ID` | Stripe OAuth client ID for Connect | `ca_...` | ## Code Execution @@ -134,7 +136,6 @@ Environment variables override any values set in configuration files. The `.env` | Variable | Description | Example | |---|---|---| | `LEARNHOUSE_SENTRY_DSN` | Sentry DSN for error tracking | `https://abc@sentry.io/123` | -| `LEARNHOUSE_LOGFIRE_ENABLED` | Enable Logfire logging | `false` | ## Full Example diff --git a/content/self-hosting/installation/cli-reference.mdx b/content/self-hosting/installation/cli-reference.mdx index defc317..8236bc2 100644 --- a/content/self-hosting/installation/cli-reference.mdx +++ b/content/self-hosting/installation/cli-reference.mdx @@ -1,17 +1,21 @@ +import { Callout } from 'nextra/components' + # CLI Reference -Complete reference for all LearnHouse CLI commands. The CLI is published as `learnhouse` on npm (v1.1.0) and is typically run via `npx learnhouse@latest`. +Complete reference for all LearnHouse CLI commands. The CLI is published as `learnhouse` on npm and is typically run via `npx learnhouse@latest`. ## Setup and Configuration ### `learnhouse setup` -Run the interactive setup wizard. This command generates `docker-compose.yml`, `.env`, `learnhouse.config.json`, and nginx/Caddy configuration files based on your choices. +Run the interactive setup wizard. This command generates `docker-compose.yml`, `.env`, `learnhouse.config.json`, and nginx or Caddy configuration files based on your choices. ```bash learnhouse setup ``` +Flags: `--ci`, `--name`, `--domain`, `--port`, `--admin-email`, `--admin-password`, `--channel `, `--no-start`. + You can re-run this command at any time to reconfigure your instance. Existing configuration will be preserved as defaults in the prompts. ### `learnhouse config` @@ -22,6 +26,18 @@ View the current configuration. learnhouse config ``` +### `learnhouse env` + +Interactively edit environment variables in your `.env` file (Domain & Hosting, Database & Redis, Security, AI, Email (Resend), S3 Storage, OAuth). + +```bash +learnhouse env +``` + + +The `env` command edits a curated set of variables only. SMTP credentials (`LEARNHOUSE_SMTP_*`) are not editable through this command — edit `.env` directly if you need them. + + ## Service Management ### `learnhouse start` @@ -40,6 +56,14 @@ Stop all running LearnHouse services. Data is preserved in Docker volumes. learnhouse stop ``` +### `learnhouse status` + +Show the status of each LearnHouse service. + +```bash +learnhouse status +``` + ### `learnhouse logs` Stream container logs for all services. @@ -48,9 +72,20 @@ Stream container logs for all services. learnhouse logs ``` +### `learnhouse update` + +Update LearnHouse to the latest release or a specific version. Pulls the target image, rewrites `docker-compose.yml`, restarts services, and prompts for database migrations. + +```bash +learnhouse update +learnhouse update --version 1.4.2 +learnhouse update --migrate # auto-apply migrations +learnhouse update --no-migrate # skip migrations +``` + ### `learnhouse dev` -Start a full development environment. Useful when working on LearnHouse locally. +Start a full development environment (PostgreSQL + Redis in Docker, API + web + collab run locally). ```bash learnhouse dev @@ -66,6 +101,14 @@ Run diagnostics on your LearnHouse installation. Checks Docker availability, con learnhouse doctor ``` +### `learnhouse health` + +Run the CLI's health checks (PostgreSQL connection, Redis ping, HTTP health endpoint, disk, resources). + +```bash +learnhouse health +``` + ### `learnhouse shell` Open an interactive shell inside a running container for debugging. @@ -78,22 +121,30 @@ learnhouse shell ### `learnhouse deployments` -View or set resource limits (CPU, memory) for your LearnHouse containers. +Manage deployments and scale memory limits for your LearnHouse containers. ```bash learnhouse deployments ``` -## Backup +## Backup and Restore ### `learnhouse backup` -Backup or restore the database. This command handles both creating new backups and restoring from existing backup files. +Create a PostgreSQL dump archive of your instance's database (plus a copy of `.env`). Archives are written to `/backups/`. ```bash learnhouse backup ``` +### `learnhouse restore` + +Restore a database from a backup archive. + +```bash +learnhouse restore .tar.gz> +``` + ## Command Summary | Command | Description | @@ -101,10 +152,15 @@ learnhouse backup | `learnhouse setup` | Interactive setup wizard, generates docker-compose.yml, .env, and config files | | `learnhouse start` | Start all services | | `learnhouse stop` | Stop all services | +| `learnhouse update` | Update to latest or a specific version | +| `learnhouse status` | Show service status | +| `learnhouse health` | Run health checks | | `learnhouse logs` | Stream container logs | | `learnhouse config` | View current configuration | +| `learnhouse env` | Edit environment variables | +| `learnhouse backup` | Create a database backup archive | +| `learnhouse restore` | Restore the database from an archive | | `learnhouse doctor` | Diagnose Docker, containers, ports, DNS, and disk | | `learnhouse shell` | Open a shell in a running container | -| `learnhouse backup` | Backup or restore the database | -| `learnhouse deployments` | View or set resource limits | +| `learnhouse deployments` | Manage deployments and memory limits | | `learnhouse dev` | Start full development environment | diff --git a/content/self-hosting/installation/quick-install.mdx b/content/self-hosting/installation/quick-install.mdx index e713d02..c0e9f1f 100644 --- a/content/self-hosting/installation/quick-install.mdx +++ b/content/self-hosting/installation/quick-install.mdx @@ -17,12 +17,12 @@ You can also use the one-line installer scripts if you prefer: **macOS / Linux:** ```bash -curl -fsSL https://raw.githubusercontent.com/learnhouse/learnhouse/main/install.sh | bash +curl -fsSL https://raw.githubusercontent.com/learnhouse/learnhouse/main/apps/cli/install.sh | bash ``` **Windows (PowerShell):** ```powershell -irm https://raw.githubusercontent.com/learnhouse/learnhouse/main/install.ps1 | iex +irm https://raw.githubusercontent.com/learnhouse/learnhouse/main/apps/cli/install.ps1 | iex ``` @@ -40,7 +40,7 @@ The wizard generates `docker-compose.yml`, `.env`, `learnhouse.config.json`, and Once setup is complete, start all services: ```bash -learnhouse start +npx learnhouse start ``` The CLI will pull the required Docker images (on first run), create the containers, and start all services. This typically takes one to two minutes on first launch. diff --git a/content/self-hosting/maintenance/backups.mdx b/content/self-hosting/maintenance/backups.mdx index b2f1388..b993644 100644 --- a/content/self-hosting/maintenance/backups.mdx +++ b/content/self-hosting/maintenance/backups.mdx @@ -2,7 +2,11 @@ import { Callout } from 'nextra/components' # Backups -Regular backups are essential for protecting your LearnHouse data. The LearnHouse CLI provides built-in backup and restore functionality. +Regular backups are essential for protecting your LearnHouse data. The LearnHouse CLI provides built-in backup and restore commands for the PostgreSQL database. + + +The built-in backup only covers the database and your `.env` file. Uploaded content (images, videos, documents) stored on the filesystem is **not** included. See [Filesystem Content](#filesystem-content) below for recommendations. + ## Creating a Backup @@ -12,30 +16,29 @@ Create a backup with a single command: learnhouse backup ``` -This creates a timestamped archive file containing: +This creates a timestamped archive containing: -- **PostgreSQL database dump** -- all users, courses, organizations, and configuration data -- **Uploaded content** -- images, videos, documents, and other files stored on the filesystem +- **`database.sql`** — a `pg_dump` of the LearnHouse PostgreSQL database +- **`.env`** — a copy of your instance's environment file (if present) -The backup file is saved in the current working directory with a name like `backup-2025-01-15-120000.tar.gz`. +Backups are written to `/backups/learnhouse-backup-.tar.gz`. The CLI prints the absolute path when the backup completes. + + +`learnhouse backup` only works when PostgreSQL runs in a local Docker container managed by the CLI. If you use an external managed database, use that provider's native backup tools instead. + ## Restoring from a Backup To restore from a backup file: ```bash -learnhouse restore backup-2025-01-15-120000.tar.gz +learnhouse restore /backups/learnhouse-backup-.tar.gz ``` -The restore process: - -1. Stops all running services -2. Restores the database from the dump -3. Restores uploaded content files -4. Restarts all services +The restore command replays `database.sql` into the running database container. It does **not** stop or restart services — restart them yourself if needed. -Restoring a backup overwrites all current data. Make sure you are restoring to the correct instance. +Restoring a backup overwrites the database. Make sure you are restoring to the correct instance. ## Automating Backups @@ -52,17 +55,14 @@ crontab -e ## Backup Retention -Backup files can accumulate over time and consume significant disk space. Implement a retention policy to remove old backups. For example, keep the last 7 daily backups: +Backup files accumulate over time and can consume significant disk space. Implement a retention policy to remove old backups. For example, keep the last 7 daily backups: ```bash -# Remove backups older than 7 days -find /path/to/backups -name "backup-*.tar.gz" -mtime +7 -delete +find /backups -name "learnhouse-backup-*.tar.gz" -mtime +7 -delete ``` -## S3 Storage Considerations +## Filesystem Content -If you use S3-compatible storage for uploaded content, the `learnhouse backup` command backs up the database only. Your S3 content is managed by your storage provider, which typically offers its own backup and versioning features. +When `LEARNHOUSE_CONTENT_DELIVERY_TYPE=filesystem`, uploaded files live on the host (or in a Docker volume) and are **not** captured by `learnhouse backup`. You are responsible for backing up this directory separately — for example with `rsync`, a volume snapshot, or a scheduled `tar` job. - -For S3-based deployments, ensure your storage provider's backup or versioning features are enabled to protect uploaded content. - +When using `s3api` storage, rely on your S3 provider's versioning, lifecycle, or cross-region replication features to protect uploaded content. diff --git a/content/self-hosting/maintenance/monitoring.mdx b/content/self-hosting/maintenance/monitoring.mdx index 9e1b621..5395d89 100644 --- a/content/self-hosting/maintenance/monitoring.mdx +++ b/content/self-hosting/maintenance/monitoring.mdx @@ -6,14 +6,14 @@ Monitoring your self-hosted LearnHouse instance helps you catch issues early and ## Service Health Checks -Run the built-in diagnostics to check the health of your installation: +The CLI offers three complementary commands: ```bash -learnhouse doctor +learnhouse status # quick container status for each service +learnhouse health # PostgreSQL, Redis, HTTP health endpoint, disk, resources +learnhouse doctor # deep diagnostics (Docker, ports, DNS, env validation, logs) ``` -This checks Docker availability, container health, port conflicts, DNS resolution, and disk space. It reports any issues found and suggests fixes. - You can also verify the application health endpoint directly: ```bash diff --git a/content/self-hosting/maintenance/updates.mdx b/content/self-hosting/maintenance/updates.mdx index effd4d6..d8dd1dd 100644 --- a/content/self-hosting/maintenance/updates.mdx +++ b/content/self-hosting/maintenance/updates.mdx @@ -6,15 +6,23 @@ Keeping LearnHouse up to date ensures you have the latest features, bug fixes, a ## Updating LearnHouse -There is no dedicated update command in the CLI. To update your instance, pull the latest Docker images and restart the services manually: +Use the built-in `update` command. It pulls the target image, rewrites the image tag in `docker-compose.yml`, restarts the stack, and prompts for database migrations. ```bash -docker compose pull -learnhouse stop -learnhouse start +# Update to the latest version +learnhouse update + +# Update to a specific version +learnhouse update --version 1.4.2 ``` -This pulls the latest LearnHouse Docker images (`ghcr.io/learnhouse/app:latest` and others), stops the running services, and starts them again with the new images. +Flags: + +| Flag | Description | +|---|---| +| `--version ` | Pull a specific image tag from `ghcr.io/learnhouse/app`. Defaults to `latest`. | +| `--migrate` | Run database migrations without prompting. | +| `--no-migrate` | Skip database migrations without prompting. | Always create a backup before updating. This allows you to roll back if anything goes wrong. @@ -26,17 +34,13 @@ Always create a backup before updating. This allows you to roll back if anything # 1. Create a backup learnhouse backup -# 2. Pull the latest images -docker compose pull +# 2. Run the update +learnhouse update -# 3. Restart services with the new images -learnhouse stop -learnhouse start - -# 4. Verify all services are healthy +# 3. Verify all services are healthy learnhouse doctor -# 5. Check logs for any errors +# 4. Check logs for any errors learnhouse logs ``` @@ -45,16 +49,16 @@ learnhouse logs Review the [LearnHouse release notes](https://github.com/learnhouse/learnhouse/releases) before updating to understand what has changed. Some updates may include: - New features or UI changes -- Database migrations (applied automatically) +- Database migrations (applied automatically when you accept the prompt or pass `--migrate`) - Configuration changes that may require updating your `.env` file - Breaking changes (rare, but documented in release notes) ## Rolling Back -If an update causes issues, restore from your backup using the backup command: +If an update causes issues, restore from your latest backup: ```bash -learnhouse backup +learnhouse restore ``` -The backup command handles both creating new backups and restoring from existing ones. Follow the prompts to select a restore operation, which will restore both the database and uploaded content to the state captured in the backup. +Backups live under `/backups/` and are named `learnhouse-backup-.tar.gz`. The restore command replays the database dump and optionally restores the `.env` file — uploaded files on the filesystem are **not** restored (they are not included in the backup).