Splitting & Refactoring - Concept¶
π Status: Concept
This project is in the concept phase. Goal: bring all files under 500 lines.
Created: 2025-11-28
Author: Claude Code
Version: 1.0
Goal¶
All large files in the LLARS project should be split into smaller, logically grouped modules. Target size: max 500 lines per file. This improves maintainability, testability, and readability.
File Overview¶
π΄ CRITICAL (>1500 lines) - Highest priority¶
| File | Lines | Type | Priority |
|---|---|---|---|
llars-frontend/src/components/Judge/JudgeSession.vue |
4,191 | Vue | P1 |
app/routes/judge/judge_routes.py |
2,596 | Python | P1 |
app/routes/oncoco/oncoco_routes.py |
1,934 | Python | P1 |
llars-frontend/src/components/Judge/JudgeResults.vue |
1,808 | Vue | P1 |
llars-frontend/src/components/OnCoCo/OnCoCoResults.vue |
1,533 | Vue | P1 |
π HIGH (1000-1500 lines)¶
| File | Lines | Type | Priority |
|---|---|---|---|
llars-frontend/src/components/Admin/sections/AdminRAGSection.vue |
1,406 | Vue | P2 |
llars-frontend/src/components/PromptEngineering/PromptEngineeringDetail.vue |
1,373 | Vue | P2 |
llars-frontend/src/components/Judge/WorkerLane.vue |
1,350 | Vue | P2 |
llars-frontend/src/components/Admin/CrawlerAdmin/WebCrawlerTool.vue |
1,298 | Vue | P2 |
app/db/tables.py |
1,260 | Python | P2 |
app/routes/rag/RAGRoutes.py |
1,202 | Python | P2 |
llars-frontend/src/components/Ranker/RankerDetail.vue |
1,031 | Vue | P2 |
app/services/crawler/web_crawler.py |
1,024 | Python | P2 |
π‘ MEDIUM (700-1000 lines)¶
| File | Lines | Type | Priority |
|---|---|---|---|
llars-frontend/src/components/Admin/ChatbotAdmin/ChatbotEditor.vue |
901 | Vue | P3 |
llars-frontend/src/components/HistoryGenerator/HistoryGenerationDetail.vue |
883 | Vue | P3 |
llars-frontend/src/components/OnCoCo/MatrixComparisonMetrics.vue |
880 | Vue | P3 |
llars-frontend/src/components/comparison/ComparisonChat.vue |
855 | Vue | P3 |
llars-frontend/src/components/Judge/JudgeConfig.vue |
835 | Vue | P3 |
llars-frontend/src/components/Admin/AdminRAG.vue |
835 | Vue | P3 |
llars-frontend/src/components/OnCoCo/OnCoCoInfo.vue |
780 | Vue | P3 |
llars-frontend/src/components/parts/ScenarioDetailsDialog.vue |
771 | Vue | P3 |
llars-frontend/src/components/Orga/Documentation.vue |
740 | Vue | P3 |
llars-frontend/src/components/PromptEngineering/PromptEngineering.vue |
734 | Vue | P3 |
llars-frontend/src/components/ChatWithBots.vue |
728 | Vue | P3 |
llars-frontend/src/components/parts/CreateScenarioDialog.vue |
714 | Vue | P3 |
app/services/oncoco/oncoco_service.py |
719 | Python | P3 |
app/workers/judge_worker_pool.py |
700 | Python | P3 |
llars-frontend/src/components/PromptEngineering/sidebar.vue |
700 | Vue | P3 |
π’ LOW (500-700 lines)¶
| File | Lines | Type | Priority |
|---|---|---|---|
llars-frontend/src/components/OnCoCo/OnCoCoOverview.vue |
676 | Vue | P4 |
app/ComparisonFunctions.py |
673 | Python | P4 |
app/services/judge/kia_sync_service.py |
623 | Python | P4 |
app/db/db.py |
622 | Python | P4 |
app/services/oncoco/oncoco_labels.py |
602 | Python | P4 |
app/services/judge/judge_service.py |
576 | Python | P4 |
llars-frontend/src/components/Admin/ChatbotAdmin/ChatbotManager.vue |
568 | Vue | P4 |
app/services/permission_service.py |
562 | Python | P4 |
app/services/chatbot/chat_service.py |
552 | Python | P4 |
llars-frontend/src/components/Admin/AdminUserProgressStats.vue |
545 | Vue | P4 |
app/routes/chatbot/chatbot_routes.py |
530 | Python | P4 |
llars-frontend/src/components/Chat.vue |
527 | Vue | P4 |
app/services/chatbot/chatbot_service.py |
522 | Python | P4 |
app/workers/judge_worker.py |
505 | Python | P4 |
llars-frontend/src/components/FloatingChat.vue |
504 | Vue | P4 |
Splitting Strategies¶
Backend (Python)¶
1. Split routes by function¶
Example: judge_routes.py (2,596 lines)
app/routes/judge/
βββ __init__.py # Blueprint registration
βββ session_routes.py # Session CRUD (~400 lines)
βββ comparison_routes.py # Comparison endpoints (~400 lines)
βββ evaluation_routes.py # Evaluation/results (~400 lines)
βββ kia_sync_routes.py # GitLab sync (~300 lines)
βββ statistics_routes.py # Statistics (~300 lines)
βββ stream_routes.py # Streaming endpoints (~300 lines)
2. Split models by domain¶
Example: tables.py (1,260 lines)
app/db/models/
βββ __init__.py # Export all models
βββ user.py # User, UserGroup, UserRole (~150 lines)
βββ permission.py # Permission, Role, etc. (~200 lines)
βββ judge.py # JudgeSession, Comparison, etc. (~250 lines)
βββ rag.py # RAGCollection, Document, etc. (~200 lines)
βββ chatbot.py # Chatbot, Conversation, etc. (~150 lines)
βββ oncoco.py # OnCoCoAnalysis, Labels (~150 lines)
βββ pillar.py # PillarThread, Statistics (~100 lines)
βββ scenario.py # Scenario, Rating models (~150 lines)
3. Split services by responsibility¶
Example: web_crawler.py (1,024 lines)
app/services/crawler/
βββ __init__.py
βββ crawler_service.py # Core service (~300 lines)
βββ url_queue.py # URL queue management (~200 lines)
βββ html_parser.py # HTML extraction (~200 lines)
βββ sitemap_parser.py # Sitemap processing (~150 lines)
βββ robots_handler.py # robots.txt handling (~100 lines)
Frontend (Vue)¶
1. Split components into sub-components¶
Example: JudgeSession.vue (4,191 lines)
llars-frontend/src/components/Judge/JudgeSession/
βββ JudgeSession.vue # Main container (~300 lines)
βββ SessionHeader.vue # Header with stats (~200 lines)
βββ SessionControls.vue # Play/Pause/Stop (~150 lines)
βββ WorkerGrid.vue # Worker lane container (~200 lines)
βββ ComparisonQueue.vue # Queue display (~300 lines)
βββ ComparisonDetail.vue # Active comparison (~400 lines)
βββ StreamOutput.vue # LLM stream viewer (~250 lines)
βββ SessionProgress.vue # Progress display (~150 lines)
βββ composables/
βββ useSessionSocket.js # Socket.IO logic (~200 lines)
βββ useSessionState.js # State management (~200 lines)
βββ useWorkerManagement.js # Worker logic (~150 lines)
2. Move logic into composables¶
Principle: - Template: presentation only - Script: orchestration only - Composables: business logic, API calls, state
Example:
// Before: everything in one component
// After:
import { useJudgeSession } from './composables/useJudgeSession'
import { useSocketEvents } from './composables/useSocketEvents'
const { session, workers, queue } = useJudgeSession(sessionId)
const { connect, disconnect } = useSocketEvents(sessionId)
3. Extract shared components¶
Reusable UI elements:
- StatCard.vue - stats cards
- ProgressRing.vue - progress display
- StreamViewer.vue - LLM output
- ThreadPreview.vue - thread preview
- ConfirmDialog.vue - confirmation dialogs
Proposed Folder Structure¶
Backend¶
app/
βββ routes/
β βββ judge/
β β βββ __init__.py
β β βββ session_routes.py
β β βββ comparison_routes.py
β β βββ evaluation_routes.py
β β βββ kia_sync_routes.py
β β βββ statistics_routes.py
β β βββ stream_routes.py
β βββ oncoco/
β β βββ __init__.py
β β βββ analysis_routes.py
β β βββ labels_routes.py
β βββ rag/
β βββ __init__.py
β βββ collection_routes.py
β βββ search_routes.py
β
βββ services/
β βββ crawler/
β βββ judge/
β βββ oncoco/
β βββ rag/
β βββ chatbot/
β
βββ db/
βββ models/
βββ user.py
βββ permission.py
βββ judge.py
βββ rag.py
βββ chatbot.py
βββ oncoco.py
βββ scenario.py
Frontend¶
llars-frontend/src/components/
βββ Judge/
β βββ JudgeSession/
β βββ JudgeSession.vue
β βββ SessionHeader.vue
β βββ SessionControls.vue
β βββ ...
βββ OnCoCo/
β βββ OnCoCoResults/
β βββ OnCoCoResults.vue
β βββ ResultsHeader.vue
β βββ ...
βββ Admin/
βββ CrawlerAdmin/
βββ WebCrawlerTool.vue
βββ CrawlerSettings.vue
βββ ...
Guidelines¶
- One responsibility per module
- Keep components below 500 lines
- Extract shared UI into common components
- Use composables for business logic
- Keep routes thin; move logic to services
Risks¶
- Large refactors can introduce regressions
- Test coverage may be insufficient
- Vue components might have tightly coupled state
Next Steps¶
- Confirm the priority list
- Split P1 files first (judge routes + core views)
- Add regression tests
- Continue with P2/P3