# Productier

A calm, lightweight productivity workspace combining calendar planning, kanban task management, notes, focus sessions, mail-based task capture, and CRM capabilities.

## Quick Start

```bash
# Install dependencies
npm install

# Generate API client
npm run gen:api

# Copy environment file
cp .env.example .env

# Start backend services (Postgres, Auth, API)
docker compose up -d

# Run frontend
npm run dev
```

**Service URLs:**
- Frontend: http://localhost:5173
- API: http://localhost:48080
- Auth: http://localhost:43001

## Features

### Core Productivity
- **Today Dashboard** - Daily overview with due tasks, agenda, and focus minutes
- **Inbox** - Quick capture for ideas and tasks
- **Calendar** - Month/week/day views with drag/drop rescheduling
- **Board (Kanban)** - Custom groups with reorder/recolor, drag/drop
- **List View** - Table/spreadsheet view with sorting and filtering
- **Timeline** - 2-week visual project overview
- **Notes** - Fast markdown editing with autosave
- **Focus** - Pomodoro-style sessions with history

### CRM
- **Contacts** - Manage people with company linking
- **Companies** - Track organizations with industry/size
- **Contact Linking** - Link contacts to tasks and events

### Mail
- IMAP/SMTP mailbox connection
- Inbox sync
- Convert emails to tasks
- Send/schedule outgoing mail

### Integrations
- **Webhooks** - Send events to external services
- **Integration Framework** - Connect Google Calendar, Slack, etc.
- **Notifications** - In-app notification center

### Collaboration
- Multi-member workspaces
- Roles: owner, admin, member
- Invite system
- Real-time presence indicators

### Quality of Life
- Command palette (Cmd/Ctrl+K)
- Global search (Cmd/Ctrl+/)
- Time tracking per task
- Recurring tasks/events
- Task attachments (20MB max)
- Offline support with sync queue

## Architecture

| Component | Tech | Port |
|-----------|------|------|
| Frontend | SolidStart + SolidJS | 5173 |
| API | Go + Gin | 48080 |
| Auth | Better Auth (Node.js) | 43001 |
| Database | PostgreSQL | 5432 |
| Storage | Local or S3-compatible | - |

**Key packages:**
- `packages/openapi` - OpenAPI 3.1 contract
- `packages/api-client` - Generated TypeScript client
- `packages/openclaw-plugin` - OpenClaw AI plugin

## Common Commands

```bash
# Development
npm run dev              # Frontend only
npm run dev:backend      # Backend stack in Docker
npm run dev:full         # Frontend + auth + API (no Docker)

# Build & Test
npm run build            # Build all
npm run ci               # CI gate (build + tests)
npm run test:api         # Go tests

# API Generation
npm run gen:api          # Generate TS client from OpenAPI

# Production
npm run check:prod-env   # Validate production env
npm run ops:deploy       # Deploy + health checks
npm run ops:backup       # Create backup
npm run ops:smoke        # Post-deploy smoke tests
```

## Production Deployment

1. Create production env:
```bash
cp .env.production.example .env.production
```

2. Configure required values:
- `PUBLIC_DOMAIN`, `PUBLIC_URL`, `TLS_EMAIL`
- `BETTER_AUTH_SECRET`, `MAIL_ENCRYPTION_KEY`
- `POSTGRES_PASSWORD`, `S3_ACCESS_KEY`, `S3_SECRET_KEY`
- SMTP settings for magic links
- `CORS_ALLOW_ORIGINS`

3. Deploy:
```bash
npm run ops:deploy
```

Gateway routing (single domain):
- `/` → Frontend
- `/v1/*` → API
- `/api/auth/*` → Auth service

## Environment Reference

**Core:**
- `APP_ENV` - development, staging, production
- `DATABASE_URL` - PostgreSQL connection string
- `BETTER_AUTH_SECRET` - Auth secret key
- `CORS_ALLOW_ORIGINS` - Allowed origins (required in production)

**Auth:**
- `AUTH_MAGIC_LINK_PROVIDER` - `dev-mailbox` or `smtp`
- `AUTH_SMTP_*` - SMTP settings for magic links

**Storage:**
- `FILE_STORAGE_PROVIDER` - `local` or `s3`
- `S3_*` - S3 configuration

**Full reference:** See `.env.example` and `.env.production.example`

## OpenClaw Plugin

The `packages/openclaw-plugin` provides AI agent tools:

**Profiles:**
- `readonly` - List workspaces and tasks
- `standard` - Full access to tasks, calendar, notes, mail

**Available tools:**
- Workspace/task/board/calendar/notes CRUD
- Mailbox management and sync
- Outgoing mail and task creation from emails

```bash
npm run openclaw:describe  # List tools
npm run openclaw:check     # Run tests
```

## Backup & Restore

```bash
npm run ops:backup         # Create backup
npm run ops:restore:drill  # Non-destructive drill
npm run ops:smoke          # Health checks
```

Backups stored in `./backups/<timestamp>/` with:
- `postgres.sql.gz` - Database dump
- `s3/` - Object storage
- `checksums.sha256` - Integrity check

Full runbook: `docs/operations-disaster-recovery.md`

## Repository Structure

```
apps/
  frontend/          # SolidStart web app
  backend/           # Go API
    auth-service/    # Better Auth service
packages/
  openapi/           # OpenAPI 3.1 contract
  api-client/        # Generated TS client
  openclaw-plugin/   # AI agent plugin
infra/
  docker-compose.yml      # Local stack
  docker-compose.prod.yml # Production stack
  Caddyfile              # Reverse proxy
  systemd/               # Backup timers
```

## License

MIT