Files
Docwell/README.md
T
tajniak81andClaude Opus 5.5 b9be8be156
CI / go (Server) (push) Failing after 22m50s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m47s
CI / desktop (ubuntu-latest) (push) Successful in 2h56m50s
CI / mobile (push) Failing after 5m33s
CI / docker (push) Successful in 1h43m8s
Docs / build (push) Successful in 16m2s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Run docwell-db as a stock PocketBase and let the server set it up
docwell-db no longer needs a Docwell image: the stack runs
tajniak81/pocketbase-docker-root as it is, and docwell-server does what
the migrations and pb_hooks used to do inside PocketBase.

On start, docwell-server now:
- waits for PocketBase and imports Docwell's collections from an
  embedded snapshot (internal/pbschema). Existing collections and
  fields are matched by name, so their data is kept; the admin-managed
  users options (OAuth2 providers, magic link) are left untouched.
- writes the DOCWELL_APP_NAME, DOCWELL_WEB_URL, DOCWELL_MAIL_FROM,
  DOCWELL_SMTP_* and DOCWELL_S3_* settings into PocketBase, as the
  boot hook did.

It also replaces the hook's two routes: token checks use PocketBase's
auth-refresh (the organization name is read as the superuser), and
Docwell's own emails go out over SMTP from the server. PocketBase never
returns the SMTP password, so the server keeps a copy in the
superuser-only instance_settings collection; a password saved before
this change has to be entered once more in the admin panel.

Database/ keeps pb_migrations as the source of the schema;
export-schema.sh regenerates the snapshot from them. Database/Dockerfile
and pb_hooks are removed, the release no longer builds docwell-db, the
AIO image runs PocketBase without migrations or hooks, and the compose
files default DB_IMAGE to the stock image and pass the settings to the
server instead of the database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:09:38 +01:00

148 lines
8.4 KiB
Markdown

