Files
TimeTracker/INTEGRATION_REFACTORING_PLAN.md
Dries Peeters 0ec6b8e9d6 refactor: major integration system overhaul with global integrations support
This commit implements a comprehensive refactoring of the integration system to support both global (shared) and per-user integrations, adds new integrations, and improves the overall architecture.

Key changes:

- Add global integrations support: most integrations are now shared across all users (Jira, Slack, GitHub, Asana, Trello, GitLab, Microsoft Teams, Outlook Calendar, Xero)

- Add new integrations: GitLab, Microsoft Teams, Outlook Calendar, and Xero

- Database migrations:

  * Migration 081: Add OAuth credential columns for all integrations to Settings model

  * Migration 082: Add is_global flag to Integration model and make user_id nullable

- Update Integration model to support global integrations with nullable user_id

- Refactor IntegrationService to handle both global and per-user integrations

- Create dedicated admin setup pages for each integration

- Update Trello connector to use API key setup instead of OAuth flow

- Enhance all existing integrations (Jira, Slack, GitHub, Google Calendar, Asana, Trello) with global support

- Update routes, templates, and services to support the new global/per-user distinction

- Improve integration management UI with better separation of global vs per-user integrations

- Update scheduled tasks to work with the new integration architecture
2025-11-29 07:03:00 +01:00

2.2 KiB

Integration System Refactoring Plan

Issues Identified

  1. Double Pages: /calendar/integrations and /integrations - duplicate functionality
  2. OAuth Requirements: Some integrations (Trello) don't need OAuth but are using OAuth flow
  3. Global vs Per-User: All integrations are currently per-user, but should be global (except Google Calendar)
  4. Setup Pages: Need dedicated setup pages for each integration instead of all in one settings page

Solution

1. Database Changes

  • Migration 082: Add is_global flag to Integration model
  • Make user_id nullable for global integrations
  • Add constraint: global integrations must have user_id = NULL

2. Integration Classification

Global Integrations (shared across all users):

  • Jira
  • Slack
  • GitHub
  • Outlook Calendar
  • Microsoft Teams
  • Asana
  • Trello (API key based, not OAuth)
  • GitLab
  • QuickBooks
  • Xero

Per-User Integrations:

  • Google Calendar (each user connects their own)

3. OAuth vs API Key Requirements

OAuth Required:

  • Jira (OAuth 2.0)
  • Slack (OAuth 2.0)
  • GitHub (OAuth 2.0)
  • Google Calendar (OAuth 2.0) - per-user
  • Outlook Calendar (OAuth 2.0)
  • Microsoft Teams (OAuth 2.0)
  • Asana (OAuth 2.0)
  • GitLab (OAuth 2.0)
  • QuickBooks (OAuth 2.0)
  • Xero (OAuth 2.0)

API Key Based (no OAuth):

  • Trello (API Key + Token)

4. Implementation Steps

  1. Create migration for global integrations
  2. Update Integration model
  3. Update IntegrationService to handle global integrations
  4. Create admin setup pages for each integration
  5. Fix Trello connector to use API key setup (not OAuth)
  6. Remove duplicate calendar integrations page
  7. Update routes to use global integrations
  8. Update integration list page to show global vs per-user

Files to Modify

  1. app/models/integration.py - Add is_global, make user_id nullable
  2. app/services/integration_service.py - Handle global integrations
  3. app/routes/integrations.py - Update to handle global
  4. app/routes/admin.py - Add setup routes for each integration
  5. app/integrations/trello.py - Fix to use API key setup
  6. app/routes/calendar.py - Remove duplicate integrations page
  7. app/templates/integrations/ - Create setup templates