mirror of
https://github.com/learnhouse/docs.git
synced 2026-11-30 09:42:42 +01:00
feat: new documentation
This commit is contained in:
7
content/cli/_meta.json
Normal file
7
content/cli/_meta.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"index": "Overview",
|
||||
"commands": "Commands",
|
||||
"setup-wizard": "Setup Wizard",
|
||||
"dev-mode": "Dev Mode",
|
||||
"environment-variables": "Environment Variables"
|
||||
}
|
||||
150
content/cli/commands.mdx
Normal file
150
content/cli/commands.mdx
Normal file
@@ -0,0 +1,150 @@
|
||||
import { Callout } from 'nextra/components'
|
||||
|
||||
# Commands
|
||||
|
||||
Full reference for all LearnHouse CLI commands.
|
||||
|
||||
## `setup`
|
||||
|
||||
Interactive wizard that generates a complete Docker Compose deployment. See [Setup Wizard](/cli/setup-wizard) for details.
|
||||
|
||||
```bash
|
||||
npx learnhouse@latest setup
|
||||
```
|
||||
|
||||
## `start`
|
||||
|
||||
Start all Docker containers for your deployment.
|
||||
|
||||
```bash
|
||||
npx learnhouse start
|
||||
```
|
||||
|
||||
## `stop`
|
||||
|
||||
Stop all running containers.
|
||||
|
||||
```bash
|
||||
npx learnhouse stop
|
||||
```
|
||||
|
||||
## `logs`
|
||||
|
||||
Stream logs from all containers in real-time.
|
||||
|
||||
```bash
|
||||
npx learnhouse logs
|
||||
```
|
||||
|
||||
## `config`
|
||||
|
||||
Display current installation metadata — version, directory, URL, organization slug, and file locations.
|
||||
|
||||
```bash
|
||||
npx learnhouse config
|
||||
```
|
||||
|
||||
## `doctor`
|
||||
|
||||
Run comprehensive diagnostics to identify issues. Checks:
|
||||
|
||||
- Docker installation and daemon status
|
||||
- Docker Compose v2 availability
|
||||
- Container health and restart counts
|
||||
- Port availability
|
||||
- DNS resolution (for non-localhost domains)
|
||||
- Disk space (warns below 1 GB)
|
||||
- Docker volume sizes
|
||||
- Log analysis (scans for errors)
|
||||
- `.env` validation (required variables, secret length)
|
||||
- Image freshness
|
||||
|
||||
```bash
|
||||
npx learnhouse doctor
|
||||
```
|
||||
|
||||
## `backup`
|
||||
|
||||
Create a database backup as a `.tar.gz` archive containing a `pg_dump` and optionally your `.env` file.
|
||||
|
||||
```bash
|
||||
npx learnhouse backup
|
||||
```
|
||||
|
||||
Backups are saved to `{installDir}/backups/learnhouse-backup-{timestamp}.tar.gz`.
|
||||
|
||||
### Restore
|
||||
|
||||
Restore a database from a backup archive. This overwrites the current database.
|
||||
|
||||
```bash
|
||||
npx learnhouse backup --restore
|
||||
npx learnhouse restore <archive.tar.gz>
|
||||
```
|
||||
|
||||
<Callout type="warning">
|
||||
Restore only works with local (Docker) databases, not external connections. Restart services after restoring.
|
||||
</Callout>
|
||||
|
||||
## `deployments`
|
||||
|
||||
View and manage deployments on the current machine.
|
||||
|
||||
```bash
|
||||
npx learnhouse deployments
|
||||
```
|
||||
|
||||
Features:
|
||||
- List all LearnHouse deployments with container status
|
||||
- Scale resource limits (memory) for `learnhouse-app`, `db`, and `redis`
|
||||
- View current resource usage via `docker stats`
|
||||
|
||||
## `shell`
|
||||
|
||||
Open an interactive shell (`/bin/sh`) inside a running container.
|
||||
|
||||
```bash
|
||||
npx learnhouse shell
|
||||
```
|
||||
|
||||
Displays a list of running containers to choose from.
|
||||
|
||||
## `env`
|
||||
|
||||
Interactive environment variable editor. Edit variables by category:
|
||||
|
||||
- Domain & Hosting
|
||||
- Database & Redis
|
||||
- Security
|
||||
- AI
|
||||
- Email
|
||||
- S3 Storage
|
||||
- OAuth
|
||||
|
||||
```bash
|
||||
npx learnhouse env
|
||||
```
|
||||
|
||||
Secret values are masked in the display. Optionally restart services after changes.
|
||||
|
||||
## `health`
|
||||
|
||||
Run health checks against the running deployment.
|
||||
|
||||
```bash
|
||||
npx learnhouse health
|
||||
```
|
||||
|
||||
Checks container status, PostgreSQL connection, Redis ping, HTTP health endpoint, disk usage, and resource consumption.
|
||||
|
||||
## `dev`
|
||||
|
||||
Start a local development environment. See [Dev Mode](/cli/dev-mode) for details.
|
||||
|
||||
```bash
|
||||
npx learnhouse dev
|
||||
```
|
||||
|
||||
| Flag | Description |
|
||||
| --- | --- |
|
||||
| `--ee` | Enable Enterprise Edition features |
|
||||
79
content/cli/dev-mode.mdx
Normal file
79
content/cli/dev-mode.mdx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Callout } from 'nextra/components'
|
||||
|
||||
# Dev Mode
|
||||
|
||||
The `dev` command starts a full local development environment with hot reload for all services.
|
||||
|
||||
```bash
|
||||
npx learnhouse dev
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
The command splits infrastructure and application services:
|
||||
|
||||
- **Infrastructure** (Docker): PostgreSQL with pgvector + Redis run in containers via `.learnhouse/docker-compose.dev.yml`
|
||||
- **Application** (local): API, Web, and Collab servers run directly on your machine with hot reload
|
||||
|
||||
## Requirements
|
||||
|
||||
- Docker (for database and Redis)
|
||||
- [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.
|
||||
|
||||
## 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.
|
||||
5. **Install dependencies** — Runs `bun install` and `uv sync` if needed
|
||||
6. **Start services** — Launches API, Web, and Collab with color-coded output
|
||||
|
||||
## Services
|
||||
|
||||
| Service | Command | Port |
|
||||
| --- | --- | --- |
|
||||
| API | `uv run python app.py` | 1338 |
|
||||
| Web | `next dev --turbopack` | 3000 |
|
||||
| Collab | `tsx watch src/index.ts` | 4000 |
|
||||
|
||||
## Interactive Controls
|
||||
|
||||
While running, you can type commands to manage services:
|
||||
|
||||
| Key | Action |
|
||||
| --- | --- |
|
||||
| `ra` | Restart API |
|
||||
| `rw` | Restart Web |
|
||||
| `rc` | Restart Collab |
|
||||
| `rb` | Restart all services |
|
||||
| `q` | Quit (graceful shutdown) |
|
||||
|
||||
## Enterprise Edition
|
||||
|
||||
Use the `--ee` flag to enable Enterprise Edition features:
|
||||
|
||||
```bash
|
||||
npx learnhouse dev --ee
|
||||
```
|
||||
|
||||
Without the flag, the `apps/api/ee/` directory is temporarily hidden during development.
|
||||
|
||||
## Shutdown
|
||||
|
||||
When you quit (`q` or Ctrl+C):
|
||||
|
||||
- Local services (API, Web, Collab) are stopped
|
||||
- Docker containers (PostgreSQL, Redis) keep running for the next session
|
||||
- To fully stop infrastructure:
|
||||
|
||||
```bash
|
||||
docker compose -f .learnhouse/docker-compose.dev.yml -p learnhouse-dev down
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
Database data persists across dev sessions via Docker volumes. Your data is safe between restarts.
|
||||
</Callout>
|
||||
89
content/cli/environment-variables.mdx
Normal file
89
content/cli/environment-variables.mdx
Normal file
@@ -0,0 +1,89 @@
|
||||
# Environment Variables
|
||||
|
||||
The CLI generates a `.env` file during setup with all configuration variables. These can also be edited interactively with `npx learnhouse env`.
|
||||
|
||||
## Domain & Hosting
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_DOMAIN` | Hostname | `localhost` |
|
||||
| `HTTP_PORT` | HTTP port for reverse proxy | `80` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_API_URL` | Public API URL | `http://localhost/api/v1/` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL` | Backend URL | `http://localhost` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_DOMAIN` | Public domain | `localhost` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN` | Top-level domain | `localhost` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG` | Multi-org mode | `false` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG` | Default org slug | `my-school` |
|
||||
| `NEXT_PUBLIC_LEARNHOUSE_HTTPS` | HTTPS enabled | `false` |
|
||||
|
||||
## Database & Redis
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_SQL_CONNECTION_STRING` | PostgreSQL connection | `postgresql://learnhouse:pass@db:5432/learnhouse` |
|
||||
| `LEARNHOUSE_REDIS_CONNECTION_STRING` | Redis connection | `redis://redis:6379/learnhouse` |
|
||||
| `LEARNHOUSE_REDIS_URL` | Redis URL | `redis://redis:6379/learnhouse` |
|
||||
| `POSTGRES_USER` | Database user (local only) | `learnhouse` |
|
||||
| `POSTGRES_PASSWORD` | Database password (local only) | Auto-generated |
|
||||
| `POSTGRES_DB` | Database name (local only) | `learnhouse` |
|
||||
|
||||
## Security & Authentication
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_AUTH_JWT_SECRET_KEY` | JWT signing key | Auto-generated |
|
||||
| `LEARNHOUSE_INITIAL_ADMIN_EMAIL` | First admin email | `admin@example.com` |
|
||||
| `LEARNHOUSE_INITIAL_ADMIN_PASSWORD` | First admin password | Set during setup |
|
||||
| `LEARNHOUSE_COOKIE_DOMAIN` | Cookie domain | `localhost` |
|
||||
| `COLLAB_INTERNAL_KEY` | Collaboration service key | Auto-generated |
|
||||
| `NEXTAUTH_SECRET` | NextAuth secret | Auto-generated |
|
||||
| `NEXTAUTH_URL` | NextAuth URL | `http://localhost` |
|
||||
|
||||
## Application
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_PORT` | Internal API port | `9000` |
|
||||
| `LEARNHOUSE_DEVELOPMENT_MODE` | Dev mode flag | `False` |
|
||||
| `NEXT_PUBLIC_COLLAB_URL` | WebSocket collab URL | `ws://localhost/collab` |
|
||||
|
||||
## AI
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_IS_AI_ENABLED` | Enable AI features | `True` / `False` |
|
||||
| `LEARNHOUSE_GEMINI_API_KEY` | Gemini API key | Your API key |
|
||||
|
||||
## Email
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_EMAIL_PROVIDER` | Email provider | `resend` / `smtp` |
|
||||
| `LEARNHOUSE_SYSTEM_EMAIL_ADDRESS` | From address | `noreply@example.com` |
|
||||
| `LEARNHOUSE_RESEND_API_KEY` | Resend API key | Your API key |
|
||||
| `LEARNHOUSE_SMTP_HOST` | SMTP host | `smtp.gmail.com` |
|
||||
| `LEARNHOUSE_SMTP_PORT` | SMTP port | `587` |
|
||||
| `LEARNHOUSE_SMTP_USERNAME` | SMTP username | `user@example.com` |
|
||||
| `LEARNHOUSE_SMTP_PASSWORD` | SMTP password | Your password |
|
||||
| `LEARNHOUSE_SMTP_USE_TLS` | Enable TLS | `True` / `False` |
|
||||
|
||||
## S3 Storage
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_CONTENT_DELIVERY_TYPE` | Storage type | `filesystem` / `s3api` |
|
||||
| `LEARNHOUSE_S3_API_BUCKET_NAME` | S3 bucket name | `my-bucket` |
|
||||
| `LEARNHOUSE_S3_API_ENDPOINT_URL` | S3 endpoint (optional for AWS) | `https://s3.amazonaws.com` |
|
||||
|
||||
## OAuth
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `LEARNHOUSE_GOOGLE_CLIENT_ID` | Google OAuth client ID | Your client ID |
|
||||
| `LEARNHOUSE_GOOGLE_CLIENT_SECRET` | Google OAuth client secret | Your secret |
|
||||
|
||||
## Unsplash
|
||||
|
||||
| Variable | Description | Example |
|
||||
| --- | --- | --- |
|
||||
| `NEXT_PUBLIC_UNSPLASH_ACCESS_KEY` | Unsplash API key | Your access key |
|
||||
71
content/cli/index.mdx
Normal file
71
content/cli/index.mdx
Normal file
@@ -0,0 +1,71 @@
|
||||
import { Callout } from 'nextra/components'
|
||||
|
||||
# CLI
|
||||
|
||||
The LearnHouse CLI is the primary tool for deploying, managing, and developing LearnHouse. It orchestrates Docker Compose services and provides an interactive setup wizard for production deployments, as well as a full local development environment.
|
||||
|
||||
<img src="/img/pages/cli/cli-screenshot.png" alt="LearnHouse CLI" style={{ borderRadius: '12px', marginTop: '1rem' }} />
|
||||
|
||||
**Package**: [`learnhouse`](https://www.npmjs.com/package/learnhouse) on npm
|
||||
|
||||
## Installation
|
||||
|
||||
### Quick Start (recommended)
|
||||
|
||||
```bash
|
||||
npx learnhouse@latest setup
|
||||
```
|
||||
|
||||
### One-line Install (macOS / Linux)
|
||||
|
||||
Installs Docker, Node.js, and launches the CLI:
|
||||
|
||||
```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/apps/cli/install.ps1 | iex
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Node.js** 18+
|
||||
- **Docker** with Docker Compose v2
|
||||
|
||||
## What It Does
|
||||
|
||||
The CLI handles two main workflows:
|
||||
|
||||
### Production Deployment
|
||||
|
||||
The [setup wizard](/cli/setup-wizard) generates a complete Docker Compose deployment with:
|
||||
|
||||
- **LearnHouse app** container (Next.js + FastAPI)
|
||||
- **PostgreSQL** database (with optional pgvector for AI)
|
||||
- **Redis** cache
|
||||
- **Caddy** or **Nginx** reverse proxy (with optional auto-SSL)
|
||||
|
||||
Each deployment gets a unique ID, allowing multiple instances on the same machine.
|
||||
|
||||
### Local Development
|
||||
|
||||
The [`dev` command](/cli/dev-mode) starts infrastructure in Docker and runs the API, web, and collaboration servers locally with hot reload.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `npx learnhouse setup` | Interactive setup wizard |
|
||||
| `npx learnhouse start` | Start all services |
|
||||
| `npx learnhouse stop` | Stop all services |
|
||||
| `npx learnhouse logs` | Stream container logs |
|
||||
| `npx learnhouse doctor` | Run diagnostics |
|
||||
| `npx learnhouse backup` | Backup database |
|
||||
| `npx learnhouse dev` | Start dev environment |
|
||||
|
||||
<Callout type="info">
|
||||
See [Commands](/cli/commands) for the full reference.
|
||||
</Callout>
|
||||
107
content/cli/setup-wizard.mdx
Normal file
107
content/cli/setup-wizard.mdx
Normal file
@@ -0,0 +1,107 @@
|
||||
import { Callout } from 'nextra/components'
|
||||
|
||||
# Setup Wizard
|
||||
|
||||
The setup wizard (`npx learnhouse@latest setup`) is an interactive 6-step process that generates a complete Docker Compose deployment. You can go back and edit any step before confirming.
|
||||
|
||||
## Step 1 — Install Directory
|
||||
|
||||
Choose where the deployment files will be created.
|
||||
|
||||
- **Default**: `./learnhouse`
|
||||
- The directory is created if it doesn't exist
|
||||
|
||||
## Step 2 — Domain Configuration
|
||||
|
||||
Configure your hostname and HTTPS settings.
|
||||
|
||||
- **Domain**: hostname or IP address (default: `localhost`)
|
||||
- **HTTPS options** (non-localhost only):
|
||||
- **Automatic SSL** (recommended) — Uses Let's Encrypt via Caddy. Requires a valid domain and ports 80/443.
|
||||
- **Manual SSL** — You handle the reverse proxy or Cloudflare. LearnHouse runs on HTTP internally.
|
||||
- **No HTTPS** — HTTP only (not recommended for production)
|
||||
- **Port**: Automatically set based on SSL choice (443 for auto SSL, 80 for HTTP)
|
||||
|
||||
## Step 3 — Database & Redis
|
||||
|
||||
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
|
||||
- Password is auto-generated
|
||||
- **External** — Provide a connection string (`postgresql://user:pass@host:5432/db`). The wizard tests connectivity before proceeding.
|
||||
|
||||
### Redis
|
||||
|
||||
- **Local Docker** (recommended) — Uses `redis:7.2.3-alpine`
|
||||
- **External** — Provide a connection string. The wizard tests connectivity before proceeding.
|
||||
|
||||
## Step 4 — Organization
|
||||
|
||||
Set your organization name (e.g., "My School"). This creates the initial organization in the database.
|
||||
|
||||
## Step 5 — Admin Account
|
||||
|
||||
Create the first admin user with email and password (minimum 8 characters).
|
||||
|
||||
## Step 6 — Optional Features
|
||||
|
||||
Enable any of the following integrations:
|
||||
|
||||
| Feature | Required Configuration |
|
||||
| --- | --- |
|
||||
| **AI (Gemini)** | Gemini API key |
|
||||
| **Email (Resend)** | Resend API key + system email address |
|
||||
| **Email (SMTP)** | Host, port, username, password, TLS toggle + system email |
|
||||
| **S3 Storage** | Bucket name, endpoint URL (optional for AWS) |
|
||||
| **Google OAuth** | Client ID + Client Secret |
|
||||
| **Unsplash** | Access Key |
|
||||
|
||||
## Confirmation
|
||||
|
||||
After completing all steps, the wizard shows a summary of your configuration. You can:
|
||||
|
||||
- **Proceed** — Generate files and optionally start the deployment
|
||||
- **Edit** — Go back and change any step
|
||||
- **Cancel** — Abort without generating anything
|
||||
|
||||
## Generated Files
|
||||
|
||||
After confirmation, the wizard creates:
|
||||
|
||||
```
|
||||
{installDir}/
|
||||
├── docker-compose.yml # Service definitions
|
||||
├── .env # All configuration variables
|
||||
├── learnhouse.config.json # CLI metadata
|
||||
└── extra/
|
||||
├── Caddyfile # If auto-SSL enabled
|
||||
└── nginx.prod.conf # If manual SSL or HTTP
|
||||
```
|
||||
|
||||
## Docker Services
|
||||
|
||||
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-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) |
|
||||
|
||||
<Callout type="info">
|
||||
The wizard optionally starts the deployment and waits up to 3 minutes for the health check (`/api/v1/health`) to pass before showing your credentials and URL.
|
||||
</Callout>
|
||||
|
||||
## Release Channels
|
||||
|
||||
During setup you choose a release channel:
|
||||
|
||||
- **Stable** — Recommended for production
|
||||
- **Dev** — Bleeding edge, latest features
|
||||
- **Custom** — Specify an exact image tag
|
||||
Reference in New Issue
Block a user