VSM Service Implementation Summary
Overview
Successfully implemented VSM (Value Stream Mapping) tracking service for issue #51.
Components Implemented
1. Service API (services/vsm/)
-
FastAPI Application (
app/main.py): -
POST
/api/v1/work-items- Create work items - PUT
/api/v1/work-items/{id}/transition- Move between stages - GET
/api/v1/work-items/{id}/history- Get stage history - GET
/api/v1/metrics- Flow metrics (throughput, WIP, cycle time) - GET
/api/v1/stages- List available stages - GET
/api/v1/health- Health check -
GET
/metrics- Prometheus metrics -
Database Models (
app/models.py): -
WorkItem- Work items (features, bugs, tasks, epics) Stage- Value stream stages (Backlog → Production)StageTransition- Transition history-
FlowMetrics- Aggregated metrics -
Pydantic Schemas (
app/schemas.py): -
Request/response models with validation
-
OpenAPI documentation auto-generated
-
Prometheus Metrics:
vsm_requests_total- Request countervsm_work_items_created_total- Work items createdvsm_stage_transitions_total- Stage transitionsvsm_cycle_time_hours- Cycle time histogramvsm_work_in_progress- WIP gauge by stage
2. Database Schema (services/vsm/migrations/)
-
Alembic Migrations:
-
Initial migration (001) creates all tables
-
Default stages pre-populated
-
Tables:
work_items- Work item trackingstages- 6 default stages (Backlog → Production)stage_transitions- Full transition historyflow_metrics- Aggregated flow metrics
3. Kubernetes Deployment (platform/apps/vsm-service/)
-
PostgreSQL Cluster (
postgresql/db-vsm-cluster.yaml): -
CloudNativePG cluster with HA (3 replicas)
- Resource optimized (200m CPU, 256Mi memory)
-
Monitoring enabled
-
Service Manifests:
-
deployment.yaml- 2 replicas, health probes service.yaml- ClusterIP serviceingress.yaml- External accessconfigmap.yaml- Configuration-
serviceaccount.yaml- RBAC -
ArgoCD Application (
vsm-service-application.yaml): - Automated sync enabled
- Sync wave 25 (after dependencies)
Acceptance Criteria Status
- ✅ VSM service API deployed
- ✅ Work item tracking across stages
- ✅ Cycle time calculation per stage
- ✅ Flow metrics collection (throughput, WIP, cycle time percentiles)
- ✅ API documented (OpenAPI/Swagger)
- ⏳ Passes AT-E2-005 (partial) - Ready for testing
Testing
Unit Tests
Location: services/vsm/tests/unit/
- API endpoint validation
- Request/response model validation
- Health check verification
Run: cd services/vsm && pytest tests/unit -v
Validation Script
Location: services/vsm/validate.sh
Tests all API endpoints end-to-end:
- Health check
- Create work item
- Stage transition
- Work item history
- Flow metrics
- List stages
Run: ./services/vsm/validate.sh
Deployment Instructions
Prerequisites
- Kubernetes cluster with ArgoCD
- CloudNativePG operator installed
- Ingress controller configured
Deploy Steps
- Deploy PostgreSQL cluster:
kubectl apply -f platform/apps/postgresql/db-vsm-credentials.yaml
kubectl apply -f platform/apps/postgresql/db-vsm-cluster.yaml
- Wait for database to be ready:
kubectl wait --for=condition=Ready cluster/db-vsm-dev -n fawkes --timeout=300s
- Build and push Docker image:
cd services/vsm
./build.sh
docker tag vsm-service:latest <registry>/vsm-service:latest
docker push <registry>/vsm-service:latest
- Deploy via ArgoCD:
kubectl apply -f platform/apps/vsm-service-application.yaml
- Verify deployment:
kubectl get pods -n fawkes -l app=vsm-service
kubectl logs -n fawkes -l app=vsm-service
- Run validation:
export VSM_URL=http://vsm-service.127.0.0.1.nip.io
./services/vsm/validate.sh
API Usage Examples
Create Work Item
curl -X POST http://vsm-service.127.0.0.1.nip.io/api/v1/work-items \
-H "Content-Type: application/json" \
-d '{"title": "Implement feature X", "type": "feature"}'
Transition Stage
curl -X PUT http://vsm-service.127.0.0.1.nip.io/api/v1/work-items/1/transition \
-H "Content-Type: application/json" \
-d '{"to_stage": "Development"}'
Get Flow Metrics
curl http://vsm-service.127.0.0.1.nip.io/api/v1/metrics?days=7
View API Documentation
Open: http://vsm-service.127.0.0.1.nip.io/docs
Architecture
┌─────────────────┐
│ Work Items │
│ (Features, │
│ Bugs, etc) │
└────────┬────────┘
│
▼
┌─────────────────────────────────────────┐
│ Value Stream Stages │
├─────────────────────────────────────────┤
│ Backlog → Analysis → Development → │
│ Testing → Deployment → Production │
└────────┬────────────────────────────────┘
│
▼
┌─────────────────┐
│ Flow Metrics │
│ - Throughput │
│ - WIP │
│ - Cycle Time │
└─────────────────┘
Security Features
- Non-root container (UID/GID 10001)
- Read-only root filesystem support
- Security context constraints
- No privileged escalation
- Database credentials in secrets
- TLS-ready PostgreSQL connections
Monitoring & Observability
- Prometheus metrics endpoint (
/metrics) - Health/readiness probes
- Structured logging
- OpenTelemetry instrumentation ready
- Flow metrics tracking:
- Throughput (items/period)
- WIP (work in progress)
- Cycle time (avg, p50, p85, p95)
Future Enhancements
- [ ] Custom stage definitions
- [ ] Work item dependencies
- [ ] Team/project segmentation
- [ ] SLA tracking
- [ ] Automated flow metric aggregation
- [ ] Grafana dashboard templates
- [ ] Webhook notifications
- [ ] REST API rate limiting
- [ ] External Secrets Operator integration
Resources
- Service Code:
services/vsm/ - K8s Manifests:
platform/apps/vsm-service/ - Database Schema:
services/vsm/migrations/ - Documentation:
services/vsm/README.md - Issue: paruff/fawkes#51