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>@teamsAuthentication
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.poDevelopment 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:openapiDatabase Development
Schema Management
- ORM: Drizzle ORM (minimal overhead, SQL-like)
- Migrations: Auto-generated in
drizzle/fromsrc/db/schema/schema.js - Dev workflow:
pnpm devauto-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 migrateEnvironment 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-configwith custom rules - Auto-fix: On commit via a lefthook pre-commit hook (
lefthook.yml), installed bypnpm install. Clones that still use the old Husky hooks switch once withgit 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 gracefullyRemote Development
Okteto
# Start remote development environment
okteto upSee 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:
- Record architecture decisions
- Use Vue.js as frontend framework
- Use Vue Router for navigation
- CSS framework decisions (UnoCSS)
- Use tree structure in sidepanel
- Introduce database layer (PostgreSQL + Drizzle ORM)
- Introduce Yjs for real-time state sharing
- Use custom WebSocket implementation for Yjs
- Ignore sent items when fetching threads
- Use OIDC client credentials grant (superseded)
- Implement standard token exchange for authorization
- Use local DOMPurify implementation
- Error tracking with Sentry-compatible endpoints
- OIDC Authorization Code Flow
- Deactivate cross-browser E2E tests
- Support public IMAP folders
- Background mail sync (stale-while-revalidate)
- Parse HTML message previews server-side
- Helm pre-install hooks for database migration (superseded)
- Plain Job with rotation token for database migration
- External submission endpoint
- Session forwarding authentication mode
- Server-side thread events via PostgreSQL LISTEN/NOTIFY
Quality Attributes
- Security - Security considerations, threat model, and security practices
- Non-Functional Requirements (NFR) - Performance, scalability, reliability, and other 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
- Unit Testing Guide - Comprehensive guide for unit testing with Vitest
- E2E Testing Guide - Complete guide for end-to-end testing with Playwright
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
