Skip to main content

Impact Analysis

Understand the ripple effects of code changes before you make them.

What is Impact Analysis?

Impact analysis answers the question: "If I change this file, what else will be affected?"

This helps you:

  • Plan changes more carefully
  • Identify required tests
  • Avoid unexpected breakages
  • Estimate effort for changes

Running Impact Analysis

Web Interface

  1. Select a project
  2. Click on a file in the visualization
  3. Click Analyze Impact

CLI

> /analyze src/services/user.ts

API

curl -X POST https://api.archicore.io/api/v1/projects/:id/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"path": "src/services/user.ts"}'

Understanding Results

Impact Analysis for src/services/user.ts

╭─────────────────────────────────────────╮
│ Direct Dependencies (5) │
├─────────────────────────────────────────┤
│ → src/utils/crypto.ts │
│ → src/db/models/user.ts │
│ → src/config/auth.ts │
│ → src/types/user.ts │
│ → src/utils/validation.ts │
╰─────────────────────────────────────────╯

╭─────────────────────────────────────────╮
│ Dependents - Will Be Affected (8) │
├─────────────────────────────────────────┤
│ ← src/controllers/auth.ts │
│ ← src/controllers/profile.ts │
│ ← src/controllers/admin.ts │
│ ← src/middleware/auth.ts │
│ ← src/services/session.ts │
│ ← src/api/routes/users.ts │
│ ← tests/user.test.ts │
│ ← tests/auth.test.ts │
╰─────────────────────────────────────────╯

Risk Level: MEDIUM
Affected Tests: 2

Impact Levels

LevelDescriptionAction
LowFew dependents, isolated changeProceed with standard review
MediumMultiple dependents, moderate riskThorough testing recommended
HighMany dependents, core moduleExtensive testing, consider phased rollout
CriticalAffects critical pathsExtra review, feature flags recommended

Simulating Changes

Preview the impact of a proposed change:

> /simulate
Describe your change: Adding a new parameter to UserService.getUser()

Simulation Results:

Files that need updates:
1. src/controllers/auth.ts:34 - calls getUser()
2. src/controllers/profile.ts:12 - calls getUser()
3. src/services/session.ts:45 - calls getUser()

Tests that need updates:
1. tests/user.test.ts - 5 test cases call getUser()
2. tests/auth.test.ts - 3 test cases call getUser()

Estimated effort: Medium (8 files, 15 call sites)

Best Practices

Before Making Changes

  1. Run impact analysis on files you plan to modify
  2. Review the dependency chain - understand the blast radius
  3. Identify affected tests - ensure they're updated
  4. Check for circular dependencies - they amplify impact

Reducing Impact

  1. Use interfaces - Depend on abstractions
  2. Apply SOLID principles - Single responsibility limits impact
  3. Decouple modules - Reduce direct dependencies
  4. Write facade layers - Shield implementation details

Example: Safe Refactoring

// Before: Direct dependency
// Changing User affects all consumers
class UserController {
constructor(private userService: UserService) {}
}

// After: Interface dependency
// Changing UserService implementation doesn't affect consumers
interface IUserService {
getUser(id: string): Promise<User>;
}

class UserController {
constructor(private userService: IUserService) {}
}

Integration with CI/CD

Add impact analysis to your pipeline:

# .gitlab-ci.yml
impact-analysis:
script:
- archicore analyze --changed-files
- if [ $IMPACT_LEVEL == "critical" ]; then
echo "Critical impact detected - requires additional review";
exit 1;
fi