Kind: Service
Source: atloria-monorepo/apps/api/src/documentation/services/workflow-detector.service.ts
Service for detecting business workflows from various sources
Detection strategies:
- Business context files (workflow diagrams, process docs)
- Navigation patterns (sequences of page visits)
- Form sequences (multi-step processes)
- User journey analysis (common paths through the app)
WorkflowDetectorService identifies business workflows from application and documentation signals, including process artifacts, navigation behavior, multi-step forms, and user journey paths. It consolidates these detection strategies into a normalized list of DetectedWorkflow records for downstream documentation, analysis, or workflow visualization features.
Methods
| Method | Signature | Returns | Description |
|---|---|---|---|
detectWorkflows | `detectWorkflows(appMap: any, businessContext: { |
marketing: string[]; workflows: string[]; brand: string[]; processes: string[]; })` | `Promise<DetectedWorkflow[]>` | Detect workflows from multiple sources |
Where it refuses work
WorkflowDetectorServicestops the work with an early return when!appMap.navigation || !appMap.pages.WorkflowDetectorServicestops the work with an early return when!appMap.pages.WorkflowDetectorServicestops the work with an early return whenmatchedPage.WorkflowDetectorServicestops the work with an early return whenfield.type === 'select' || field.type === 'dropdown'.WorkflowDetectorServicestops the work with an early return whenfield.type === 'file'.WorkflowDetectorServicestops the work with an early return whenlower.includes('sale') || lower.includes('order') || lower.includes('purchase').
Diagram
mermaidsequenceDiagram participant Caller as Documentation/Analysis Caller participant Detector as WorkflowDetectorService participant Context as Business Context Sources participant Navigation as Navigation Patterns participant Forms as Form Sequences participant Journeys as User Journey Data Caller->>Detector: detectWorkflows() Detector->>Context: Analyze workflow diagrams and process docs Context-->>Detector: Context-based workflows Detector->>Navigation: Analyze page visit sequences Navigation-->>Detector: Navigation-based workflows Detector->>Forms: Identify multi-step form processes Forms-->>Detector: Form-based workflows Detector->>Journeys: Analyze common application paths Journeys-->>Detector: Journey-based workflows Detector->>Detector: Normalize and consolidate detections Detector-->>Caller: Promise<DetectedWorkflow[]>
Usage
tsimport { Injectable } from '@nestjs/common';
import { WorkflowDetectorService } from './workflow-detector.service';
@Injectable()
export class WorkflowDocumentationService {
constructor(
private readonly workflowDetectorService: WorkflowDetectorService,
) {}
async generateWorkflowDocumentation() {
const workflows = await this.workflowDetectorService.detectWorkflows();
return workflows.map((workflow) => ({
name: workflow.name,
description: workflow.description,
steps: workflow.steps,
}));
}
}
AI Coding Instructions
- Keep
detectWorkflows()as the orchestration entry point; add new detection approaches as isolated strategies rather than embedding unrelated logic in callers. - Normalize results from every source into the shared
DetectedWorkflowshape before returning them. - Treat detected workflows as potentially incomplete or duplicated; deduplicate and validate workflow steps when combining results.
- Preserve asynchronous behavior when integrating file analysis, analytics data, or navigation repositories.
- Register the service in the appropriate NestJS module and inject it through NestJS dependency injection rather than constructing it manually.
Referenced By
DocumentationModule(MODULE_PROVIDES)DocumentationService(DEPENDS_ON)
Was this page helpful?