Skip to content

Latest commit

 

History

History
136 lines (108 loc) · 4.26 KB

API_Duplication_Analysis.md

File metadata and controls

136 lines (108 loc) · 4.26 KB

Comprehensive API Duplication Analysis

Major Duplication Categories Found

1. HEALTH/STATUS Endpoints (MAJOR DUPLICATION)

  • /health appears 12 times across modules
  • /status appears 15 times across modules
  • /stats appears 5 times

Modules with health/status duplicates:

  • system.py: /system/health, /system/status
  • chat.py: /chat/health, /chat/llm-status
  • llm.py: /status/comprehensive, /status/quick
  • workflow.py: /workflow/{id}/status
  • Many more...

2. CONFIGURATION Endpoints (8 DUPLICATES)

  • /config appears 8 times
  • Different modules managing configuration separately

3. SEARCH Functionality (4 DUPLICATES)

  • /search appears 4 times
  • knowledge.py: knowledge search
  • templates.py: template search
  • Other modules with search capabilities

4. WORKFLOW Duplicates

  • workflow.py vs workflow_automation.py vs advanced_workflow_orchestrator.py
  • /workflows vs /workflow/{id}
  • Multiple workflow management systems

5. TERMINAL Duplicates (CRITICAL)

  • terminal.py vs simple_terminal_websocket.py vs secure_terminal_websocket.py vs base_terminal.py
  • /terminal/sessions in multiple files
  • WebSocket endpoints: /ws/terminal, /ws/secure, /ws/simple

6. AGENT Management Duplicates

  • agent.py vs intelligent_agent.py vs agent_config.py
  • /agents endpoints scattered across files

7. KNOWLEDGE Base Duplicates

  • knowledge.py vs chat_knowledge.py vs kb_librarian.py
  • /entries vs /knowledge patterns

8. WEBSOCKET Duplicates

  • Multiple WebSocket implementations
  • websockets.py + embedded websockets in other files

Specific Problem Examples

Terminal APIs (4 different implementations!)

terminal.py:
- POST /terminal/command
- POST /terminal/sessions
- GET /terminal/sessions/{id}

simple_terminal_websocket.py:
- GET /simple/sessions
- POST /sessions
- WebSocket /ws/simple/{id}

secure_terminal_websocket.py:
- WebSocket /ws/secure/{id}
- POST /terminal/{chat_id}/control/take

base_terminal.py:
- GET /terminal/package-managers
- POST /terminal/check-tool

Health Check Chaos

system.py: GET /system/health
chat.py: GET /chat/health
llm.py: GET /status/comprehensive
workflow.py: GET /workflow/{id}/status
kb_librarian.py: GET /health
research_browser.py: GET /playwright/health

Configuration Scattered

settings.py: GET/POST /config
agent_config.py: GET/POST /config
llm.py: GET/POST /config
system.py: GET /config
phase_management.py: POST /config/update

Impact Assessment

Critical Issues:

  1. Frontend Confusion: Which endpoint to call?
  2. Inconsistent Behavior: Same path, different results
  3. Maintenance Nightmare: 4 terminal implementations
  4. Testing Complexity: Multiple code paths for same functionality
  5. Documentation Chaos: Hard to document overlapping APIs

Resource Waste:

  • Multiple health check implementations
  • Duplicate configuration management
  • Redundant validation logic
  • Scattered business logic

Consolidation Recommendations

Phase 1: Critical Consolidations

  1. Unify Terminal APIs: Choose one implementation, deprecate others
  2. Standardize Health Checks: Single /health with service-specific details
  3. Centralize Configuration: Single config API with module routing

Phase 2: Feature Consolidations

  1. Merge Knowledge APIs: knowledge.py + chat_knowledge.py + kb_librarian.py
  2. Consolidate Agent Management: agent.py + intelligent_agent.py
  3. Unify Workflow Systems: Choose primary workflow implementation

Phase 3: API Standardization

  1. Consistent Naming: /api/v1/{resource}/{action} pattern
  2. HTTP Method Standards: GET=read, POST=create, PUT=update, DELETE=remove
  3. Response Format Standards: Consistent JSON structure

Immediate Actions Needed

  1. Audit Current Usage: Which endpoints are actually used by frontend?
  2. Create Migration Plan: Safe deprecation timeline
  3. Choose Primary Implementations: Keep best, deprecate rest
  4. Update Documentation: Clear API reference

Benefits of Cleanup

  • 50% reduction in API surface area
  • Simplified frontend development
  • Easier testing and maintenance
  • Better performance (fewer code paths)
  • Clearer documentation