@@ -185,6 +185,17 @@ def get_component_file_mapping() -> dict[str, list[str]]:
185185 "tests/api/test_voice_endpoints.py" ,
186186 "app/components/frontend/dashboard/modals/voice_settings_tab.py" ,
187187 ],
188+ AnswerKeys .SERVICE_INSIGHTS : [
189+ "app/components/backend/api/insights" ,
190+ "app/services/insights" ,
191+ "app/cli/insights.py" ,
192+ "tests/services/test_insights_service.py" ,
193+ "tests/services/test_insights_collectors.py" ,
194+ "tests/api/test_insights_endpoints.py" ,
195+ # Frontend dashboard files
196+ "app/components/frontend/dashboard/cards/insights_card.py" ,
197+ "app/components/frontend/dashboard/modals/insights_modal.py" ,
198+ ],
188199 }
189200
190201
@@ -559,6 +570,21 @@ def _rename_backend_files(suffix: str) -> set[str]:
559570 project_path , "app/components/frontend/dashboard/modals/comms_modal.py"
560571 )
561572
573+ # Remove insights service if not selected
574+ if not is_enabled (AnswerKeys .INSIGHTS ):
575+ remove_dir (project_path , "app/components/backend/api/insights" )
576+ remove_dir (project_path , "app/services/insights" )
577+ remove_file (project_path , "app/cli/insights.py" )
578+ remove_file (project_path , "tests/services/test_insights_service.py" )
579+ remove_file (project_path , "tests/services/test_insights_collectors.py" )
580+ remove_file (project_path , "tests/api/test_insights_endpoints.py" )
581+ remove_file (
582+ project_path , "app/components/frontend/dashboard/cards/insights_card.py"
583+ )
584+ remove_file (
585+ project_path , "app/components/frontend/dashboard/modals/insights_modal.py"
586+ )
587+
562588 # Remove auth service dashboard files if not selected
563589 if not is_enabled (AnswerKeys .AUTH ):
564590 remove_file (
@@ -569,23 +595,25 @@ def _rename_backend_files(suffix: str) -> set[str]:
569595 )
570596
571597 # Remove services_card.py only if NO services are enabled
572- # ServicesCard shows all services (auth, AI, comms) , so keep if ANY service is enabled
598+ # ServicesCard shows all services, so keep if ANY service is enabled
573599 if (
574600 not is_enabled (AnswerKeys .AUTH )
575601 and not is_enabled (AnswerKeys .AI )
576602 and not is_enabled (AnswerKeys .COMMS )
603+ and not is_enabled (AnswerKeys .INSIGHTS )
577604 ):
578605 remove_file (
579606 project_path , "app/components/frontend/dashboard/cards/services_card.py"
580607 )
581608
582609 # Remove Alembic directory only if NO service needs migrations
583- # Alembic is needed when: auth is enabled OR (AI is enabled AND backend is NOT memory )
610+ # Alembic is needed when: auth, insights, or (AI with non-memory backend)
584611 include_auth = is_enabled (AnswerKeys .AUTH )
585612 include_ai = is_enabled (AnswerKeys .AI )
613+ include_insights = is_enabled (AnswerKeys .INSIGHTS )
586614 ai_backend = context .get (AnswerKeys .AI_BACKEND , StorageBackends .MEMORY )
587615 ai_needs_migrations = include_ai and ai_backend != StorageBackends .MEMORY
588- needs_migrations = include_auth or ai_needs_migrations
616+ needs_migrations = include_auth or ai_needs_migrations or include_insights
589617
590618 if not needs_migrations :
591619 remove_dir (project_path , "alembic" )
@@ -632,6 +660,7 @@ def _render_jinja_template(src: Path, dst: Path, project_path: Path) -> None:
632660 "include_auth" : True ,
633661 "include_ai" : True ,
634662 "include_comms" : True ,
663+ "include_insights" : True ,
635664 # Component flags - check what exists in project
636665 "include_scheduler" : (project_path / "app/components/scheduler" ).exists (),
637666 "include_worker" : (project_path / "app/components/worker" ).exists (),
0 commit comments