# 예제

> 기능별 Collaboration SDK 예제를 실행하고 가이드와 서버·Web 진입점을 확인합니다.

- Human documentation: [https://docs.univer.ai/ko-KR/server/collaboration/examples](https://docs.univer.ai/ko-KR/server/collaboration/examples)

- Agent Markdown: [https://docs.univer.ai/ko-KR/server/collaboration/examples.md](https://docs.univer.ai/ko-KR/server/collaboration/examples.md)

- Requested language: `ko-KR`

- Content language: `ko-KR`

- Documentation version: `1.0.4`

- Source: [collaboration/examples.ko-KR.mdx](https://github.com/dream-num/documentation/blob/dev/content/server/collaboration/examples.ko-KR.mdx)

---

모든 예제는 [univer-collaboration-examples](https://github.com/dream-num/univer-collaboration-examples)에 있습니다. 같은 최소 `web/main.ts + server/main.ts` 구조로 독립 실행됩니다. 빠른 시작을 완료한 후 통합 작업에 맞는 예제를 선택하세요.

| 예제                              | 핵심 개념         | 명령                              |
| ------------------------------- | ------------- | ------------------------------- |
| [빠른 시작](#quick-start)           | 핵심 협업 경로      | `pnpm example:quick-start`      |
| [데이터베이스 어댑터](#database-adapter) | 데이터베이스 어댑터    | `pnpm example:database-adapter` |
| [권한](#permissions)              | 신원 확인과 권한 부여  | `pnpm example:permissions`      |
| [기록](#history)                  | 파생 버전 기록      | `pnpm example:history`          |
| [댓글](#comments)                 | 독립 댓글         | `pnpm example:comments`         |
| [Worktree](#worktree)           | 격리 편집·병합      | `pnpm example:worktree`         |
| [파일 변환](#exchange)              | Office 파일 변환  | `pnpm example:exchange`         |
| [다중 노드 배포](#multi-node)         | 문서별 다중 노드 라우팅 | `pnpm example:multi-node`       |

## 빠른 시작

Collaboration Client, Transport, Endpoint, Service, Memory Adapter를 조합합니다. 두 브라우저에서 같은 Sheet의 HTTP 로드, WebSocket Session, Room, ACK, 브로드캐스트를 확인합니다.

```bash
pnpm example:quick-start
```

`http://127.0.0.1:3010/?unit=quick-start-sheet&type=2`를 엽니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/web/main.ts)
* [이 사이트의 단계별 가이드](https://docs.univer.ai/ko-KR/server/collaboration/quick-start.md)

## 데이터베이스 어댑터

내장 SQLite Adapter의 사용법과 사용자 정의 Database Adapter의 구현을 보여줍니다.

```bash
pnpm example:database-adapter
```

`http://127.0.0.1:3010/?unit=persistent-sheet&type=2`를 엽니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/web/main.ts)

## 권한

Cookie로 신뢰할 수 있는 신원을 만들고 Unit HTTP 읽기, 실시간 JOIN, 변경 집합 제출을 각각 보호합니다. 페이지에서 교육용 **Alice · Editor**와 읽기 전용 **Bob · Viewer**를 전환합니다.

```bash
pnpm example:permissions
```

`http://127.0.0.1:3010`를 엽니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/web/main.ts)
* [신원 확인·권한 가이드](https://docs.univer.ai/ko-KR/server/collaboration/identity-and-authorization.md)

## 기록

핵심 밖에 History Service, 독립 Adapter, History Endpoint, 브라우저 기록 진입점을 추가합니다. Unit 생성·변경 커밋 Events로 재구축 가능한 파생 기록 인덱스를 만듭니다.

```bash
pnpm example:history
```

`http://127.0.0.1:3010/?unit=history-sheet&type=2`를 열고 Sheet를 편집한 뒤 상단의 `History`를 선택합니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/web/main.ts)

## 댓글

Thread Comment Service, 독립 Adapter, Comment Endpoint, 프런트엔드 댓글 진입점을 추가합니다. Comment Endpoint는 주 협업 Endpoint의 Session과 Unit Room을 재사용합니다.

```bash
pnpm example:comments
```

`http://127.0.0.1:3010/?unit=comments-sheet&type=2`를 열고 셀을 선택해 댓글 기능을 사용합니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/web/main.ts)

## Worktree

격리 초안, Ready, Reopen, Unit별 Merge 수명 주기를 보여줍니다. 트렁크와 초안을 전환해 병합 전 AI Agent 변경의 격리를 확인합니다.

```bash
pnpm example:worktree
```

`http://127.0.0.1:3010/?unit=worktree-sheet&type=2&worktree=demo-worktree`를 엽니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/server/main.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/web/main.ts)
* [CLI·사람 검토 흐름](https://docs.univer.ai/ko-KR/ai/worktree.md)

## 파일 변환

`@univerjs-pro/exchange-node`와 Collaboration Service로 서버 Sheet 가져오기·내보내기, 작업 폴링, 스냅샷 가져오기, 확정 리비전 내보내기를 구성합니다.

```bash
pnpm example:exchange
```

`http://127.0.0.1:3010/?unit=exchange-sheet&type=2`를 엽니다. \*\*File → Open (File)\*\*로 가져오고 **File → Save As**로 내보냅니다.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/README.md)
* [서버 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/server/main.ts)
* [파일 변환 흐름](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/server/exchange.ts)
* [Web 진입점](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/web/main.ts)

## 다중 노드 배포

다중 노드 배포를 통해 문서별 협업 부하를 여러 서버 노드로 분산하여 각 노드의 부담을 줄이고 전체 동시 처리 능력을 높입니다.

```bash
pnpm example:multi-node
```

`http://127.0.0.1:3010/`를 열고 **New Sheet**를 클릭해 파일을 만듭니다. 전체 URL을 다른 탭에 복사하여 같은 문서의 협업 편집을 확인하세요. 파일을 몇 개 더 만들어 여러 노드에 어떻게 할당되는지 살펴보세요.

* [예제 가이드](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/multi-node/README.md)

> [!NOTE: 예제는 운영 애플리케이션이 아닙니다]
> 고정 사용자, 교육용 권한, Memory Adapter, 로컬 비밀 정보, 메모리 파일·작업 저장소는 학습용입니다. 신원 확인, 권한, 영속성, 비밀 정보, 파일, 배포, 제품 상호작용은 애플리케이션이 담당합니다.
