# Deploy on StartOS 0.4.0

This file documents how to build and deploy YouTube Summarizer on StartOS 0.4.0.

## Prerequisites

- Docker with `buildx` support (for ARM64 cross-compilation)
- `start-sdk` CLI tool installed ([docs.start9.com](https://docs.start9.com))
- Git (required by `start-sdk pack`)

## 0) One-time Git setup

`start-sdk pack` requires a Git repository in the project folder.

```bash
cd /Users/macpro/Projects/youtube-summarizer
git init
git add .
git commit -m "Initial commit for Start9 packaging"
```

## 1) Build package

```bash
cd /Users/macpro/Projects/youtube-summarizer

# For x86_64 servers (Intel NUC, mini PC, custom build) — the default:
make -C start9/0.4 package

# For ARM64 servers (Raspberry Pi, Start9 original hardware):
make -C start9/0.4 package PLATFORM=linux/arm64
```

This creates:
- `start9/0.4/image.tar` (Docker image for your server's architecture)
- `start9/0.4/youtube-summarizer.s9pk` (installable package)

## 2) Upload to StartOS

1. Open the StartOS web UI.
2. Go to Services > Sideload Package.
3. Upload `start9/0.4/youtube-summarizer.s9pk`.
4. Install and start the service.

## 3) First run

1. Open the service UI.
2. Go to Settings and enter your Gemini API key.
3. (Recommended) Set up YouTube OAuth authentication.
4. Run a manual StartOS backup.

## 4) Data persistence

All user data lives in `/data` on the StartOS service volume:
- `/data/history/` — processed summaries, subscriptions, queue state
- `/data/config/` — StartOS-managed configuration + processing config
- `/data/cookies.txt` — YouTube cookie file (if uploaded)
- `/data/bin/` — runtime-updated yt-dlp binary
- `/data/ytdlp-cache/` — yt-dlp cache (OAuth tokens)
- `/data/.env` — optional env overrides

This contract must be preserved across package versions.

Key config files:
- `config/startos-config.json` — Gemini API key (set from UI)
- `config/processing-config.json` — background queue delay + enabled state
- `history/subscriptions.json` — subscriptions (with autoDownload flag)
- `history/auto-queue.json` — processing queue state (survives restarts)

## 5) Updating the package

1. Make changes to the app or wrapper.
2. Bump `version` in `start9/0.4/manifest.yaml`.
3. Rebuild: `make -C start9/0.4 package`
4. Sideload the new `.s9pk` — StartOS will upgrade in place.
5. All data in `/data` is preserved across upgrades.
