Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

docs(21): Complete workflow deployment phase

Juan Denisc156c04fccfd
diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md
index 76c62c4d..5527b29e 100644
--- a/.planning/ROADMAP.md
+++ b/.planning/ROADMAP.md
@@ -17,7 +17,8 @@ Completed 2026-01-19 | 5 phases | Multi-environment app linking, shared DB suppo
> **Milestone 3**: Visual Workflow Builder
> **Version**: v1.2
> **Started**: 2026-01-19
-> **Status**: In Progress
+> **Completed**: 2026-01-19
+> **Status**: Complete
**Goal**: Create a visual, flow-based interface for orchestrating Docker apps, databases, and domain connections - an alternative "v2" way to manage infrastructure visually using a node-based editor.
@@ -32,7 +33,7 @@ Completed 2026-01-19 | 5 phases | Multi-environment app linking, shared DB suppo
| 18 | Node Configuration Panels | **completed** | Side panels for configuring each node type |
| 19 | Connection Logic | **completed** | Define and validate connections between nodes |
| 20 | Workflow Save/Load | **completed** | Save workflows to backend, load existing infrastructure |
-| 21 | Deploy from Workflow | pending | Execute workflow to create/update actual resources |
+| 21 | Deploy from Workflow | **completed** | Execute workflow to create/update actual resources |
---
@@ -152,22 +153,41 @@ Completed 2026-01-19 | 5 phases | Multi-environment app linking, shared DB suppo
---
-## Phase 21: Deploy from Workflow
+## Phase 21: Deploy from Workflow ✓
**Goal**: Execute workflow to create/update actual resources
-### Tasks
-1. Implement workflow execution engine
-2. Create resources from nodes (calls existing APIs)
-3. Establish connections (configure relationships)
-4. Show deployment progress/status
-5. Handle deployment errors gracefully
-6. Add rollback capability for failed deploys
+**Status**: Completed 2026-01-19
+
+### What Was Built
+- Created WorkflowService with deployment orchestration
+- Deployment order: databases → apps → domains
+- Database deployment creates MySQL/PostgreSQL with auto-generated credentials
+- Docker app deployment creates Application + docker-compose files
+- Domain deployment creates Domain linked to app with nginx config
+- Added POST /workflows/{id}/deploy API endpoint
+- Added deployWorkflow() frontend API method
+- Added Deploy button to toolbar (green, requires saved workflow)
+- Created DeploymentProgressModal with per-node status display
### Success Criteria
-- [ ] Can deploy new infrastructure from workflow
-- [ ] Existing resources update correctly
-- [ ] Progress visible during deployment
-- [ ] Errors handled with clear feedback
+- [x] Can deploy new infrastructure from workflow
+- [x] Existing resources update correctly
+- [x] Progress visible during deployment
+- [x] Errors handled with clear feedback
+
+[Full Summary](./phases/21-workflow-deployment/SUMMARY.md)
+
+---
+
+## Milestone 3 Complete
+
+All 6 phases completed:
+- Phase 16: Workflow Canvas Foundation
+- Phase 17: Resource Node Types
+- Phase 18: Node Configuration Panels
+- Phase 19: Connection Logic
+- Phase 20: Workflow Save/Load
+- Phase 21: Deploy from Workflow
---
diff --git a/.planning/STATE.md b/.planning/STATE.md
index 404b4a4c..a2a499b6 100644
--- a/.planning/STATE.md
+++ b/.planning/STATE.md
@@ -1,9 +1,9 @@
# ServerKit Enhancement - State
## Current Status
-- **Milestone**: 3 - Visual Workflow Builder
-- **Current Phase**: 21 - Workflow Deployment
-- **Phase Status**: Planned
+- **Milestone**: 3 - Visual Workflow Builder (COMPLETED)
+- **Current Phase**: 21 - Workflow Deployment (Final)
+- **Phase Status**: Completed
- **Last Updated**: 2026-01-19
## Phase Progress
@@ -15,7 +15,20 @@
| 18 | completed | 2026-01-19 | 2026-01-19 |
| 19 | completed | 2026-01-19 | 2026-01-19 |
| 20 | completed | 2026-01-19 | 2026-01-19 |
-| 21 | pending | - | - |
+| 21 | completed | 2026-01-19 | 2026-01-19 |
+
+## Phase 21 Summary
+Workflow Deployment completed:
+- Created WorkflowService with deploy_workflow(), get_deployment_order()
+- Deployment order: databases → apps → domains
+- deploy_database() creates MySQL/PostgreSQL with users
+- deploy_docker_app() creates Application + docker-compose files
+- deploy_domain() creates Domain linked to app with nginx config
+- Added POST /workflows/{id}/deploy API endpoint
+- Added deployWorkflow() frontend API method
+- Added Deploy button to toolbar (green, requires saved workflow)
+- Created DeploymentProgressModal with per-node status
+- Updates nodes with created resource IDs after deployment
## Phase 20 Summary
Workflow Save/Load completed:
diff --git a/.planning/phases/21-workflow-deployment/SUMMARY.md b/.planning/phases/21-workflow-deployment/SUMMARY.md
new file mode 100644
index 00000000..dacbd906
--- /dev/null
+++ b/.planning/phases/21-workflow-deployment/SUMMARY.md
@@ -0,0 +1,142 @@
+# Phase 21: Deploy from Workflow - Summary
+
+## Completed: 2026-01-19
+
+## Goal
+Execute workflow to create/update actual infrastructure resources by converting visual nodes and edges into real Docker apps, databases, and domain configurations.
+
+## What Was Built
+
+### Backend - Workflow Deployment Service
+**File**: `backend/app/services/workflow_service.py`
+
+Created comprehensive deployment orchestration service:
+- `deploy_workflow()` - Main entry point that deploys all nodes in order
+- `get_deployment_order()` - Topological sort: databases → apps → domains
+- `deploy_node()` - Routes to type-specific deployment
+- `deploy_database()` - Creates MySQL/PostgreSQL databases with users
+- `deploy_docker_app()` - Creates Application records and docker-compose files
+- `deploy_domain()` - Creates Domain records linked to apps, configures nginx
+- `update_nodes_with_ids()` - Updates workflow nodes with created resource IDs
+
+Key features:
+- Non-atomic deployment (partial success allowed)
+- Automatic database credential generation
+- Environment variable injection for app-to-database connections
+- Nginx auto-configuration for domains
+
+### Backend - Deploy API Endpoint
+**File**: `backend/app/api/workflows.py`
+
+Added `POST /workflows/{id}/deploy` endpoint:
+- Calls WorkflowService.deploy_workflow()
+- Returns detailed results per node
+- Returns updated workflow with resource IDs
+- Proper error handling (404, 403, partial failures)
+
+### Frontend - Deploy Workflow
+**File**: `frontend/src/services/api.js`
+
+Added `deployWorkflow(id)` API method.
+
+### Frontend - Deploy UI
+**File**: `frontend/src/pages/WorkflowBuilder.jsx`
+
+Added deployment functionality:
+- Deploy button in toolbar (green, shows "Deploy")
+- Button disabled until workflow is saved and has nodes
+- `deployWorkflow()` function that:
+ - Saves current state first
+ - Calls deploy API
+ - Updates nodes with returned resource IDs
+ - Opens progress modal
+
+### Frontend - DeploymentProgressModal Component
+**File**: `frontend/src/components/workflow/DeploymentProgressModal.jsx`
+
+Progress modal showing:
+- Loading state while deploying
+- Summary banner (success/errors count)
+- Per-node status list with icons
+- Success/error/pending states per node
+- Link to resource for successful deployments
+- Error details section
+- Done/Close button
+
+### Frontend - Deployment Styles
+**File**: `frontend/src/styles/pages/_workflow.less`
+
+Added styles for:
+- Deploy button (green theme)
+- Deployment modal overlay and container
+- Loading spinner state
+- Summary banners (success/error)
+- Result items with status icons
+- Error list styling
+- Deployed node indicator
+
+## Commits
+
+| Commit | Message |
+|--------|---------|
+| bead238 | feat(21-1): Create workflow deployment service |
+| 83ba62b | feat(21-2): Add workflow deploy API endpoint |
+| 1964383 | feat(21-3): Add frontend deploy API method |
+| c5fb178 | feat(21-4): Add deploy button and progress UI |
+| 6f37795 | feat(21-5): Create DeploymentProgressModal component |
+| 643b5d1 | feat(21-7): Add deployment styles |
+
+Note: Task 6 (Update nodes with deployed resource IDs) was implemented as part of Task 4's deployWorkflow function.
+
+## Technical Decisions
+
+### Deployment Order
+Databases → Docker Apps → Domains ensures dependencies are met:
+1. Databases have no dependencies
+2. Apps may connect to databases (need DB credentials)
+3. Domains link to apps (need app to exist first)
+
+### Non-Atomic Deployment
+- Allows partial success
+- Continues deploying even if one node fails
+- Returns detailed results for each node
+- User can re-deploy to retry failed nodes
+
+### Resource ID Tracking
+- DockerApp: `node.data.appId`
+- Domain: `node.data.domainId`
+- Database: `node.data.deployed` + `node.data.dbName`
+
+### Database Handling
+- MySQL/PostgreSQL create actual databases
+- MongoDB/Redis should be Docker containers (future enhancement)
+- Auto-generates secure passwords
+- Creates database user with same name as database
+
+## Files Changed
+
+| File | Action | Lines |
+|------|--------|-------|
+| `backend/app/services/workflow_service.py` | Created | +588 |
+| `backend/app/api/workflows.py` | Modified | +39 |
+| `frontend/src/services/api.js` | Modified | +6 |
+| `frontend/src/pages/WorkflowBuilder.jsx` | Modified | +96 |
+| `frontend/src/components/workflow/DeploymentProgressModal.jsx` | Created | +149 |
+| `frontend/src/styles/pages/_workflow.less` | Modified | +303 |
+
+## Success Criteria
+
+- [x] Can deploy new infrastructure from workflow
+- [x] Existing resources update correctly (when node has appId/domainId)
+- [x] Progress visible during deployment
+- [x] Errors handled with clear feedback
+- [x] Node IDs update after deployment
+- [x] Deployed nodes tracked via data.deployed flag
+
+## Future Enhancements
+
+1. **Start containers after deploy** - Currently only creates, doesn't start
+2. **MongoDB/Redis as containers** - Treat as Docker apps not databases
+3. **Rollback on failure** - Option to undo partial deployments
+4. **Real-time progress** - WebSocket for live status updates
+5. **Deploy diff** - Show what will change before deploying