2757ef3b4f
Recovers and adapts the structural refactoring from overwritten
main merge (b6f89f9) to current dev reality.
Scope:
- Schema extraction into apps/api/src/schemas/
- Docker service split into services/docker/ package
- Instance lifecycle extraction from api/tool_instances.py
- Config profile service extraction from api/config_profiles.py
- Auth dependency refactor (get_current_user)
- Frontend reorganization into features/ dirs + kebab-case naming
Exclusions (already in dev): seeding, defaults, unique constraint,
SSH key mounting, terminal backend, tunnel regex, session auto-numbering.
3.9 KiB
3.9 KiB
Scope
This change is a pure structural refactoring of the backend and frontend codebase. No API contracts, database schemas, or user-facing behaviors change.
In Scope
-
Schema extraction (
apps/api/src/schemas/)- Extract Pydantic models from API routers into dedicated schema modules
- Schemas to extract:
tool_type,tool_instance,config_profile,user,user_config,project,ssh_key,git_repository,health - Each API router imports schemas from
src.schemas.*instead of defining inline
-
Docker service package (
apps/api/src/services/docker/)- Split
services/docker.pymonolith into focused modules:docker/compose.py— compose file generation, modification, validationdocker/container.py— container lifecycle (status, IP, network, logs)docker/config_staging.py— config file staging for instancesdocker/tunnel.py— tunnel URL extraction (moved fromservices/tunnel.py)docker/__init__.py— re-exports for backward compatibility
- Update all imports across the backend
- Split
-
Instance lifecycle extraction (
apps/api/src/services/instance_lifecycle.py)- Extract instance creation, start, stop, restart, and deletion logic from
api/tool_instances.py - The API router becomes thin: validates auth, calls service, returns response
- Service functions are async and receive
AsyncSession, models, and raw parameters
- Extract instance creation, start, stop, restart, and deletion logic from
-
Config profile service extraction (
apps/api/src/services/config_profiles.py)- Extract business logic from
api/config_profiles.py: CRUD helpers, validation, default profile management - API router delegates to service functions
- Extract business logic from
-
Auth dependency refactor (
apps/api/src/auth/dependencies.py)- Add
get_current_userdependency that returns aUsermodel directly - Update API routers to use
user: User = Depends(get_current_user)where the full user object is needed - Keep
get_current_user_idfor endpoints that only need the ID
- Add
-
Frontend reorganization
- Move components into
features/directories by domain:features/git/— CommitDialog, FileBrowser, FileEditor, GitToolbar, MergeDialog, WorkspaceSidebarfeatures/dashboard/— ActiveSessionsList, DashboardSummary, ProjectsSection, QuickCreateForm, RecentSessionsSectionfeatures/project/— RepositoriesSettingsTabfeatures/tool-workshop/— ToolTypesTab (already exists)
- Rename API files from snake_case to kebab-case:
tool_types.ts→tool-types.tsssh_keys.ts→ssh-keys.tsgit_repositories.ts→git-repositories.ts
- Rename page files to
*Page.tsx:dashboard.tsx→DashboardPage.tsxprojects.tsx→ProjectsPage.tsx- etc.
- Move components into
Out of Scope
- Any new features or behavioral changes
- Database schema changes (no migrations)
- API contract changes (same endpoints, same request/response shapes)
- Frontend UI behavior changes (same components, same interactions)
- Removing or modifying the
ConfigProfileIncludemodel (already exists as a relation) - Extracting
ConfigMountinto a separate model (current dev uses JSON arrays; this is a schema decision, not a refactor) - Changes to
tool_definition_manifestorworkspacemodels
Acceptance Criteria
- All existing tests pass without modification (behavior unchanged)
- All existing API endpoints return identical responses for identical requests
- All frontend pages render identically
docker compose upstarts successfully- Backend
ruff checkpasses - Frontend
npm run typecheckpasses - Frontend
npm run buildpasses - File sizes are reduced: no API router > 500 lines, no service > 400 lines
Preconditions
- Current
devbranch is stable and all behavioral forward-ports are complete - All legacy
ToolConfig/ConfigFoldercode has been removed - Database migrations are at a single head