# Docwell
An open-source, self-hostable knowledge base and collaborative document editor. It is wiki-first like Docmost and Outline, and will grow Notion-style databases later.
> Status: **Phase 1 (MVP wiki) feature-complete, heading for release 0.1.** Phase 2 ("team ready") is next.
What works today:
- Accounts with email and password, sign-in links by email, invites, sign-up rules and an email-domain allow-list
- Organizations, workspaces, groups, open and private spaces, and a page tree with drag and drop and a trash
- Real-time co-editing with live cursors and page history; a slash menu, a formatting toolbar, mentions, images and file attachments
- Inline comments, favorites, recently visited pages, full-text search with a Ctrl+K palette
- Public read-only share links, Markdown and HTML import and export, Word and Notion import, PDF export
- An admin panel for users and invites, branding, sign-up rules, email, file storage (disk or S3), backups, background jobs and system health
- English and Polish, light and dark themes, phone-sized layouts
User and operator documentation lives in [Docs-Site](Docs-Site) (a VitePress site: `npm run dev:docs`).
## Components
| Folder | What | Stack |
|---|---|---|
| `Database/` | Schema for **docwell-db** (storage, private service), a stock PocketBase that docwell-server sets up | PocketBase v0.40.6, JS migrations |
| `Server/` | **docwell-server**: the only public API, plus the admin panel at `/admin/` | Go 1.26, Vue 3, Tailwind CSS 4 |
| `Web-App/` | **docwell-web**: serves the end-user web app | Go 1.26, Vue 3, Tailwind CSS 4, Tiptap |
| `Desktop-App/` | Desktop app; reuses the web app UI | Wails v3 |
| `Phone-App/` | Mobile app (Android, iOS) | Flutter |
| `Packages/` | Shared frontend code: `@docwell/editor`, `@docwell/ui`, `@docwell/api-client`, and `@docwell/editor-bridge` (the editor as one HTML page for the phone app's WebView) | TypeScript |
| `Docker/` | The three services as separate containers | docker compose |
| `Docker-AIO/` | Everything in one container | docker compose |
| `Docs-Site/` | User and operator documentation | VitePress |
## Quick start (Docker)
```bash
cd Docker
cp .env.example .env # change the passwords
docker compose up -d # released images; add --build to build this checkout
```
- Web app: http://localhost:3000
- API: http://localhost:8080/api/v1/version
- Admin panel: http://localhost:8080/admin/
For production, use `docker-compose.prod.yml` with `.env.prod.example`, or one of its S3 and SeaweedFS variants;
see [Docker/README.md](Docker/README.md) and [Docker-AIO/README.md](Docker-AIO/README.md).
All-in-one container instead (one port, 3000; admin at http://localhost:3000/admin/):
```bash
cd Docker-AIO
PB_ADMIN_PASSWORD=change-me docker compose up -d
```
**The first account you sign up becomes the superadmin**, which unlocks the admin panel. To test sign-up emails (verification, password reset) locally, set `DOCWELL_SMTP_HOST=mailpit` and `DOCWELL_SMTP_PORT=1025` in `.env`, start with `docker compose --profile dev up --build`, and read the emails at http://localhost:8025.
The [quick start guide](Docs-Site/guide/quick-start.md) covers first steps, HTTPS behind a reverse proxy, every configuration variable, and backups and upgrades.
## Authentication
Accounts live in PocketBase's built-in `users` auth collection. PocketBase stores the passwords, issues the tokens, and sends the verification and password-reset emails. It stays private: apps call `/api/v1/auth/*` on docwell-server, which forwards to PocketBase and adds Docwell's rules:
- sign-up on or off and an email-domain allow-list (the admin panel; `DOCWELL_SIGNUP_ENABLED` and `DOCWELL_SIGNUP_DOMAINS` are the defaults)
- invites, which work even with sign-up off
- the first account becomes the superadmin
- disabled accounts (`status = disabled`) can't sign in
Tokens are sent as `Authorization: Bearer <token>`. Sign-in links by email (PocketBase's email OTP) are switched on in the admin panel; MFA and OAuth2 providers are switched on in PocketBase's `users` collection settings, and the web app already handles codes and MFA.
## Organizations and rights
Docwell uses the same model as DriverVault. Every user belongs to at most one **organization** and has a role:
| Role | Can manage |
|---|---|
| `superadmin` | Every organization, user and workspace on the server |
| `admin` | Their own organization: its members (never superadmins) and all of its workspaces |
| `user` | Only the workspaces they were added to |
Workspaces belong to an organization, and rights cascade into them: superadmins and org admins are owners of every workspace in their scope, and everyone else gets their workspace role (`owner` > `admin` > `member` > `guest`). Nobody can grant a role above their own, change someone ranked above them, or change their own role.
Inside a workspace, pages live in **spaces**. Workspace owners and admins administer every space. In an **open** space every workspace member (not guests) gets the space's default role (`editor`, `commenter` or `viewer`); a **private** space is visible only to the people added to it. Space roles rank `admin` > `editor` > `commenter` > `viewer`: editors create, rename, move and trash pages, and space admins manage members and empty the trash. Pages form a tree per space, ordered by fractional position keys, and trashing a page hides its whole subtree until it is restored.
A user without an organization can create one from the web app and becomes its admin. Org admins and superadmins manage users and organizations in the admin panel; workspace members are managed in the web app. The rules live in [Server/internal/access](Server/internal/access/access.go).
## Development
Requirements: Go 1.26+, Node 22+, Rust with the `wasm32-wasip1` target, Flutter 3.44+, Wails CLI v3, and the PocketBase binary (see [Database/README.md](Database/README.md)).
```bash
npm install
```
Run each piece in its own terminal:
```bash
# 1. Database (from Database/). docwell-server creates the collections on start.
./bin/pocketbase superuser upsert admin@docwell.test devpassword123 --dir ./pb_data # once
./bin/pocketbase serve --dir ./pb_data --http 127.0.0.1:8070
# 2. API server (from Server/). Build yrs.wasm once, and again after changing Server/ycrdt-wasm:
# rustup target add wasm32-wasip1 && go generate ./internal/ycrdt
DOCWELL_PB_EMAIL=admin@docwell.test DOCWELL_PB_PASSWORD=devpassword123 go run ./cmd/docwell-server
# 3. Web app with hot reload (from the repo root): http://localhost:5173
npm run dev:web
# 4. Admin panel with hot reload: http://localhost:5174/admin/
npm run dev:admin
# Desktop app (from Desktop-App/)
wails3 dev
# Mobile app (from Phone-App/), e.g. on an Android emulator. Build the editor
# page into its assets first: npm run build -w @docwell/editor-bridge
flutter run
```
Tests and checks (CI runs all of them; see [CONTRIBUTING.md](CONTRIBUTING.md)):
```bash
go test ./Server/... ./Web-App/... ./Desktop-App/
npm run lint && npm run format:check && npm run typecheck && npm test
cd Phone-App && flutter analyze && flutter test
```
Go code is linted with `golangci-lint run` from each module folder.
After changing `api/openapi.yaml`, regenerate the TypeScript, Go and Dart types:
```bash
npm run generate
```
Desktop release builds set the update feed and its signing key; see [Desktop-App/updates.go](Desktop-App/updates.go). Development builds never update themselves.
The documentation site: `npm run dev:docs` (http://localhost:5173) and `npm run build:docs`. The Docs workflow publishes it to GitHub Pages.
### Releases
Push a tag like `v1.0.0` to the Gitea repository. The Release workflow builds `docwell-server`, `docwell-web` and the all-in-one `docwell` image for `linux/amd64` and `linux/arm64` and pushes them to that Gitea's container registry, `<gitea host>/<repository owner>/`. It also builds the Windows and Linux desktop installers and attaches them to a Gitea release for the tag. The macOS DMG is built by hand on a Mac (`wails3 task darwin:package:dmg` in `Desktop-App`) and attached afterwards. The runners, secret and variables it needs are listed at the top of [.github/workflows/release.yml](.github/workflows/release.yml).
The compose files pull from `DOCWELL_REGISTRY` (default `ghcr.io/docwell`) at `DOCWELL_VERSION` (default `latest`). For images from a Gitea registry, set `DOCWELL_REGISTRY=<gitea host>/<repository owner>`.
## License
[GNU Affero General Public License v3.0 or later](LICENSE).