Skip to content

Development Documentation

Welcome to the Development documentation for App Suite for Teams.

Overview

This section contains comprehensive guides for developers working on App Suite for Teams, including architecture decisions, testing strategies, and development workflows.

Getting Started

For initial setup and development environment configuration, see the main README.md in the repository root.

Quick Start

# First-time setup: Create database
DATABASE_ADMIN_USER=postgres pnpm create:database

# Start backend (includes database migrations)
pnpm dev  # Runs on http://127.0.0.1:8080

# Start UI development server (separate terminal)
pnpm vite dev  # Runs on https://localhost:5173

# Access application at: https://localhost:5173
# Login with: <your-username>@teams

Authentication

Keycloak Token Exchange

Detailed guide on authentication flow using Keycloak token exchange with impersonation (RFC 8693).

Key Concepts:

  • User JWTs issued by Switchboard (not Keycloak)
  • Teams validates Switchboard tokens locally
  • Internal token exchange with impersonation for App Suite Middleware access
  • No external IDP configuration needed in Keycloak

Internationalization (i18n)

i18n Workflow:

# Update translations after changing i18n strings
pnpm msgmerge

# Extract strings from PO files
msggrep -K -e "pattern" ui/i18n/*.po

# Format and compile translations
msgfmt --check ui/i18n/en_US.po

Development Workflow

Technology Stack

  • Backend: Fastify (Node.js >=20), PostgreSQL, Drizzle ORM
  • Frontend: Vue 3, Vite, UnoCSS, Pinia
  • Real-time: WebSockets, Yjs, TipTap
  • Testing: Vitest (unit), Playwright (E2E)
  • Package Manager: pnpm (10.18.1+)

Key Commands

# Run unit tests
pnpm test

# Run E2E tests
pnpm e2e

# Lint and auto-fix
pnpm lint

# Build production bundle
pnpm build

# Generate database migrations
npx drizzle-kit generate

# Update OpenAPI spec
pnpm update:openapi

Database Development

Schema Management

  • ORM: Drizzle ORM (minimal overhead, SQL-like)
  • Migrations: Auto-generated in drizzle/ from src/db/schema/schema.js
  • Dev workflow: pnpm dev auto-pushes schema changes
# Generate migration from schema changes
npx drizzle-kit generate

# Push schema directly to database (dev only)
npx drizzle-kit push

# Apply migrations manually
npx drizzle-kit migrate

Environment Configuration

Key environment variables (set in .env):

Database:

  • DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_SSL

Service:

  • PORT (default 8080), BIND_ADDR, LOG_LEVEL

Authentication:

  • ISSUER_URL, OPENID_CLIENT_ID, OPENID_CLIENT_SECRET (Keycloak)
  • SERVICE_TOKEN, JWKS_DOMAIN, SWITCHBOARD_API_PATH (Switchboard legacy)

App Suite Integration:

  • APP_SUITE_APP_ID, FRONTEND_URIS

Development:

  • HOST_KEY, HOST_CRT (SSL certificates for Vite dev server)

Code Style

  • ESLint: @antfu/eslint-config with custom rules
  • Auto-fix: On commit via a lefthook pre-commit hook (lefthook.yml), installed by pnpm install. Clones that still use the old Husky hooks switch once with git config --unset core.hooksPath && pnpm i.
  • Import style: Auto-imports for Vue, components, utilities

Commit Message Style

Follow keep-a-changelog format:

  • Add - New features
  • Update - Changes to existing functionality
  • Fix - Bug fixes
  • Remove - Removed features
  • Change - Refactoring

Example:

Add: Track work status of the thread
Update dependency vue to v3.5.22
Fix: Handle expired service tokens gracefully

Remote Development

Okteto

# Start remote development environment
okteto up

See okteto.yml for configuration details.

Architecture

Architecture Decision Records (ADRs)

All significant architectural decisions are documented using ADRs following the format proposed by Michael Nygard.

Recorded Decisions:

  1. Record architecture decisions
  2. Use Vue.js as frontend framework
  3. Use Vue Router for navigation
  4. CSS framework decisions (UnoCSS)
  5. Use tree structure in sidepanel
  6. Introduce database layer (PostgreSQL + Drizzle ORM)
  7. Introduce Yjs for real-time state sharing
  8. Use custom WebSocket implementation for Yjs
  9. Ignore sent items when fetching threads
  10. Use OIDC client credentials grant (superseded)
  11. Implement standard token exchange for authorization
  12. Use local DOMPurify implementation
  13. Error tracking with Sentry-compatible endpoints
  14. OIDC Authorization Code Flow
  15. Deactivate cross-browser E2E tests
  16. Support public IMAP folders
  17. Background mail sync (stale-while-revalidate)
  18. Parse HTML message previews server-side
  19. Helm pre-install hooks for database migration (superseded)
  20. Plain Job with rotation token for database migration
  21. External submission endpoint
  22. Session forwarding authentication mode
  23. Server-side thread events via PostgreSQL LISTEN/NOTIFY

Quality Attributes

Key Architectural Patterns

Backend Architecture:

  • Fastify with autoload pattern - Plugin and route auto-loading
  • PostgreSQL + Drizzle ORM - Type-safe database access
  • WebSocket support - Real-time collaborative editing (Yjs)
  • Thread events - PostgreSQL LISTEN/NOTIFY fanned out over Server-Sent Events (ADR-0023)
  • JWT authentication - Token-based security

Frontend Architecture:

  • Vue 3 SPA - Component-based UI with Composition API
  • Microfrontend pattern - Integration with App Suite core
  • Pinia state management - Centralized reactive state
  • UnoCSS - Utility-first atomic CSS

Real-time Collaboration:

  • Yjs (CRDT) - Conflict-free replicated data types
  • Custom WebSocket transport - Own y-websocket compatible sync server, replicas synced over Redis (ADR-0029)
  • PostgreSQL persistence - One snapshot per thread in yjs_documents (ADR-0028)
  • TipTap editor - Rich text editing with collaborative extensions

Testing

Testing Strategy

App Suite for Teams uses a comprehensive testing approach:

  • Unit Tests (Vitest) - ~75% coverage for unit-testable code
  • E2E Tests (Playwright) - Full user workflows across browsers
  • Test Specifications - Detailed test scenarios and acceptance criteria

Testing Guides

Test Organization

Unit Tests (spec/):

  • Backend: Routes, plugins, database tests
  • Frontend: Components, Pinia stores

E2E Tests (e2e/):

  • Full user workflows
  • Multi-user collaboration
  • Real-time synchronization
  • Cross-browser compatibility (Chromium, Firefox, WebKit)

Test Specifications (docs/development/testing/specs/):

  • Detailed test scenarios for each feature
  • Acceptance criteria documentation

Running Tests

# Run unit tests
pnpm test

# Run E2E tests
pnpm e2e

# Run specific test
npx vitest spec/path/to/test.js