# TaskPlaner

A simple task and thought capture app. Quickly add tasks, thoughts, and notes from any device.

## Developing

Install dependencies and start a development server:

```sh
npm install
npm run dev
```

## Building

To create a production version of your app:

```sh
npm run build
```

## Docker Deployment

### Quick Start

```bash
# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down
```

The application will be available at http://localhost:3000

### Configuration

Copy `.env.example` to `.env` and customize:

```bash
cp .env.example .env
```

Key settings:
- `ORIGIN` - Required for production. Set to your public URL (e.g., `https://tasks.example.com`)
- `BODY_SIZE_LIMIT` - Max upload size. Default: `512kb`, recommended: `10M`
- `PORT` - Server port inside container. Default: `3000`

### Behind a Reverse Proxy

When running behind nginx, traefik, or similar, uncomment these in `.env`:

```bash
PROTOCOL_HEADER=x-forwarded-proto
HOST_HEADER=x-forwarded-host
ADDRESS_HEADER=x-forwarded-for
XFF_DEPTH=1
```

### Data Persistence

Data is stored in a Docker named volume (`taskplaner_data`). This includes:
- SQLite database (`/app/data/taskplaner.db`)
- Uploaded images (`/app/data/uploads/`)

The volume persists across container restarts and updates.

### Backup & Restore

Create a backup:
```bash
./backup.sh
```

Backups are saved to `./backups/` with timestamps.

Restore from backup:
```bash
# Stop the container first
docker-compose down

# Restore (replace TIMESTAMP with actual backup filename)
docker run --rm \
  -v taskplaner_taskplaner_data:/data \
  -v $(pwd)/backups:/backup \
  alpine tar xzf /backup/taskplaner_backup_TIMESTAMP.tar.gz -C /data

# Start the container
docker-compose up -d
```

### Health Check

The container includes a health check at `/health`. View status:

```bash
docker-compose ps
```

A healthy container shows `(healthy)` in the status column.
