-
Notifications
You must be signed in to change notification settings - Fork 3.1k
refactor: Remove Socket.IO and implement HTTP polling architecture #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
595907a
61ab403
7283b79
94a8949
4179322
af402c2
970ba04
6816610
98c8684
2b08c7b
1301516
e4a6a68
75f0e70
c4a7058
fb382b3
ea4e9cf
785d347
2e4e5fa
496c3ca
3219447
39779dd
86b2873
2376cdc
42275c8
bc08810
791f116
3dd46b7
73e1933
800ffd4
579e7c3
d1e2023
346a1cf
1240001
e99038d
f0972ad
302f055
6b0ee67
e3a9e9b
8886ad9
5a19446
987f554
6c5a597
1f1dc4a
2e2fdee
33d95cb
4e0044b
15f9544
b2248f0
43b1902
965f60d
5b87191
5b94932
c3b4526
d134962
29e8a15
17cb94c
36a6234
7273728
e75a55f
85be1a3
3d31669
b39627f
fa753c4
1ba8777
fe68762
0248832
551ef9b
4b2d478
a8c703d
064082a
ce4183d
9146778
198c4aa
b5f82bd
a576b91
2672109
aad773e
0933e70
819a6a5
55e5fbf
f6d0ce5
7fa3e97
125dd6e
b23523a
86b536d
848a43d
1ed2d88
f526181
190a686
da5f32b
7252aa9
a816410
f82eee2
b0cc601
91d2eb9
d2455ce
8022d40
af7c59a
1079205
0ed2d47
eaa5e17
58149a5
37bd48b
f42f79a
d3080fa
e113939
f35f09d
c6fb8af
d15d8aa
17a39e4
3f67fc1
ed43182
ff6b067
534868b
c41eefb
511b5cf
a7809d8
ec79f86
6198f12
624f70a
116c909
30c3698
9b199c3
c1770e7
027bf22
071a88d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,163 @@ | ||||||||||||||||
| # API Naming Conventions | ||||||||||||||||
|
|
||||||||||||||||
| ## Overview | ||||||||||||||||
| This document defines the naming conventions used throughout the Archon V2 codebase for consistency and clarity. | ||||||||||||||||
|
|
||||||||||||||||
| ## Task Status Values | ||||||||||||||||
| **Database values only - no UI mapping:** | ||||||||||||||||
| - `todo` - Task is in backlog/todo state | ||||||||||||||||
| - `doing` - Task is actively being worked on | ||||||||||||||||
| - `review` - Task is pending review | ||||||||||||||||
| - `done` - Task is completed | ||||||||||||||||
|
|
||||||||||||||||
| ## Service Method Naming | ||||||||||||||||
|
|
||||||||||||||||
| ### Project Service (`projectService.ts`) | ||||||||||||||||
|
|
||||||||||||||||
| #### Projects | ||||||||||||||||
| - `listProjects()` - Get all projects | ||||||||||||||||
| - `getProject(projectId)` - Get single project by ID | ||||||||||||||||
| - `createProject(projectData)` - Create new project | ||||||||||||||||
| - `updateProject(projectId, updates)` - Update project | ||||||||||||||||
| - `deleteProject(projectId)` - Delete project | ||||||||||||||||
|
|
||||||||||||||||
| #### Tasks | ||||||||||||||||
| - `getTasksByProject(projectId)` - Get all tasks for a specific project | ||||||||||||||||
| - `getTask(taskId)` - Get single task by ID | ||||||||||||||||
| - `createTask(taskData)` - Create new task | ||||||||||||||||
| - `updateTask(taskId, updates)` - Update task with partial data | ||||||||||||||||
| - `updateTaskStatus(taskId, status)` - Update only task status | ||||||||||||||||
| - `updateTaskOrder(taskId, newOrder, newStatus?)` - Update task position/order | ||||||||||||||||
| - `deleteTask(taskId)` - Delete task (soft delete/archive) | ||||||||||||||||
| - `getTasksByStatus(status)` - Get all tasks with specific status | ||||||||||||||||
|
|
||||||||||||||||
| #### Documents | ||||||||||||||||
| - `getDocuments(projectId)` - Get all documents for project | ||||||||||||||||
| - `getDocument(projectId, docId)` - Get single document | ||||||||||||||||
| - `createDocument(projectId, documentData)` - Create document | ||||||||||||||||
| - `updateDocument(projectId, docId, updates)` - Update document | ||||||||||||||||
| - `deleteDocument(projectId, docId)` - Delete document | ||||||||||||||||
|
|
||||||||||||||||
| #### Versions | ||||||||||||||||
| - `createVersion(projectId, field, content)` - Create version snapshot | ||||||||||||||||
| - `listVersions(projectId, fieldName?)` - List version history | ||||||||||||||||
| - `getVersion(projectId, fieldName, versionNumber)` - Get specific version | ||||||||||||||||
| - `restoreVersion(projectId, fieldName, versionNumber)` - Restore version | ||||||||||||||||
|
|
||||||||||||||||
| ## API Endpoint Patterns | ||||||||||||||||
|
|
||||||||||||||||
| ### RESTful Endpoints | ||||||||||||||||
| ``` | ||||||||||||||||
| GET /api/projects - List all projects | ||||||||||||||||
| POST /api/projects - Create project | ||||||||||||||||
| GET /api/projects/{project_id} - Get project | ||||||||||||||||
| PUT /api/projects/{project_id} - Update project | ||||||||||||||||
| DELETE /api/projects/{project_id} - Delete project | ||||||||||||||||
|
|
||||||||||||||||
| GET /api/projects/{project_id}/tasks - Get project tasks | ||||||||||||||||
| POST /api/tasks - Create task (project_id in body) | ||||||||||||||||
| GET /api/tasks/{task_id} - Get task | ||||||||||||||||
| PUT /api/tasks/{task_id} - Update task | ||||||||||||||||
| DELETE /api/tasks/{task_id} - Delete task | ||||||||||||||||
|
|
||||||||||||||||
| GET /api/projects/{project_id}/docs - Get project documents | ||||||||||||||||
| POST /api/projects/{project_id}/docs - Create document | ||||||||||||||||
| GET /api/projects/{project_id}/docs/{doc_id} - Get document | ||||||||||||||||
| PUT /api/projects/{project_id}/docs/{doc_id} - Update document | ||||||||||||||||
| DELETE /api/projects/{project_id}/docs/{doc_id} - Delete document | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ### Progress/Polling Endpoints | ||||||||||||||||
| ``` | ||||||||||||||||
| GET /api/progress/{operation_id} - Generic operation progress | ||||||||||||||||
| GET /api/knowledge/crawl-progress/{id} - Crawling progress | ||||||||||||||||
| GET /api/agent-chat/sessions/{id}/messages - Chat messages | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ## Component Naming | ||||||||||||||||
|
|
||||||||||||||||
| ### Hooks | ||||||||||||||||
| - `use[Feature]` - Custom hooks (e.g., `usePolling`, `useProjectMutation`) | ||||||||||||||||
| - Returns object with: `{ data, isLoading, error, refetch }` | ||||||||||||||||
|
|
||||||||||||||||
| ### Services | ||||||||||||||||
| - `[feature]Service` - Service modules (e.g., `projectService`, `crawlProgressService`) | ||||||||||||||||
| - Methods return Promises with typed responses | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+83
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove reference to deprecated Docs should point to hooks ( -– `[feature]Service` - Service modules (e.g., `projectService`, `crawlProgressService`)
+– `[feature]Service` - Service modules (e.g., `projectService`)
+Note: prefer hooks like `useCrawlProgressPolling` over service wrappers for progress.📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~84-~84: There might be a mistake here. (QB_NEW_EN) 🤖 Prompt for AI Agents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Wirasm Thanks for the quick fix! The documentation now properly reflects the architectural decision to use the consolidated 🧠 Learnings used |
||||||||||||||||
| ### Components | ||||||||||||||||
| - `[Feature][Type]` - UI components (e.g., `TaskBoardView`, `EditTaskModal`) | ||||||||||||||||
| - Props interfaces: `[Component]Props` | ||||||||||||||||
|
|
||||||||||||||||
| ## State Variable Naming | ||||||||||||||||
|
|
||||||||||||||||
| ### Loading States | ||||||||||||||||
| - `isLoading[Feature]` - Boolean loading indicators | ||||||||||||||||
| - `isSwitchingProject` - Specific operation states | ||||||||||||||||
| - `movingTaskIds` - Set/Array of items being processed | ||||||||||||||||
|
|
||||||||||||||||
| ### Error States | ||||||||||||||||
| - `[feature]Error` - Error message strings | ||||||||||||||||
| - `taskOperationError` - Specific operation errors | ||||||||||||||||
|
|
||||||||||||||||
| ### Data States | ||||||||||||||||
| - `[feature]s` - Plural for collections (e.g., `tasks`, `projects`) | ||||||||||||||||
| - `selected[Feature]` - Currently selected item | ||||||||||||||||
| - `[feature]Data` - Raw data from API | ||||||||||||||||
|
|
||||||||||||||||
| ## Type Definitions | ||||||||||||||||
|
|
||||||||||||||||
| ### Database Types (from backend) | ||||||||||||||||
| ```typescript | ||||||||||||||||
| type DatabaseTaskStatus = 'todo' | 'doing' | 'review' | 'done'; | ||||||||||||||||
| type Assignee = 'User' | 'Archon' | 'AI IDE Agent'; | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ### Request/Response Types | ||||||||||||||||
| ```typescript | ||||||||||||||||
| Create[Feature]Request // e.g., CreateTaskRequest | ||||||||||||||||
| Update[Feature]Request // e.g., UpdateTaskRequest | ||||||||||||||||
| [Feature]Response // e.g., TaskResponse | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ## Function Naming Patterns | ||||||||||||||||
|
|
||||||||||||||||
| ### Event Handlers | ||||||||||||||||
| - `handle[Event]` - Generic handlers (e.g., `handleProjectSelect`) | ||||||||||||||||
| - `on[Event]` - Props callbacks (e.g., `onTaskMove`, `onRefresh`) | ||||||||||||||||
|
|
||||||||||||||||
| ### Operations | ||||||||||||||||
| - `load[Feature]` - Fetch data (e.g., `loadTasksForProject`) | ||||||||||||||||
| - `save[Feature]` - Persist changes (e.g., `saveTask`) | ||||||||||||||||
| - `delete[Feature]` - Remove items (e.g., `deleteTask`) | ||||||||||||||||
| - `refresh[Feature]` - Reload data (e.g., `refreshTasks`) | ||||||||||||||||
|
|
||||||||||||||||
| ### Formatting/Transformation | ||||||||||||||||
| - `format[Feature]` - Format for display (e.g., `formatTask`) | ||||||||||||||||
| - `validate[Feature]` - Validate data (e.g., `validateUpdateTask`) | ||||||||||||||||
|
|
||||||||||||||||
| ## Best Practices | ||||||||||||||||
|
|
||||||||||||||||
| ### ✅ Do Use | ||||||||||||||||
| - `getTasksByProject(projectId)` - Clear scope with context | ||||||||||||||||
| - `status` - Single source of truth from database | ||||||||||||||||
| - Direct database values everywhere (no mapping) | ||||||||||||||||
| - Polling with `usePolling` hook for data fetching | ||||||||||||||||
| - Async/await with proper error handling | ||||||||||||||||
| - ETag headers for efficient polling | ||||||||||||||||
| - Loading indicators during operations | ||||||||||||||||
|
|
||||||||||||||||
| ## Current Architecture Patterns | ||||||||||||||||
|
|
||||||||||||||||
| ### Polling & Data Fetching | ||||||||||||||||
| - HTTP polling with `usePolling` and `useCrawlProgressPolling` hooks | ||||||||||||||||
| - ETag-based caching for bandwidth efficiency | ||||||||||||||||
| - Loading state indicators (`isLoading`, `isSwitchingProject`) | ||||||||||||||||
| - Error toast notifications for user feedback | ||||||||||||||||
| - Manual refresh triggers via `refetch()` | ||||||||||||||||
| - Immediate UI updates followed by API calls | ||||||||||||||||
|
|
||||||||||||||||
| ### Service Architecture | ||||||||||||||||
| - Specialized services for different domains (`projectService`, `crawlProgressService`) | ||||||||||||||||
| - Direct database value usage (no UI/DB mapping) | ||||||||||||||||
| - Promise-based async operations | ||||||||||||||||
| - Typed request/response interfaces | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use consistent camelCase for document route params.
Move from snake_case to camelCase and keep names distinct.
📝 Committable suggestion
🤖 Prompt for AI Agents