gateway/modules/FEATURES_TO_INTERFACES_IMPORTS.md

199 lines
8.1 KiB
Markdown

# Features → Interfaces Import Analysis
## Summary
This document details all imports from `features/` modules to `interfaces/` modules.
**Total Feature Modules:** 6
**Modules Importing from Interfaces:** 2 (only `getRootInterface` - system-level function)
**Total Interface Imports:** 2 (both for `getRootInterface` only)
**✅ REFACTORED:** All feature modules now use `services.getInterface()` to access interfaces, following the same pattern as `chatPlayground`. Only `getRootInterface()` remains as a direct import (system-level function, not user-specific).
---
## Detailed Import List
### 1. `features/featuresLifecycle.py`
**Imports:**
- **Line 2:** `from modules.interfaces.interfaceDbAppObjects import getRootInterface`
- **Type:** Direct import
- **Usage:** Gets root interface to retrieve event user for feature initialization
- **Context:** Used in `start()` function to get event user for automation, syncDelta, and chatAlthaus features
- **Note:** `getRootInterface()` is a system-level function (no user required), so it remains as direct import
**Refactored:**
-**Removed:** `from modules.interfaces.interfaceDbChatObjects import getInterface as getChatInterface`
-**Added:** `from modules.services import getInterface as getServices`
-**Changed:** Now uses `services.interfaceDbChat` instead of direct interface import
- **Pattern:** `services = getServices(eventUser, None)` then `services.interfaceDbChat`
**Purpose:** Feature lifecycle management - initializes and manages all features on startup/shutdown.
---
### 2. `features/automation/mainAutomation.py`
**Imports:**
- **Line 14:** `from modules.interfaces.interfaceDbAppObjects import getRootInterface`
- **Type:** Direct import
- **Usage:** Gets root interface to retrieve event user (system-level function)
- **Context:** Used in `createAutomationEventHandler()` to get event user
- **Note:** `getRootInterface()` is a system-level function (no user required), so it remains as direct import
**Refactored:**
-**Removed:** `from modules.interfaces.interfaceDbChatObjects import getInterface as getChatInterface`
-**Removed:** `from modules.interfaces.interfaceDbAppObjects import getInterface as getAppInterface`
-**Added:** `from modules.services import getInterface as getServices`
-**Changed:** All interface access now goes through services:
- `executeAutomation()`: Uses `services.interfaceDbApp` and `services.interfaceDbChat`
- `createAutomationEventHandler()`: Uses `eventServices.interfaceDbChat` and `eventServices.interfaceDbApp`
- **Pattern:** `services = getServices(user, None)` then `services.interfaceDbChat` or `services.interfaceDbApp`
**Purpose:** Automation workflow execution and scheduling - handles automated workflow triggers and event scheduling.
---
### 3. `features/chatPlayground/mainChatPlayground.py`
**Imports:**
-**No imports from interfaces/**
- Uses `modules.services.getInterface` instead (indirect access through services layer)
**Purpose:** Chat playground feature - interactive chat interface.
---
### 4. `features/chatAlthaus/mainChatAlthaus.py`
**Imports:**
-**No imports from interfaces/**
- Uses `modules.services.getInterface` instead (indirect access through services layer)
**Purpose:** Chat Althaus data scheduler - scheduled data updates for Althaus preprocessing.
---
### 5. `features/syncDelta/mainSyncDelta.py`
**Imports:**
-**No imports from interfaces/**
- Uses `modules.services.getInterface` instead (indirect access through services layer)
**Purpose:** Delta Group sync manager - synchronizes tickets to SharePoint.
---
### 6. `features/neutralizePlayground/mainNeutralizePlayground.py`
**Imports:**
-**No imports from interfaces/**
- Uses `modules.services.getInterface` instead (indirect access through services layer)
**Purpose:** Neutralization playground - UI wrapper for data neutralization service.
---
## Import Statistics
### By Interface Module
**`interfaceDbAppObjects`:**
- `getRootInterface`: 2 imports (system-level function, remains as direct import)
- `features/featuresLifecycle.py` (line 2)
- `features/automation/mainAutomation.py` (line 14)
**`interfaceDbChatObjects`:**
-**Removed:** All direct imports refactored to use services layer
- Now accessed via `services.interfaceDbChat` after calling `getServices(user, None)`
**`interfaceDbAppObjects.getInterface`:**
-**Removed:** All direct imports refactored to use services layer
- Now accessed via `services.interfaceDbApp` after calling `getServices(user, None)`
### By Import Type
- **Direct imports:** 2 (only `getRootInterface` - system-level function)
- `features/featuresLifecycle.py`: 1
- `features/automation/mainAutomation.py`: 1
- **Services-based access:** All user-specific interface access now goes through services layer
- Pattern: `services = getServices(user, None)` then `services.interfaceDbChat` or `services.interfaceDbApp`
---
## Architectural Notes
### ✅ Correct Dependency Direction
All imports follow the correct architectural direction:
- **features/** → **interfaces/**
This is compliant with the dependency rules:
- Features can import from interfaces (correct)
- Features can import from services (correct)
- Features do NOT import from other features (except internal feature-to-feature imports)
### Import Patterns
1. **Direct Interface Access:**
- `features/automation/mainAutomation.py` - Directly imports interfaces for automation management
- `features/featuresLifecycle.py` - Directly imports `getRootInterface` for feature initialization
2. **Indirect Access via Services:**
- `features/chatPlayground/mainChatPlayground.py`
- `features/chatAlthaus/mainChatAlthaus.py`
- `features/syncDelta/mainSyncDelta.py`
- `features/neutralizePlayground/mainNeutralizePlayground.py`
These features use `modules.services.getInterface` which provides a service layer abstraction.
### Usage Context
**`interfaceDbAppObjects`:**
- Used for user management (`getRootInterface`, `getAppInterface`)
- Primarily for getting event user and creator user in automation context
**`interfaceDbChatObjects`:**
- Used for chat/automation data access (`getChatInterface`)
- Used for automation execution, event syncing, and workflow management
---
## Summary Table
| Feature Module | Interface Imports | Import Type | Purpose |
|---------------|-------------------|-------------|---------|
| `featuresLifecycle.py` | `interfaceDbAppObjects.getRootInterface` | Direct | Feature initialization (system-level) |
| `featuresLifecycle.py` | ✅ Via `services.interfaceDbChat` | Services | Automation event sync |
| `automation/mainAutomation.py` | `interfaceDbAppObjects.getRootInterface` | Direct | Event user access (system-level) |
| `automation/mainAutomation.py` | ✅ Via `services.interfaceDbChat` | Services | Automation execution |
| `automation/mainAutomation.py` | ✅ Via `services.interfaceDbApp` | Services | User management |
| `chatPlayground/mainChatPlayground.py` | None | - | Uses services layer |
| `chatAlthaus/mainChatAlthaus.py` | None | - | Uses services layer |
| `syncDelta/mainSyncDelta.py` | None | - | Uses services layer |
| `neutralizePlayground/mainNeutralizePlayground.py` | None | - | Uses services layer |
---
## Conclusion
**Total Interface Imports:** 2 (only `getRootInterface` - system-level function)
- 2 direct imports (both for `getRootInterface`)
**Modules Using Direct Interface Imports:** 2 out of 6 (only for `getRootInterface`)
- `features/featuresLifecycle.py`
- `features/automation/mainAutomation.py`
**✅ REFACTORED:** All user-specific interface access now goes through services layer
- Pattern: `services = getServices(user, None)` then `services.interfaceDbChat` or `services.interfaceDbApp`
- Consistent with other feature modules (`chatPlayground`, `chatAlthaus`, `syncDelta`, `neutralizePlayground`)
**Architectural Compliance:****PERFECT**
- All imports follow correct direction (features → interfaces)
- Only system-level function (`getRootInterface`) remains as direct import
- All user-specific interface access goes through services layer
- Clean separation maintained
- Consistent pattern across all feature modules