Forma3D.Connect — Implementation Plan¶
Version: 2.6
Date: January 19, 2026
Status: Active
Related Documents: Vision | Requirements | Architecture
1. Executive Summary¶
This document outlines the phased implementation plan for Forma3D.Connect, detailing the features to be developed, their dependencies, and the recommended development sequence. The plan is designed to deliver incremental value while building toward a fully automated print-on-demand integration.
2. Implementation Phases Overview¶
Phase 0: Foundation [2 weeks] → Infrastructure & Setup ✅ COMPLETE
Phase 1: Shopify Inbound [3 weeks] → Order Reception & Storage ✅ COMPLETE
Phase 1b: Observability [1 week] → Sentry, OpenTelemetry, Logging ✅ COMPLETE
Phase 1c: Staging Deployment[1 week] → Docker, Traefik, DigitalOcean ✅ COMPLETE
Phase 1d: Acceptance Testing[0.5 week] → Playwright, Gherkin, CI ✅ COMPLETE
Phase 2: SimplyPrint Core [3 weeks] → Print Job Automation ✅ COMPLETE
Phase 3: Fulfillment Loop [2 weeks] → Complete Automation Cycle ✅ COMPLETE (MVP!)
Phase 4: Dashboard MVP [3 weeks] → Administrative Interface ✅ COMPLETE
Phase 5: Shipping [2 weeks] → Sendcloud Integration ✅ COMPLETE
Phase 5b: Domain Boundaries [1 week] → Microservices Preparation ✅ COMPLETE
Phase 5c: Webhook Idempotency[0.5 week] → Tech Debt TD-001 Resolution ✅ COMPLETE
Phase 5d: Frontend Tests [1 week] → Tech Debt TD-002 Resolution ✅ COMPLETE
Phase 5e: JSON Schemas [0.5 week] → Tech Debt TD-003 Resolution ✅ COMPLETE
Phase 5f: Shared Types [0.5 week] → Tech Debt TD-004 Resolution ✅ COMPLETE
Phase 5g: Structured Logging[0.5 week] → Tech Debt TD-005 Resolution ✅ COMPLETE
Phase 5h: Controller Tests [0.5 week] → Tech Debt TD-006 Resolution ✅ COMPLETE
Phase 5i: Domain Contracts [0.5 week] → Tech Debt TD-007 Resolution ✅ COMPLETE
Phase 5j: Error Types [0.5 week] → Tech Debt TD-008 Resolution ✅ COMPLETE
Phase 5k: Configuration [0.5 week] → Tech Debt TD-009 Resolution ✅ COMPLETE
Phase 6: Hardening [2 weeks] → Production Readiness ✅ COMPLETE
Phase 7: PWA [1 week] → Cross-Platform Mobile/Desktop ✅ COMPLETE
─────────
26.5 weeks total
Current Status (January 19, 2026): All phases 0-7 and tech debt phases 5e-5k complete. System is production-ready with full PWA support for cross-platform mobile and desktop access.
3. Phase 0: Foundation (Weeks 1-2)¶
3.1 Objectives¶
- Establish project infrastructure
- Set up development environment
- Create base application structure
- Configure CI/CD pipeline
3.2 Features¶
F0.1: Nx Monorepo Setup¶
| Attribute | Value |
|---|---|
| ID | F0.1 |
| Title | Initialize Nx Monorepo Structure |
| Description | Create the Nx monorepo with all required apps and libs |
| Effort | 8 hours |
| Dependencies | None |
Tasks:
- Initialize Nx workspace with pnpm
- Create
apps/api- NestJS backend application - Create
apps/web- React 19 frontend application - Create
libs/domain- Shared domain types and entities - Create
libs/api-client- Typed API client - Create
libs/utils- Shared utilities - Configure TypeScript strict mode
- Set up ESLint and Prettier
Deliverables:
- Working monorepo structure
- All projects compile successfully
- Lint passes on all projects
F0.2: Database Setup¶
| Attribute | Value |
|---|---|
| ID | F0.2 |
| Title | PostgreSQL and Prisma Configuration |
| Description | Set up database with Prisma ORM and initial schema |
| Effort | 6 hours |
| Dependencies | F0.1 |
Tasks:
- Create
prisma/schema.prismawith core entities - Configure database connection
- Create initial migration
- Set up Prisma Client generation
- Create database seed script for development
Schema Entities:
// Core entities to create:
- Order
- LineItem
- PrintJob
- ProductMapping
- EventLog
- SystemConfig
Deliverables:
- Prisma schema defined
- Database migrations created
- Development database seeded
F0.3: CI/CD Pipeline¶
| Attribute | Value |
|---|---|
| ID | F0.3 |
| Title | GitHub Actions CI/CD Setup |
| Description | Configure automated testing, linting, and deployment |
| Effort | 4 hours |
| Dependencies | F0.1 |
Tasks:
- Create
.github/workflows/ci.yml - Configure lint job
- Configure test job
- Configure build job
- Set up deployment workflow (staging)
Deliverables:
- CI runs on all PRs
- Lint and build must pass to merge
- Deployment to staging automated
F0.4: Environment Configuration¶
| Attribute | Value |
|---|---|
| ID | F0.4 |
| Title | Environment and Secrets Management |
| Description | Set up environment variables and secrets handling |
| Effort | 2 hours |
| Dependencies | F0.1 |
Tasks:
- Create
.env.examplewith all required variables - Configure environment validation on startup
- Document environment setup in README
- Set up local development environment
Environment Variables:
# Database
DATABASE_URL=
# Shopify
SHOPIFY_SHOP_DOMAIN=
SHOPIFY_API_KEY=
SHOPIFY_API_SECRET=
SHOPIFY_ACCESS_TOKEN=
SHOPIFY_WEBHOOK_SECRET=
# SimplyPrint
SIMPLYPRINT_API_URL=
SIMPLYPRINT_API_KEY=
# Sendcloud
SENDCLOUD_PUBLIC_KEY=
SENDCLOUD_SECRET_KEY=
# App
APP_URL=
APP_PORT=
NODE_ENV=
Deliverables:
- Environment template documented
- Validation on startup
- Local development works
3.3 Phase 0 Exit Criteria¶
- Nx monorepo builds successfully ✅
- Database schema created and migrations run ✅
- CI pipeline executes on all PRs ✅
- Development environment documented ✅
Status: Phase 0 COMPLETE ✅
4. Phase 1: Shopify Inbound (Weeks 3-5)¶
4.1 Objectives¶
- Establish Shopify API connection
- Receive and store orders via webhooks
- Create product mapping system
4.2 Features¶
F1.0: OpenAPI/Swagger Documentation ✅¶
| Attribute | Value |
|---|---|
| ID | F1.0 |
| Title | OpenAPI/Swagger API Documentation |
| Description | Interactive API documentation with Swagger UI |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F0.1 |
Implementation:
- Installed
@nestjs/swaggerpackage - Configured Swagger in
main.tswith DocumentBuilder - Added API decorators to all controllers:
@ApiTagsfor grouping endpoints@ApiOperationfor endpoint descriptions@ApiResponsefor response documentation@ApiParamand@ApiQueryfor parameter documentation- Added
@ApiPropertydecorators to all DTOs - Swagger UI available at
/api/docsin non-production environments
Access:
- Development:
http://localhost:3000/api/docs - Staging:
https://staging-api.forma3d.be/api/docs
Features:
- Interactive API testing directly from documentation
- Auto-generated OpenAPI 3.0 specification
- Request/response schema documentation
- Grouped by feature (Health, Orders, Product Mappings, Shopify Webhooks)
Deliverables:
- ✅ Swagger UI accessible at
/api/docs - ✅ All endpoints documented
- ✅ All DTOs with property descriptions
- ✅ OpenAPI JSON available at
/api/docs-json
F1.0b: Aikido Security Platform Integration ✅¶
| Attribute | Value |
|---|---|
| ID | F1.0b |
| Title | Aikido Security Platform Integration |
| Description | Continuous security monitoring, vulnerability scanning, and SBOM generation |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F0.3 (CI/CD Pipeline) |
Implementation:
- Integrated Aikido Security Platform into the development pipeline
- Configured automated security scanning for all code changes
- Enabled SBOM (Software Bill of Materials) generation
- Set up monitoring dashboards for security compliance
Security Checks Enabled:
| Check | Status | Description |
|---|---|---|
| Open Source Dependency Monitoring | Active | Monitors 3rd party dependencies for vulnerabilities |
| Exposed Secrets Monitoring | Compliant | Detects accidentally exposed secrets in source code |
| License Management | Compliant | Validates dependency licenses for legal compliance |
| SAST | Compliant | Static Application Security Testing |
| IaC Testing | Compliant | Infrastructure as Code security analysis |
| Malware Detection | Compliant | Detects malware in dependencies |
| Mobile Issues | Compliant | Mobile manifest file monitoring |
| SBOM Generation | Active | Software Bill of Materials for supply chain security |
Future Enhancements:
- Code quality analysis will be enabled in a subsequent phase
Deliverables:
- ✅ Aikido integrated into CI/CD pipeline
- ✅ All security checks active and compliant
- ✅ SBOM generation enabled
- ✅ Security monitoring dashboard available
F1.1: Shopify API Client¶
| Attribute | Value |
|---|---|
| ID | F1.1 |
| Title | Shopify REST/GraphQL API Client |
| Description | Create typed client for Shopify Admin API interactions |
| Effort | 12 hours |
| Dependencies | F0.1 |
Tasks:
- Create Shopify client module in
libs/api-client - Implement authentication (OAuth/API key)
- Create typed DTOs for Shopify entities
- Implement order retrieval methods
- Implement fulfillment creation methods
- Add request rate limiting
- Add error handling and retry logic
- Write unit tests
API Methods:
interface ShopifyClient {
// Orders
getOrder(orderId: string): Promise<ShopifyOrder>;
getOrders(params: OrderQueryParams): Promise<ShopifyOrder[]>;
// Fulfillment
createFulfillment(orderId: string, data: FulfillmentInput): Promise<Fulfillment>;
// Products
getProducts(): Promise<ShopifyProduct[]>;
getProductVariants(productId: string): Promise<ShopifyVariant[]>;
// Webhooks
registerWebhook(topic: string, address: string): Promise<Webhook>;
listWebhooks(): Promise<Webhook[]>;
}
Deliverables:
- Typed Shopify client
- 100% test coverage for client
- Error handling documented
F1.2: Webhook Receiver¶
| Attribute | Value |
|---|---|
| ID | F1.2 |
| Title | Shopify Webhook Endpoint |
| Description | Create secure webhook endpoint for Shopify events |
| Effort | 8 hours |
| Dependencies | F1.1, F0.2 |
Tasks:
- Create webhook controller in NestJS
- Implement HMAC signature verification
- Create webhook payload parsers
- Handle
orders/createevents - Handle
orders/updatedevents - Handle
orders/cancelledevents - Implement idempotency (prevent duplicate processing)
- Add comprehensive logging
- Write integration tests
Endpoint:
POST /api/v1/webhooks/shopify
Headers:
X-Shopify-Topic: orders/create
X-Shopify-Hmac-SHA256: <signature>
X-Shopify-Shop-Domain: <shop>
Deliverables:
- Webhook endpoint operational
- HMAC verification working
- All webhook topics handled
F1.3: Order Storage Service¶
| Attribute | Value |
|---|---|
| ID | F1.3 |
| Title | Order Persistence and Management |
| Description | Service layer for order storage and status management |
| Effort | 10 hours |
| Dependencies | F0.2, F1.2 |
Tasks:
- Create Order repository (Prisma)
- Create LineItem repository
- Create Order service with business logic
- Implement order creation from webhook
- Implement order status transitions
- Implement order queries (by status, date, etc.)
- Add event logging for all state changes
- Write unit and integration tests
Order State Machine:
pending → processing → completed
│ │ │
└────────▼────────────▼
cancelled
failed (from any state)
Deliverables:
- Order service operational
- State transitions enforced
- Event logging working
F1.4: Product Mapping System¶
| Attribute | Value |
|---|---|
| ID | F1.4 |
| Title | Product-to-Print Mapping Configuration |
| Description | System to map Shopify products to SimplyPrint files |
| Effort | 8 hours |
| Dependencies | F0.2 |
Tasks:
- Create ProductMapping repository
- Create ProductMapping service
- Implement CRUD operations for mappings
- Implement SKU-based lookup
- Handle unmapped product detection
- Create mapping validation
- Write tests
Mapping Structure:
interface ProductMapping {
id: string;
shopifyProductId: string;
shopifyVariantId: string;
sku: string;
simplyPrintFileId: string;
printProfile: {
material?: string;
quality?: string;
infill?: number;
supports?: boolean;
};
isActive: boolean;
}
Deliverables:
- Mapping service operational
- Lookup by SKU working
- Unmapped products flagged
4.3 Phase 1 Exit Criteria¶
- OpenAPI/Swagger documentation available ✅
- Aikido Security Platform integrated ✅
- Shopify webhooks received and verified ✅
- Orders stored in database ✅
- Order status tracking working ✅
- Product mappings configurable ✅
- Integration tests passing ✅
Status: Phase 1 COMPLETE ✅
Implemented Components:
apps/api/src/shopify/— Shopify webhook receiver and API clientapps/api/src/orders/— Order service, repository, controller, and DTOsapps/api/src/product-mappings/— Product mapping CRUD operationsapps/api/src/event-log/— Event logging serviceapps/api-e2e/src/— E2E tests for orders, product-mappings, and shopify-webhooks- Unit tests for all services with Jest
- Aikido Security Platform — Continuous security monitoring and SBOM generation
4b. Phase 1b: Sentry Observability (Week 6) ✅¶
4b.1 Objectives¶
- ✅ Integrate Sentry for error tracking and performance monitoring
- ✅ Implement structured logging with correlation IDs
- ✅ Set up OpenTelemetry-first architecture for vendor neutrality
- ✅ Add React error boundaries for graceful error handling
4b.2 Features¶
F1b.1: Backend Observability ✅¶
| Attribute | Value |
|---|---|
| ID | F1b.1 |
| Title | Sentry + OpenTelemetry for NestJS Backend |
| Description | Error tracking, performance monitoring, and distributed tracing |
| Effort | 8 hours |
| Status | ✅ Completed |
| Dependencies | Phase 1 complete |
Tasks:
- Create
libs/observabilityshared library - Install Sentry and OpenTelemetry dependencies
- Create
instrument.tsfor Sentry initialization (must run first) - Create
ObservabilityModulewith Pino logger - Create
SentryExceptionFilterfor error capture - Create
LoggingInterceptorwith correlation IDs - Update Prisma service with Sentry breadcrumbs
- Configure environment variables
- Write unit tests
Deliverables:
- Errors captured and sent to Sentry
- Performance traces recorded
- Structured JSON logs with correlation IDs
- Prisma query tracing
F1b.2: Frontend Observability ✅¶
| Attribute | Value |
|---|---|
| ID | F1b.2 |
| Title | Sentry for React Frontend |
| Description | Error boundaries and performance monitoring for React |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F1b.1 |
Tasks:
- Install
@sentry/reactdependencies - Create
sentry.tsinitialization file - Create
ErrorBoundarycomponent with Sentry integration - Update
main.tsxto initialize Sentry and wrap app - Add performance monitoring for routes
- Write unit tests
Deliverables:
- React errors captured with component stack
- Error boundary with user-friendly fallback UI
- Performance traces for page navigation
F1b.3: Structured Logging ✅¶
| Attribute | Value |
|---|---|
| ID | F1b.3 |
| Title | JSON Logging with Correlation IDs |
| Description | Structured logging with Pino and trace context propagation |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F1b.1 |
Tasks:
- Install
pino,pino-pretty,nestjs-pino - Configure Pino with JSON format for production
- Add correlation ID generation and propagation
- Configure sensitive field redaction
- Update logging across all services
Deliverables:
- JSON logs with consistent structure
- Correlation IDs in all log entries
- Sensitive data automatically redacted
F1b.4: Observability Library ✅¶
| Attribute | Value |
|---|---|
| ID | F1b.4 |
| Title | Shared Observability Configuration |
| Description | Reusable observability configuration in libs/ |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F0.1 |
Tasks:
- Create
libs/observabilityNx library - Define Sentry configuration types and defaults
- Define OpenTelemetry configuration
- Export constants and utilities
- Write unit tests
Deliverables:
- Shared observability library
- Consistent configuration across apps
- Free Tier compatible sampling defaults
4b.3 Phase 1b Exit Criteria ✅¶
- Sentry SDK integrated in backend and frontend
- Errors captured with context and stack traces
- Performance monitoring enabled
- Structured JSON logging with correlation IDs
- Prisma queries traced
- 100% sampling (adjustable when traffic increases)
- Sensitive data scrubbed from logs and Sentry
- Unit tests passing
- Documentation updated in README.md
- Test endpoints for observability verification
4c. Phase 1c: Staging Deployment (Week 7) ✅¶
4c.1 Objectives¶
- ✅ Implement automated Docker image building and publishing
- ✅ Deploy to staging environment on DigitalOcean
- ✅ Configure Traefik reverse proxy with TLS
- ✅ Establish zero-downtime deployment pipeline
4c.2 Features¶
F1c.1: Docker Image Build ✅¶
| Attribute | Value |
|---|---|
| ID | F1c.1 |
| Title | Docker Image Build with Labels |
| Description | Build Docker images with proper tagging and labels |
| Effort | 3 hours |
| Status | ✅ Completed |
| Dependencies | Phase 1b complete |
Tasks:
- ✅ Create API Dockerfile with multi-stage build
- ✅ Create Web Dockerfile with Nginx
- ✅ Add Docker labels for traceability
- ✅ Configure image tagging with pipeline instance name
Deliverables:
- ✅ API and Web Dockerfiles
- ✅ Images tagged with
YYYYMMDDhhmmssformat - ✅ Labels include git commit, build date, version
F1c.2: Container Registry Push ✅¶
| Attribute | Value |
|---|---|
| ID | F1c.2 |
| Title | DigitalOcean Container Registry Integration |
| Description | Push images to DigitalOcean Container Registry |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F1c.1 |
Tasks:
- ✅ Configure registry authentication in pipeline
- ✅ Push images with version tag and
latesttag - ✅ Verify image availability in registry
Deliverables:
- ✅ Images pushed to DigitalOcean registry
- ✅ Authentication via Secure Files
F1c.3: Staging Deployment ✅¶
| Attribute | Value |
|---|---|
| ID | F1c.3 |
| Title | Automated Staging Deployment |
| Description | Deploy via SSH + Docker Compose with migrations |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F1c.2 |
Tasks:
- ✅ Create Docker Compose for staging stack
- ✅ Configure SSH deployment in pipeline
- ✅ Run Prisma migrations before deployment
- ✅ Implement zero-downtime container replacement
- ✅ Add deployment verification (acceptance test stage)
Deliverables:
- ✅ Docker Compose configuration
- ✅ Deployment script
- ✅ Automated migration handling
F1c.4: Traefik Configuration ✅¶
| Attribute | Value |
|---|---|
| ID | F1c.4 |
| Title | Traefik Reverse Proxy with TLS |
| Description | Configure Traefik with Let's Encrypt certificates |
| Effort | 3 hours |
| Status | ✅ Completed |
| Dependencies | F1c.3 |
Tasks:
- ✅ Create Traefik configuration
- ✅ Configure Let's Encrypt certificate resolver
- ✅ Set up HTTP to HTTPS redirection
- ✅ Configure routing labels for API and Web
- ✅ Add health check endpoints
Deliverables:
- ✅ Traefik configuration file
- ✅ Automatic TLS certificate issuance
- ✅ Secure routing for API and Web
4c.3 Staging URLs¶
| Service | URL |
|---|---|
| API | https://staging-connect-api.forma3d.be |
| Web | https://staging-connect.forma3d.be |
4c.4 Phase 1c Exit Criteria ✅¶
- Docker images build with correct tags and labels ✅
- Images pushed to DigitalOcean Container Registry ✅
- Traefik issues TLS certificates via Let's Encrypt ✅
- Database migrations run before container deployment ✅
- Zero-downtime deployments working ✅
- API accessible at staging URL ✅
- Web accessible at staging URL ✅
- Health checks pass for all services ✅
- Pipeline deploys automatically on main/develop branch ✅
Status: Phase 1c COMPLETE ✅
Implemented Components:
apps/api/Dockerfile— Multi-stage API Docker buildapps/web/Dockerfile— Multi-stage Web Docker build with Nginxdeployment/staging/docker-compose.yml— Staging stack configurationdeployment/staging/traefik.yml— Traefik reverse proxy with ACMEazure-pipelines.yml— Full CI/CD pipeline with Package & Deploy stages- Acceptance Test stage with health check verification
4d. Phase 1d: Acceptance Testing (Week 7.5) ✅¶
4d.1 Objectives¶
- ✅ Implement automated acceptance testing with Playwright and Gherkin
- ✅ Create readable Given/When/Then test scenarios
- ✅ Integrate acceptance tests into Azure DevOps pipeline
- ✅ Ensure deployment verification before proceeding
4d.2 Features¶
F1d.1: Acceptance Test Project ✅¶
| Attribute | Value |
|---|---|
| ID | F1d.1 |
| Title | Nx Project with Playwright + Gherkin |
| Description | Create dedicated acceptance test project in the monorepo |
| Effort | 3 hours |
| Status | ✅ Completed |
| Dependencies | Phase 1c complete |
Tasks:
- Create
apps/acceptance-testsNx project - Install Playwright and Gherkin dependencies
- Configure Playwright for BDD testing
- Create project.json with test targets
- Set up environment configuration
Deliverables:
- Acceptance test project structure
- Playwright + Gherkin integration working
- Test targets for local and staging
F1d.2: Gherkin Feature Files ✅¶
| Attribute | Value |
|---|---|
| ID | F1d.2 |
| Title | Given/When/Then Acceptance Scenarios |
| Description | Human-readable test scenarios in Gherkin syntax |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F1d.1 |
Tasks:
- Create health-check.feature for API health verification
- Create api-docs.feature for Swagger UI verification
- Create web-dashboard.feature for frontend smoke tests
- Apply appropriate tags (@smoke, @critical, @api, @web)
Deliverables:
- Feature files with Given/When/Then scenarios
- Scenarios readable by non-developers
- Tags for test filtering
F1d.3: Playwright Step Definitions ✅¶
| Attribute | Value |
|---|---|
| ID | F1d.3 |
| Title | Step Implementations with Playwright |
| Description | TypeScript step definitions using Playwright API |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F1d.2 |
Tasks:
- Create step definitions for health check scenarios
- Create step definitions for API documentation scenarios
- Create step definitions for web dashboard scenarios
- Create support files (world context, hooks)
- Implement screenshot capture on failure
Deliverables:
- All Gherkin steps implemented
- API and browser test support
- Failure screenshot capture
F1d.4: Pipeline Integration ✅¶
| Attribute | Value |
|---|---|
| ID | F1d.4 |
| Title | Azure DevOps Acceptance Test Stage |
| Description | Pipeline stage for post-deployment acceptance tests |
| Effort | 1 hour |
| Status | ✅ Completed |
| Dependencies | F1d.3 |
Tasks:
- Add AcceptanceTests stage to azure-pipelines.yml
- Install Playwright browsers in CI
- Run tests against staging environment
- Publish JUnit results to Azure DevOps
- Publish HTML report as artifact
Deliverables:
- Acceptance test stage in pipeline
- Test results visible in Azure DevOps UI
- HTML report as pipeline artifact
4d.3 Phase 1d Exit Criteria¶
- Acceptance test project created with Playwright + Gherkin ✅
- Feature files written in Given/When/Then format ✅
- Step definitions implemented with Playwright ✅
- Tests pass against staging environment ✅
- Azure DevOps pipeline includes acceptance test stage ✅
- Test results published to Azure DevOps UI ✅
- Pipeline fails if acceptance tests fail ✅
Status: Phase 1d COMPLETE ✅
Phase 1d Implementation Notes (Completed 2026-01-14):
| Component | Path | Description |
|---|---|---|
| Acceptance Tests Project | apps/acceptance-tests/ |
Playwright + Gherkin BDD testing |
| Feature Files | apps/acceptance-tests/src/features/ |
14 Gherkin feature files |
| Step Definitions | apps/acceptance-tests/src/steps/ |
TypeScript step implementations |
| Pipeline Stage | azure-pipelines.yml |
AcceptanceTests stage with Playwright |
| Reports | Published to Azure DevOps | JUnit + Cucumber HTML + Playwright HTML |
Feature Files:
- health-check.feature — API health verification
- api-docs.feature — Swagger UI verification
- web-dashboard.feature — Frontend smoke tests
- orders-management.feature — Order management UI tests
- product-mappings.feature — Product mapping tests
- activity-logs.feature — Activity logs tests
- fulfillment.feature — Fulfillment flow tests
- cancellation.feature — Cancellation flow tests
- Plus 6 additional feature files for comprehensive coverage
5. Phase 2: SimplyPrint Core (Weeks 8-10) ✅¶
5.1 Objectives¶
- ✅ Establish SimplyPrint API connection
- ✅ Automate print job creation
- ✅ Monitor print job status
5.2 Features¶
F2.1: SimplyPrint API Client ✅¶
| Attribute | Value |
|---|---|
| ID | F2.1 |
| Title | SimplyPrint API Client |
| Description | Create typed client for SimplyPrint API interactions |
| Effort | 16 hours |
| Status | ✅ Completed |
| Dependencies | F0.1 |
Tasks:
- Research SimplyPrint API documentation thoroughly
- Create SimplyPrint client module
- Implement authentication
- Create typed DTOs for SimplyPrint entities
- Implement job creation methods
- Implement job status retrieval
- Implement job cancellation
- Implement printer status retrieval
- Implement file/queue listing
- Add error handling and retry logic
- Write unit tests with mocks
API Methods (Expected):
interface SimplyPrintClient {
// Authentication
authenticate(): Promise<void>;
// Files
getFiles(): Promise<PrintFile[]>;
getFileById(fileId: string): Promise<PrintFile>;
// Print Jobs
createJob(params: CreateJobParams): Promise<PrintJob>;
getJob(jobId: string): Promise<PrintJob>;
getJobStatus(jobId: string): Promise<JobStatus>;
cancelJob(jobId: string): Promise<void>;
// Queue
getQueue(): Promise<QueuedJob[]>;
// Printers
getPrinters(): Promise<Printer[]>;
getPrinterStatus(printerId: string): Promise<PrinterStatus>;
}
Deliverables:
- Typed SimplyPrint client
- Test coverage with mocks
- Error handling documented
F2.2: Print Job Creation Service ✅¶
| Attribute | Value |
|---|---|
| ID | F2.2 |
| Title | Automated Print Job Creation |
| Description | Service to create print jobs from order line items |
| Effort | 12 hours |
| Status | ✅ Completed |
| Dependencies | F2.1, F1.3, F1.4 |
Tasks:
- Create PrintJob repository
- Create PrintJob service
- Implement job creation workflow:
- Lookup product mapping
- Retrieve file reference
- Create job in SimplyPrint
- Store job reference locally
- Handle creation failures
- Implement retry logic for transient failures
- Add event logging
- Write tests
Job Creation Flow:
Order Line Item
│
▼
ProductMapping Lookup
│
├─ Not Found → Flag for Review
│
▼
SimplyPrint Job Create
│
├─ Success → Store PrintJob
│
└─ Failure → Retry / Alert
Deliverables:
- Print jobs created automatically
- Failures handled gracefully
- Event logging complete
F2.3: Print Job Status Monitor ✅¶
| Attribute | Value |
|---|---|
| ID | F2.3 |
| Title | Print Job Status Monitoring |
| Description | Track print job status changes from SimplyPrint |
| Effort | 12 hours |
| Status | ✅ Completed |
| Dependencies | F2.1, F2.2 |
Tasks:
- Determine monitoring method:
- Option A: SimplyPrint webhooks (preferred)
- Option B: Polling-based monitoring
- Implement webhook receiver OR polling scheduler
- Create status update handler
- Update local PrintJob records
- Trigger downstream events on status change
- Handle completion events
- Handle failure events
- Write tests
Status States:
enum PrintJobStatus {
QUEUED = 'queued',
ASSIGNED = 'assigned', // Assigned to printer
PRINTING = 'printing', // Currently printing
COMPLETED = 'completed', // Successfully finished
FAILED = 'failed', // Error during print
CANCELLED = 'cancelled', // Manually cancelled
}
Polling Configuration (if needed):
{
interval: 30000, // 30 seconds
activeJobInterval: 10000, // 10 seconds for active prints
maxConcurrentPolls: 10
}
Deliverables:
- Status changes detected within 60 seconds
- All status transitions handled
- Downstream events triggered
F2.4: Order-PrintJob Orchestration ✅¶
| Attribute | Value |
|---|---|
| ID | F2.4 |
| Title | Order Completion Orchestration |
| Description | Coordinate order status based on print job completion |
| Effort | 8 hours |
| Status | ✅ Completed |
| Dependencies | F2.2, F2.3, F1.3 |
Tasks:
- Create orchestration service
- Track all line items for an order
- Detect when all items are printed
- Handle partial completion scenarios
- Update order status to ready-for-fulfillment
- Emit fulfillment trigger event
- Write tests
Orchestration Logic:
On PrintJob Status Change:
1. Update LineItem status
2. Check if all LineItems for Order are complete
3. If all complete:
- Update Order status to 'completed'
- Emit 'order.ready-for-fulfillment' event
4. If any failed:
- Update Order status to 'partially-failed'
- Alert operator
Deliverables:
- Order completion detected
- Fulfillment event emitted
- Partial failures handled
5.3 Phase 2 Exit Criteria ✅¶
- Print jobs created in SimplyPrint from orders ✅
- Print status changes tracked ✅
- Order completion detected ✅
- Fulfillment events triggered ✅
- End-to-end flow working (order → print job) ✅
Status: Phase 2 COMPLETE ✅
Implemented Components:
apps/api/src/simplyprint/— SimplyPrint API client and webhook integrationsimplyprint-api.client.ts— Typed API client with HTTP Basic Authsimplyprint.service.ts— Status monitoring (webhook + polling)simplyprint-webhook.controller.ts— Webhook receiver endpointguards/simplyprint-webhook.guard.ts— Token verificationdto/— Request/response DTOsapps/api/src/print-jobs/— Print job managementprint-jobs.service.ts— Job creation and status updatesprint-jobs.repository.ts— Database operationsprint-jobs.controller.ts— REST API endpointsevents/print-job.events.ts— Event definitionsapps/api/src/orchestration/— Order-job coordinationorchestration.service.ts— Tracks job completion per orderlibs/api-client/src/simplyprint/— Shared types for SimplyPrint API
API Endpoints Added:
GET /api/v1/print-jobs— List print jobs with filtersGET /api/v1/print-jobs/active— Get active jobsGET /api/v1/print-jobs/:id— Get job detailsGET /api/v1/print-jobs/order/:orderId— Get jobs for orderPOST /api/v1/print-jobs/:id/cancel— Cancel a jobPOST /api/v1/print-jobs/:id/retry— Retry a failed jobPOST /webhooks/simplyprint— SimplyPrint webhook receiver
6. Phase 3: Fulfillment Loop (Weeks 9-10)¶
6.1 Objectives¶
- Automate Shopify fulfillment creation
- Complete the automation loop
- Handle edge cases
6.2 Features¶
F3.1: Shopify Fulfillment Service¶
| Attribute | Value |
|---|---|
| ID | F3.1 |
| Title | Automated Fulfillment Creation |
| Description | Create fulfillments in Shopify when orders complete |
| Effort | 10 hours |
| Dependencies | F1.1, F2.4 |
Tasks:
- Create Fulfillment service
- Listen for 'order.ready-for-fulfillment' events
- Build fulfillment payload with all line items
- Call Shopify fulfillment API
- Handle fulfillment creation errors
- Store fulfillment reference
- Update order to 'fulfilled' status
- Write tests
Fulfillment Creation:
async function createFulfillment(order: Order): Promise<void> {
const fulfillment = await shopifyClient.createFulfillment(order.shopifyOrderId, {
line_items: order.lineItems.map((li) => ({
id: li.shopifyLineItemId,
quantity: li.quantity,
})),
notify_customer: true,
tracking_info: order.trackingInfo, // Added in Phase 5
});
await orderService.markFulfilled(order.id, fulfillment.id);
}
Deliverables:
- Fulfillment created automatically
- Customer notified via Shopify
- Order marked fulfilled
F3.2: Cancellation Handling¶
| Attribute | Value |
|---|---|
| ID | F3.2 |
| Title | Order Cancellation Workflow |
| Description | Handle Shopify order cancellations |
| Effort | 6 hours |
| Dependencies | F1.2, F2.2 |
Tasks:
- Handle
orders/cancelledwebhook - Find associated print jobs
- Cancel queued/pending jobs in SimplyPrint
- Flag in-progress jobs for operator review
- Update local order status
- Write tests
Cancellation Logic:
On Order Cancelled:
For each PrintJob:
If status == 'queued':
Cancel in SimplyPrint
Update local status to 'cancelled'
If status == 'printing':
Flag for operator review
Notify operator
If status == 'completed':
Log warning (already printed)
Deliverables:
- Cancellations handled appropriately
- Queued jobs cancelled
- In-progress jobs flagged
F3.3: Error Recovery Service¶
| Attribute | Value |
|---|---|
| ID | F3.3 |
| Title | Automated Error Recovery |
| Description | Retry mechanisms and failure recovery |
| Effort | 8 hours |
| Dependencies | F2.2, F3.1 |
Tasks:
- Create retry queue system
- Implement exponential backoff
- Create failed job recovery process
- Create failed fulfillment recovery process
- Configure max retry attempts
- Alert after final failure
- Write tests
Retry Configuration:
{
maxRetries: 5,
initialDelay: 1000, // 1 second
maxDelay: 3600000, // 1 hour
backoffMultiplier: 2,
retryableErrors: [
'TIMEOUT',
'RATE_LIMITED',
'SERVICE_UNAVAILABLE'
]
}
Deliverables:
- Transient failures auto-recovered
- Permanent failures alerted
- Retry metrics available
F3.4: Event Bus and Notifications¶
| Attribute | Value |
|---|---|
| ID | F3.4 |
| Title | Internal Event System |
| Description | Event-driven architecture for component communication |
| Effort | 6 hours |
| Dependencies | F0.1 |
Tasks:
- Set up NestJS EventEmitter
- Define event types and payloads
- Create event handlers for key flows
- Implement email notification service
- Send alerts on critical failures
- Write tests
Events:
type Events = {
'order.created': OrderCreatedEvent;
'order.updated': OrderUpdatedEvent;
'order.ready-for-fulfillment': OrderReadyEvent;
'order.fulfilled': OrderFulfilledEvent;
'order.failed': OrderFailedEvent;
'printjob.created': PrintJobCreatedEvent;
'printjob.status-changed': PrintJobStatusChangedEvent;
'printjob.completed': PrintJobCompletedEvent;
'printjob.failed': PrintJobFailedEvent;
'system.error': SystemErrorEvent;
};
Deliverables:
- Event system operational
- Notifications sent on failures
- Events logged
6.3 Phase 3 Exit Criteria¶
- Complete automation loop: Order → Print → Fulfill ✅
- Cancellation handling working ✅
- Error recovery operational ✅
- Notifications sent on failures ✅
- End-to-end automated flow tested ✅
Status: Phase 3 COMPLETE — 🎯 MVP ACHIEVED ✅
Phase 3 Implementation Notes (Completed 2026-01-14):
| Component | Path | Description |
|---|---|---|
| FulfillmentService | apps/api/src/fulfillment/ |
Automated Shopify fulfillment creation |
| CancellationService | apps/api/src/cancellation/ |
Order/print job cancellation handling |
| RetryQueueService | apps/api/src/retry-queue/ |
Exponential backoff retry mechanism |
| NotificationsService | apps/api/src/notifications/ |
Email alerts for operator attention |
| RetryQueue model | prisma/schema.prisma |
Database table for retry job queue |
7. Phase 4: Dashboard MVP (Weeks 11-13)¶
7.1 Objectives¶
- Create administrative web interface
- Enable monitoring and manual overrides
- Configure product mappings
7.2 Features¶
F4.1: Dashboard Foundation¶
| Attribute | Value |
|---|---|
| ID | F4.1 |
| Title | React Dashboard Setup |
| Description | Create base React 19 application with routing and layout |
| Effort | 8 hours |
| Dependencies | F0.1 |
Tasks:
- Set up React 19 with Vite
- Configure Tailwind CSS
- Set up React Router
- Create layout components (sidebar, header)
- Create authentication flow (simple auth)
- Set up TanStack Query
- Create base API client
Pages:
/ → Dashboard overview
/orders → Order list
/orders/:id → Order detail
/print-jobs → Print job list
/mappings → Product mappings
/settings → System configuration
/logs → Activity logs
Deliverables:
- Dashboard shell running
- Authentication working
- Navigation functional
F4.2: Order Management UI¶
| Attribute | Value |
|---|---|
| ID | F4.2 |
| Title | Order List and Detail Views |
| Description | UI for viewing and managing orders |
| Effort | 12 hours |
| Dependencies | F4.1, F1.3 |
Tasks:
- Create Order List page
- Table with status, date, customer, items
- Filtering by status
- Searching by order number
- Pagination
- Create Order Detail page
- Order information display
- Line items with print job status
- Event timeline
- Action buttons
- Implement real-time updates via Socket.IO
- Create manual action handlers:
- Retry failed jobs
- Cancel pending jobs
- Force fulfill order
Order List Columns: | Column | Description | |--------|-------------| | Order # | Shopify order number | | Date | Order creation date | | Customer | Customer name | | Items | Number of line items | | Status | Current processing status | | Actions | Quick action buttons |
Deliverables:
- Order list functional
- Order detail with full info
- Manual actions working
F4.3: Product Mapping UI¶
| Attribute | Value |
|---|---|
| ID | F4.3 |
| Title | Product Mapping Configuration UI |
| Description | Interface for configuring product-to-print mappings |
| Effort | 10 hours |
| Dependencies | F4.1, F1.4, F2.1 |
Tasks:
- Create Mapping List page
- Show all Shopify products
- Indicate mapped/unmapped status
- Create Mapping Editor
- Select SimplyPrint file
- Configure print profile
- Activate/deactivate mapping
- Implement sync with Shopify products
- Show unmapped products alert
Deliverables:
- All products visible
- Mappings configurable
- Unmapped products highlighted
F4.4: Real-Time Updates¶
| Attribute | Value |
|---|---|
| ID | F4.4 |
| Title | Socket.IO Real-Time Integration |
| Description | Live updates for dashboard without page refresh |
| Effort | 6 hours |
| Dependencies | F4.1, F3.4 |
Tasks:
- Set up Socket.IO on backend
- Create Socket.IO client in React
- Emit events on order/job status changes
- Update UI in real-time
- Handle reconnection gracefully
Events:
// Server → Client
'order:updated'; // Order status changed
'printjob:updated'; // Print job status changed
'notification'; // Alert message
Deliverables:
- Dashboard updates in real-time
- No manual refresh needed
- Connection status visible
F4.5: Activity Logs UI¶
| Attribute | Value |
|---|---|
| ID | F4.5 |
| Title | Activity and Event Logs |
| Description | View system events and error logs |
| Effort | 6 hours |
| Dependencies | F4.1, F3.4 |
Tasks:
- Create Logs page
- Display events chronologically
- Filter by type, severity, date
- Link to related orders/jobs
- Export capability
Deliverables:
- Logs viewable in dashboard
- Filtering working
- Export available
7.3 Phase 4 Exit Criteria¶
- Dashboard accessible and authenticated ✅
- Order management fully functional ✅
- Product mappings configurable via UI ✅
- Real-time updates working ✅
- Activity logs available ✅
Status: Phase 4 COMPLETE ✅
Phase 4 Implementation Notes (Completed 2026-01-14):
| Component | Path | Description |
|---|---|---|
| TanStack Query | apps/web/src/lib/query-client.ts |
Server state management configuration |
| Auth Context | apps/web/src/contexts/auth-context.tsx |
API key authentication |
| Socket Context | apps/web/src/contexts/socket-context.tsx |
WebSocket real-time updates |
| UI Components | apps/web/src/components/ui/ |
Button, Badge, Card, Input, Select, Modal, Pagination |
| Orders Page | apps/web/src/pages/orders/ |
Order list and detail views |
| Mappings Page | apps/web/src/pages/mappings/ |
Product mapping CRUD UI |
| Logs Page | apps/web/src/pages/logs/ |
Activity logs with filtering and export |
| Settings Page | apps/web/src/pages/settings/ |
System configuration and status |
| WebSocket Gateway | apps/api/src/gateway/ |
Real-time event broadcasting |
| Event Log API | apps/api/src/event-log/event-log.controller.ts |
Log listing endpoint with filters |
Frontend Libraries Added:
- @headlessui/react — Accessible UI primitives
- @heroicons/react — Beautiful SVG icons
- date-fns — Date formatting
- clsx — Conditional classNames
- react-hot-toast — Toast notifications
- socket.io-client — WebSocket client
- @tanstack/react-query-devtools — React Query debugging
8. Phase 5: Shipping Integration (Weeks 14-15)¶
8.1 Objectives¶
- Integrate Sendcloud for shipping labels
- Automate tracking information sync
- Complete end-to-end flow
8.2 Features¶
F5.1: Sendcloud API Client¶
| Attribute | Value |
|---|---|
| ID | F5.1 |
| Title | Sendcloud API Integration |
| Description | Client for Sendcloud label generation and tracking |
| Effort | 8 hours |
| Dependencies | F0.1 |
Tasks:
- Create Sendcloud client module
- Implement authentication
- Create typed DTOs
- Implement parcel creation
- Implement label retrieval
- Implement tracking retrieval
- Write tests
API Methods:
interface SendcloudClient {
createParcel(data: ParcelInput): Promise<Parcel>;
getLabel(parcelId: number): Promise<LabelPDF>;
getTracking(parcelId: number): Promise<TrackingInfo>;
getShippingMethods(): Promise<ShippingMethod[]>;
}
Deliverables:
- Sendcloud client functional ✅
- Label generation working ✅
- Tracking retrieval working ✅
Implementation Notes (January 16, 2026):
apps/api/src/sendcloud/sendcloud-api.client.ts— Sendcloud HTTP client with Basic Authlibs/api-client/src/sendcloud/sendcloud.types.ts— Typed DTOs for Sendcloud API- Supports: createParcel, getParcel, getLabel, cancelParcel, getShippingMethods, getTracking
F5.2: Shipping Label Generation¶
| Attribute | Value |
|---|---|
| ID | F5.2 |
| Title | Automated Shipping Label Creation |
| Description | Generate shipping labels when orders are ready to ship |
| Effort | 8 hours |
| Dependencies | F5.1, F3.1 |
Tasks:
- Create Shipping service
- Trigger label generation on order completion
- Select appropriate shipping method
- Store parcel/tracking info
- Attach tracking to Shopify fulfillment
- Handle label generation errors
- Write tests
Deliverables:
- Labels generated automatically ✅
- Tracking attached to fulfillment ✅
- Errors handled ✅
Implementation Notes (January 16, 2026):
apps/api/src/sendcloud/sendcloud.service.ts— Business logic for shippingapps/api/src/shipments/shipments.repository.ts— Database operations for Shipment model- Listens to
order.ready-for-fulfillmentevent to auto-generate labels - Emits
shipment.createdevent when label is ready FulfillmentServicelistens toshipment.created(when shipping enabled) to ensure tracking is included in Shopify fulfillment- Uses retry queue for transient failures (SHIPMENT job type)
Why Custom API Integration vs Native Sendcloud-Shopify App:
We chose a custom Sendcloud API integration over the native Sendcloud-Shopify app because: - The native integration requires manual label creation in Sendcloud's dashboard - It doesn't know when 3D printing is complete - Our custom integration automates the entire flow: Print Complete → Label → Fulfill - See ADR-030 for detailed comparison
F5.3: Shipping Dashboard UI¶
| Attribute | Value |
|---|---|
| ID | F5.3 |
| Title | Shipping Management UI |
| Description | View and manage shipping labels |
| Effort | 6 hours |
| Dependencies | F4.2, F5.2 |
Tasks:
- Add shipping info to Order Detail
- Show tracking number and status
- Download label button
- Regenerate label option
- Shipping method override
Deliverables:
- Shipping info visible ✅
- Labels downloadable ✅
- Override available ✅
Implementation Notes (January 16, 2026):
apps/web/src/components/orders/shipping-info.tsx— ShippingInfo componentapps/web/src/hooks/use-shipments.ts— React Query hooks for shipping- Shipping section added to Order Detail page (
/orders/:id) - Supports: view shipment, download label, regenerate label, cancel shipment, select shipping method
8.3 Phase 5 Exit Criteria¶
- Shipping labels generated automatically ✅
- Tracking synced to Shopify ✅
- Labels downloadable from dashboard ✅
- Complete flow: Order → Print → Label → Fulfill ✅
Status: Phase 5 COMPLETE ✅
8b. Phase 5b: Domain Boundary Separation (Week 16) ✅¶
8b.1 Objectives¶
- ✅ Prepare modular monolith for potential microservices extraction
- ✅ Establish clean domain boundaries with interface contracts
- ✅ Add correlation ID infrastructure for distributed tracing
- ✅ Encapsulate repositories as internal implementation details
8b.2 Features¶
F5b.1: Correlation ID Infrastructure ✅¶
| Attribute | Value |
|---|---|
| ID | F5b.1 |
| Title | Correlation ID Propagation |
| Description | Request context propagation for distributed tracing |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | Phase 5 complete |
Tasks:
- ✅ Create
CorrelationMiddlewarefor HTTP request handling - ✅ Create
CorrelationServiceusingAsyncLocalStorage - ✅ Extract/generate
x-correlation-idheaders - ✅ Update all domain events to include correlation metadata
- ✅ Write unit tests
Deliverables:
- ✅ Correlation IDs propagated across all requests
- ✅ Events include
correlationId,timestamp,source
F5b.2: Domain Contracts Library ✅¶
| Attribute | Value |
|---|---|
| ID | F5b.2 |
| Title | Interface Definitions for Cross-Domain Communication |
| Description | Create dedicated library with interfaces and DTOs |
| Effort | 6 hours |
| Status | ✅ Completed |
| Dependencies | F5b.1 |
Tasks:
- ✅ Create
libs/domain-contractsNx library - ✅ Define service interfaces (
IOrdersService,IPrintJobsService, etc.) - ✅ Define DTOs for cross-domain communication
- ✅ Define Symbol injection tokens
- ✅ Write exports and barrel files
Deliverables:
- ✅
libs/domain-contractslibrary with all interfaces - ✅ DTOs:
OrderDto,LineItemDto,PrintJobDto, etc. - ✅ Tokens:
ORDERS_SERVICE,PRINT_JOBS_SERVICE, etc.
F5b.3: Repository Encapsulation ✅¶
| Attribute | Value |
|---|---|
| ID | F5b.3 |
| Title | Repository Isolation |
| Description | Stop exporting repositories, expose interfaces only |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F5b.2 |
Tasks:
- ✅ Update modules to export interface tokens instead of repositories
- ✅ Refactor services to implement domain interfaces
- ✅ Update consumers to inject via interface tokens
- ✅ Update tests to use interface mocks
Deliverables:
- ✅ Repositories are internal implementation details
- ✅ Cross-domain communication via interfaces only
F5b.4: Service Refactoring ✅¶
| Attribute | Value |
|---|---|
| ID | F5b.4 |
| Title | Interface-Based Service Dependencies |
| Description | Refactor services to depend on interfaces |
| Effort | 8 hours |
| Status | ✅ Completed |
| Dependencies | F5b.3 |
Tasks:
- ✅ Update
FulfillmentServiceto useIOrdersService - ✅ Update
OrchestrationServiceto use interfaces - ✅ Update
CancellationServiceto use interfaces - ✅ Update
SendcloudServiceto use interfaces - ✅ Update all test files for new patterns
- ✅ Verify all 355 tests pass
Deliverables:
- ✅ All services use interface-based dependencies
- ✅ All tests passing (355/355)
8b.3 Phase 5b Exit Criteria¶
- Correlation IDs propagated in all requests ✅
- Domain contracts library created with interfaces and DTOs ✅
- Repositories encapsulated (not exported from modules) ✅
- Services refactored to use interface dependencies ✅
- All tests passing (355/355) ✅
- ADR-032 documented ✅
Status: Phase 5b COMPLETE ✅
Phase 5b Implementation Notes (Completed 2026-01-17):
| Component | Path | Description |
|---|---|---|
| Correlation Middleware | apps/api/src/common/correlation/correlation.middleware.ts |
HTTP request correlation |
| Correlation Service | apps/api/src/common/correlation/correlation.service.ts |
AsyncLocalStorage context |
| Domain Contracts | libs/domain-contracts/ |
Interfaces and DTOs |
| Service Interfaces | libs/domain-contracts/src/lib/*.interface.ts |
IOrdersService, etc. |
| DTOs | libs/domain-contracts/src/lib/types.ts |
OrderDto, PrintJobDto, etc. |
| Tokens | libs/domain-contracts/src/lib/tokens.ts |
ORDERS_SERVICE, etc. |
8c. Phase 5c: Webhook Idempotency (Week 16.5) ✅¶
8c.1 Objectives¶
- ✅ Resolve critical technical debt TD-001
- ✅ Replace in-memory webhook idempotency with database-backed solution
- ✅ Ensure horizontal scaling compatibility
- ✅ Implement automatic cleanup of expired records
8c.2 Features¶
F5c.1: Database-backed Webhook Idempotency ✅¶
| Attribute | Value |
|---|---|
| ID | F5c.1 |
| Title | PostgreSQL Webhook Idempotency |
| Description | Replace in-memory Set with database table for webhook deduplication |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | Phase 5b complete |
Tasks:
- ✅ Create
ProcessedWebhookPrisma model with unique constraint - ✅ Create
webhook-idempotency.repository.tsfor database operations - ✅ Refactor
shopify.service.tsto use repository - ✅ Add 24-hour TTL for idempotency records
- ✅ Write unit tests
Deliverables:
- ✅
ProcessedWebhooktable in database - ✅ Race-condition safe with database unique constraint
- ✅ Horizontal scaling compatible
F5c.2: Webhook Cleanup Service ✅¶
| Attribute | Value |
|---|---|
| ID | F5c.2 |
| Title | Automated Cleanup of Expired Idempotency Records |
| Description | Scheduled job to remove webhooks older than 24 hours |
| Effort | 2 hours |
| Status | ✅ Completed |
| Dependencies | F5c.1 |
Tasks:
- ✅ Create
webhook-cleanup.service.tswith NestJS scheduler - ✅ Configure hourly cleanup job
- ✅ Add logging for cleanup operations
- ✅ Write unit tests
Deliverables:
- ✅ Hourly scheduled cleanup job
- ✅ No memory leak from unbounded record growth
8c.3 Phase 5c Exit Criteria¶
- ProcessedWebhook model created ✅
- Repository encapsulates database operations ✅
- Shopify service refactored to use repository ✅
- Cleanup job removes records older than 24 hours ✅
- All tests passing ✅
- TD-001 marked resolved in technical debt register ✅
Status: Phase 5c COMPLETE ✅
Phase 5c Implementation Notes (Completed 2026-01-17):
| Component | Path | Description |
|---|---|---|
| ProcessedWebhook Model | prisma/schema.prisma |
Database model for idempotency |
| Idempotency Repository | apps/api/src/shopify/webhook-idempotency.repository.ts |
Database operations |
| Cleanup Service | apps/api/src/shopify/webhook-cleanup.service.ts |
Scheduled cleanup job |
| Shopify Service | apps/api/src/shopify/shopify.service.ts |
Refactored to use repository |
8d. Phase 5d: Frontend Test Coverage (Week 17) ✅¶
8d.1 Objectives¶
- ✅ Resolve critical technical debt TD-002
- ✅ Establish frontend testing infrastructure with Vitest
- ✅ Achieve 60%+ test coverage for high-priority components
- ✅ Integrate frontend tests into CI/CD pipeline
8d.2 Features¶
F5d.1: Vitest Configuration ✅¶
| Attribute | Value |
|---|---|
| ID | F5d.1 |
| Title | Vitest Test Framework Setup |
| Description | Configure Vitest with React Testing Library for frontend testing |
| Effort | 3 hours |
| Status | ✅ Completed |
| Dependencies | Phase 5c complete |
Tasks:
- ✅ Create
vitest.config.tswith jsdom environment - ✅ Configure test setup file with jest-dom matchers
- ✅ Add coverage thresholds (60% statements/functions/lines)
- ✅ Configure CI reporters (JUnit, Cobertura)
- ✅ Install dependencies (
@testing-library/react,@vitest/coverage-v8)
Deliverables:
- ✅
apps/web/vitest.config.tsconfiguration - ✅
apps/web/src/test/setup.tstest setup - ✅
apps/web/src/test/test-utils.tsxcustom render utilities
F5d.2: MSW API Mocking ✅¶
| Attribute | Value |
|---|---|
| ID | F5d.2 |
| Title | Mock Service Worker Integration |
| Description | API mocking layer for deterministic testing |
| Effort | 3 hours |
| Status | ✅ Completed |
| Dependencies | F5d.1 |
Tasks:
- ✅ Create mock data factories for all API entities
- ✅ Define request handlers for all API endpoints
- ✅ Configure MSW server lifecycle in test setup
- ✅ Add error response handlers
Deliverables:
- ✅
apps/web/src/test/mocks/handlers.tsAPI handlers - ✅
apps/web/src/test/mocks/server.tsMSW server
F5d.3: Hook and Context Tests ✅¶
| Attribute | Value |
|---|---|
| ID | F5d.3 |
| Title | React Hook and Context Unit Tests |
| Description | Comprehensive tests for all custom hooks and contexts |
| Effort | 6 hours |
| Status | ✅ Completed |
| Dependencies | F5d.2 |
Tasks:
- ✅ Test
use-orders.tshook (data fetching, mutations) - ✅ Test
use-dashboard.tshook (dashboard stats) - ✅ Test
use-mappings.tshook (CRUD operations) - ✅ Test
use-logs.tshook (filtering, pagination) - ✅ Test
use-health.tshook (health checks) - ✅ Test
use-shipments.tshook (shipping operations) - ✅ Test
auth-context.tsx(login, logout, persistence)
Deliverables:
- ✅ 6 hook test files (61 tests)
- ✅ 1 context test file (17 tests)
F5d.4: UI Component Tests ✅¶
| Attribute | Value |
|---|---|
| ID | F5d.4 |
| Title | Core UI Component Tests |
| Description | Tests for reusable UI components |
| Effort | 4 hours |
| Status | ✅ Completed |
| Dependencies | F5d.2 |
Tasks:
- ✅ Test Badge component (variants, sizes)
- ✅ Test Button component (variants, loading, disabled)
- ✅ Test Card component (composition patterns)
- ✅ Test Loading component (states, overlays)
- ✅ Test Pagination component (navigation, edge cases)
- ✅ Test API client (error handling, request construction)
Deliverables:
- ✅ 5 UI component test files (85 tests)
- ✅ 1 API client test file (37 tests)
8d.3 Phase 5d Exit Criteria¶
- Vitest configured with React Testing Library ✅
- MSW handlers for all API endpoints ✅
- 200 frontend tests created ✅
- 60%+ coverage threshold met ✅
- CI/CD pipeline integration (JUnit + Cobertura) ✅
- TD-002 marked resolved in technical debt register ✅
Status: Phase 5d COMPLETE ✅
Phase 5d Implementation Notes (Completed 2026-01-17):
| Component | Path | Description |
|---|---|---|
| Vitest Config | apps/web/vitest.config.ts |
Test runner configuration |
| Test Setup | apps/web/src/test/setup.ts |
Global test setup |
| Test Utilities | apps/web/src/test/test-utils.tsx |
Custom render with providers |
| MSW Handlers | apps/web/src/test/mocks/handlers.ts |
API mocking |
| Hook Tests | apps/web/src/hooks/__tests__/*.test.tsx |
6 files, 61 tests |
| Context Tests | apps/web/src/contexts/__tests__/*.test.tsx |
1 file, 17 tests |
| API Client Tests | apps/web/src/lib/__tests__/*.test.ts |
1 file, 37 tests |
| UI Component Tests | apps/web/src/components/ui/__tests__/*.test.tsx |
5 files, 85 tests |
Test Summary:
| Category | Files | Tests |
|---|---|---|
| Hooks | 6 | 61 |
| Contexts | 1 | 17 |
| API Client | 1 | 37 |
| UI Components | 5 | 85 |
| Total | 13 | 200 |
8e. Phase 5e: Typed JSON Schemas (Week 20.5) ✅¶
8e.1 Objectives¶
- ✅ Resolve technical debt TD-003 (Untyped JSON Columns)
- ✅ Add Zod schemas for all JSON database columns
- ✅ Implement runtime validation at read/write boundaries
8e.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5e.1 Zod Schemas | Create schemas for ShippingAddress, PrintProfile, EventMetadata, WebhookPayload | 4 hours | ✅ |
| F5e.2 JSON Transformers | Prisma read/write validation helpers | 4 hours | ✅ |
| F5e.3 Repository Updates | Integrate typed JSON in repositories | 6 hours | ✅ |
| F5e.4 Schema Tests | Unit tests for all schemas | 4 hours | ✅ |
8e.3 Exit Criteria¶
- All JSON columns have Zod schemas ✅
- Validation at repository boundaries ✅
- Schema tests passing ✅
- TD-003 marked resolved ✅
Status: Phase 5e COMPLETE ✅
8f. Phase 5f: Shared API Types (Week 21) ✅¶
8f.1 Objectives¶
- ✅ Resolve technical debt TD-004 (Duplicated DTO Definitions)
- ✅ Create shared API types in libs/domain-contracts
- ✅ Eliminate duplicate type definitions between frontend and backend
8f.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5f.1 Shared Types | Create API response/request types in domain-contracts | 4 hours | ✅ |
| F5f.2 Frontend Integration | Update API client to use shared types | 4 hours | ✅ |
| F5f.3 Backend Integration | Update DTOs to implement shared interfaces | 4 hours | ✅ |
8f.3 Exit Criteria¶
- All API types in libs/domain-contracts ✅
- Frontend uses shared types ✅
- Backend DTOs implement interfaces ✅
- TD-004 marked resolved ✅
Status: Phase 5f COMPLETE ✅
8g. Phase 5g: Structured Logging (Week 21.5) ✅¶
8g.1 Objectives¶
- ✅ Resolve technical debt TD-005 (Console Logging in Production)
- ✅ Replace console.log with structured NestJS Logger
- ✅ Add ESLint rule to prevent future console usage
8g.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5g.1 Backend Logging | Replace console with NestJS Logger | 2 hours | ✅ |
| F5g.2 Frontend Dev Logger | Create dev-only logger utility | 2 hours | ✅ |
| F5g.3 ESLint Rule | Add no-console rule with exceptions | 1 hour | ✅ |
| F5g.4 Documentation | Create logging guidelines document | 1 hour | ✅ |
8g.3 Exit Criteria¶
- No console.log in production code ✅
- ESLint rule enforced ✅
- Logging guidelines documented ✅
- TD-005 marked resolved ✅
Status: Phase 5g COMPLETE ✅
8h. Phase 5h: Controller Tests (Week 22) ✅¶
8h.1 Objectives¶
- ✅ Resolve technical debt TD-006 (Missing Controller Tests)
- ✅ Add unit tests for all 10 backend controllers
- ✅ Test request validation, guards, and error handling
8h.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5h.1 Test Infrastructure | Controller test utilities | 2 hours | ✅ |
| F5h.2 Orders Controller | Tests for orders endpoints | 3 hours | ✅ |
| F5h.3 Print Jobs Controller | Tests for print job endpoints | 3 hours | ✅ |
| F5h.4 Webhook Controllers | Tests for Shopify/SimplyPrint webhooks | 3 hours | ✅ |
| F5h.5 Remaining Controllers | Product mappings, health, logs, shipments | 4 hours | ✅ |
8h.3 Exit Criteria¶
- All 10 controllers have tests ✅
- API key guards verified ✅
- Request validation tested ✅
- TD-006 marked resolved ✅
Status: Phase 5h COMPLETE ✅
8i. Phase 5i: Domain Contract Cleanup (Week 22.5) ✅¶
8i.1 Objectives¶
- ✅ Resolve technical debt TD-007 (Incomplete Domain Contract Usage)
- ✅ Remove Prisma type leakage from domain layer
- ✅ Create clean domain entity interfaces
8i.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5i.1 Domain Enums | Create domain-layer enums mirroring Prisma | 2 hours | ✅ |
| F5i.2 Domain Entities | Create typed entity interfaces | 3 hours | ✅ |
| F5i.3 Type Converters | Prisma-to-Domain conversion functions | 2 hours | ✅ |
| F5i.4 Service Updates | Update services to use domain types | 4 hours | ✅ |
8i.3 Exit Criteria¶
- No Prisma imports in libs/domain ✅
- Domain entities defined ✅
- Converters at repository boundary ✅
- TD-007 marked resolved ✅
Status: Phase 5i COMPLETE ✅
8j. Phase 5j: Typed Error Hierarchy (Week 23) ✅¶
8j.1 Objectives¶
- ✅ Resolve technical debt TD-008 (Missing Error Type Definitions)
- ✅ Create typed error classes with HTTP status codes
- ✅ Implement global exception filter
8j.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5j.1 Base Error Class | DomainError with code and httpStatus | 2 hours | ✅ |
| F5j.2 Domain Errors | Order, PrintJob, ProductMapping, Shipment errors | 3 hours | ✅ |
| F5j.3 Error Filter | Global exception filter for consistent responses | 2 hours | ✅ |
| F5j.4 Service Updates | Replace throw new Error with typed errors | 4 hours | ✅ |
8j.3 Exit Criteria¶
- Error hierarchy created ✅
- Consistent error response format ✅
- Services use typed errors ✅
- TD-008 marked resolved ✅
Status: Phase 5j COMPLETE ✅
8k. Phase 5k: Configuration Externalization (Week 23.5) ✅¶
8k.1 Objectives¶
- ✅ Resolve technical debt TD-009 (Hardcoded Configuration Values)
- ✅ Externalize all configuration to environment variables
- ✅ Validate configuration at startup
8k.2 Features¶
| Feature | Description | Effort | Status |
|---|---|---|---|
| F5k.1 Config Schema | class-validator schema for env vars | 2 hours | ✅ |
| F5k.2 Config Service | Typed AppConfigService | 2 hours | ✅ |
| F5k.3 Service Updates | Inject config instead of hardcoded values | 3 hours | ✅ |
| F5k.4 Documentation | Create .env.example with all variables | 1 hour | ✅ |
8k.3 Exit Criteria¶
- All config in environment variables ✅
- Validation at startup ✅
- .env.example documented ✅
- TD-009 marked resolved ✅
Status: Phase 5k COMPLETE ✅
9. Phase 6: Hardening (Weeks 24-26)¶
9.1 Objectives¶
- Production-ready reliability
- Performance optimization
- Documentation completion
9.2 Features¶
F6.1: Comprehensive Testing¶
| Attribute | Value |
|---|---|
| ID | F6.1 |
| Title | Test Suite Completion |
| Description | Achieve target test coverage and E2E tests |
| Effort | 16 hours |
| Dependencies | All previous features |
Tasks:
- Achieve 80%+ unit test coverage
- Integration tests for all API integrations
- E2E tests for critical paths:
- Order → Print Job → Fulfillment
- Cancellation flow
- Error recovery flow
- Performance tests
- Load tests (500 orders/day)
Deliverables:
- Test coverage report > 80%
- All integration tests passing
- Load test results documented
F6.2: Monitoring and Alerting¶
| Attribute | Value |
|---|---|
| ID | F6.2 |
| Title | Production Monitoring Setup |
| Description | Configure monitoring, alerting, and health checks |
| Effort | 8 hours |
| Dependencies | F0.4 |
Tasks:
- Configure Statping-ng health checks
- Set up error alerting (email/Slack)
- Configure performance metrics
- Create runbook for common issues
- Set up log aggregation
Health Endpoints:
| Endpoint | API | Web | Description |
|---|---|---|---|
/health |
✅ | ✅ | Full health status with build info |
/health/live |
✅ | ✅ | Simple liveness probe |
/health/ready |
✅ | - | Readiness probe (checks database) |
Health Checks:
- Database connectivity
- Shopify API connectivity
- SimplyPrint API connectivity
- Sendcloud API connectivity
Deliverables:
- Health endpoints operational with build info
- Alerts configured
- Monitoring dashboard
F6.3: Documentation¶
| Attribute | Value |
|---|---|
| ID | F6.3 |
| Title | Technical Documentation |
| Description | Complete system documentation |
| Effort | 12 hours |
| Dependencies | All previous features |
Documents:
- README with setup instructions
- API documentation (OpenAPI/Swagger) — ✅ Completed in Phase 1
- Architecture documentation — ✅ Completed in Phase 1
- Architecture Decision Records (13 ADRs) at
docs/architecture/ADR.md - C4 model diagrams (PlantUML) at
docs/architecture/ - Runbook for operations
- Troubleshooting guide
- Environment setup guide
Note: OpenAPI/Swagger documentation and Architecture Decision Records were implemented early in Phase 1 to facilitate API development and document key decisions.
Deliverables:
- All documentation complete
- ✅ API docs generated (Phase 1)
- ✅ Architecture documentation (Phase 1)
- Runbook validated
F6.4: Security Hardening¶
| Attribute | Value |
|---|---|
| ID | F6.4 |
| Title | Security Review and Hardening |
| Description | Security audit and improvements |
| Effort | 8 hours |
| Dependencies | All previous features |
Tasks:
- Dependency vulnerability scan
- HMAC verification audit
- Authentication review
- Data encryption verification
- Rate limiting implementation
- Security headers configuration
Deliverables:
- Security scan clean
- All endpoints secured
- Rate limiting active
9.3 Phase 6 Exit Criteria¶
- Test coverage > 80% ✅
- Load testing infrastructure created ✅
- Monitoring operational ✅
- Documentation complete ✅
- Security review passed ✅
Status: Phase 6 COMPLETE ✅
10. Phase 7: Progressive Web App (Week 26)¶
10.1 Objectives¶
- Enable installable app experience on desktop and mobile
- Implement push notifications for real-time print job alerts
- Add offline support for viewing cached order data
- Eliminate need for separate Tauri (desktop) and Capacitor (mobile) apps
10.2 Background¶
Per ADR-035, PWA was adopted to replace the originally planned native shell applications. See the PWA Feasibility Study for detailed research.
Key Decision Drivers:
- Admin dashboard is an ideal PWA use case (data-driven, no deep device integration)
- iOS PWA support matured significantly (push notifications on iOS 16.4+)
- Estimated 80-150 hours saved vs Tauri + Capacitor development
- Single codebase, instant updates, no app store management
10.3 Features¶
F7.1: PWA Foundation¶
| Attribute | Value |
|---|---|
| ID | F7.1 |
| Title | Vite PWA Plugin Integration |
| Description | Add PWA capabilities to existing React web application |
| Effort | 4 hours |
| Dependencies | Phase 6 complete |
Tasks:
- Install
vite-plugin-pwaand configure invite.config.ts - Create
manifest.jsonwith app metadata - Generate PWA icons (192x192, 512x512) from Forma3D logo
- Configure service worker for asset caching
- Add install prompt component
- Test installation on Chrome, Safari, Edge
Web App Manifest:
{
"name": "Forma3D.Connect",
"short_name": "Forma3D",
"description": "3D Print Order Management Dashboard",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#0066cc",
"orientation": "any",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
Deliverables:
- ✅ PWA installable from browser
- ✅ App appears in OS app launcher after install
- ✅ Works offline for cached pages
F7.2: Push Notifications¶
| Attribute | Value |
|---|---|
| ID | F7.2 |
| Title | Web Push API Integration |
| Description | Real-time push notifications for print job status |
| Effort | 8 hours |
| Dependencies | F7.1 |
Tasks:
- Generate VAPID keys for Web Push
- Create push notification service in NestJS API
- Add push subscription endpoint (
POST /api/v1/push/subscribe) - Integrate with existing notification service (email → push)
- Implement notification permission flow in dashboard
- Create notification settings UI in
/settings - Test on Android Chrome and iOS Safari (Home Screen installed)
Push Notification Events:
| Event | Notification |
|---|---|
| Print job completed | "Order #1234: All print jobs completed" |
| Print job failed | "Order #1234: Print job failed - attention required" |
| Order ready to ship | "Order #1234: Ready for shipping label" |
| System error | "System alert: [error summary]" |
iOS Considerations:
- Push notifications require Home Screen install
- User gesture required for permission request
- Use Declarative Web Push for reliability (iOS 18.4+)
Deliverables:
- ✅ Push notifications working on desktop browsers
- ✅ Push notifications working on Android
- ✅ Push notifications working on iOS (Home Screen install)
- ✅ User can enable/disable push in settings
F7.3: Offline Support¶
| Attribute | Value |
|---|---|
| ID | F7.3 |
| Title | Offline Data Caching |
| Description | View recent orders and status when offline |
| Effort | 6 hours |
| Dependencies | F7.1 |
Tasks:
- Configure Workbox for runtime caching
- Implement IndexedDB storage for order data
- Add offline indicator component
- Cache API responses with stale-while-revalidate strategy
- Queue actions (retry, cancel) when offline
- Sync queued actions when online
- Test offline scenarios
Caching Strategy:
| Resource | Strategy | TTL |
|---|---|---|
| Static assets (JS, CSS) | Cache-first | Indefinite |
| Images, fonts | Cache-first | 30 days |
| API: Orders list | Stale-while-revalidate | 5 minutes |
| API: Order detail | Stale-while-revalidate | 5 minutes |
| API: Health | Network-only | - |
Deliverables:
- ✅ Dashboard loads when offline (cached pages)
- ✅ Offline indicator visible when disconnected
- ✅ Queued actions sync on reconnect
F7.4: App-like Experience¶
| Attribute | Value |
|---|---|
| ID | F7.4 |
| Title | Native-like UX Enhancements |
| Description | Polish the installed app experience |
| Effort | 4 hours |
| Dependencies | F7.1 |
Tasks:
- Add splash screen configuration
- Configure status bar color for iOS/Android
- Add badge count for unread notifications
- Implement pull-to-refresh on mobile
- Add "Add to Home Screen" prompt for iOS users
- Test on various device sizes
Deliverables:
- ✅ Branded splash screen on app launch
- ✅ Badge count on app icon
- ✅ Mobile-friendly interactions
10.4 Phase 7 Exit Criteria¶
- PWA installable on Chrome, Safari, Edge
- Push notifications working on all platforms
- Offline mode shows cached data
- App icon badge shows notification count
- Documentation updated with PWA install instructions
Status: Phase 7 COMPLETE ✅
Phase 7 Implementation Notes (Completed 2026-01-19):
| Component | Path | Description |
|---|---|---|
| Vite PWA Config | apps/web/vite.config.mts |
VitePWA plugin with manifest and workbox |
| PWA Install Hook | apps/web/src/hooks/use-pwa-install.ts |
React hook for install prompt handling |
| PWA Install Prompt | apps/web/src/pwa/install-prompt.tsx |
Install banner component |
| SW Update Prompt | apps/web/src/pwa/sw-update-prompt.tsx |
Service worker update notification |
| Offline Indicator | apps/web/src/pwa/offline-indicator.tsx |
Offline status display |
| iOS Install Guide | apps/web/src/pwa/ios-install-guide.tsx |
iOS-specific installation instructions |
| Pull to Refresh | apps/web/src/pwa/pull-to-refresh.tsx |
Mobile pull-to-refresh gesture |
| IndexedDB Wrapper | apps/web/src/lib/indexed-db.ts |
Offline data storage |
| Online Status Hook | apps/web/src/hooks/use-online-status.ts |
Online/offline detection |
| Push Hook | apps/web/src/hooks/use-push-notifications.ts |
Push subscription management |
| Push Permission UI | apps/web/src/pwa/push-permission.tsx |
Push notification settings |
| Push Module | apps/api/src/push-notifications/push.module.ts |
NestJS push notifications module |
| Push Service | apps/api/src/push-notifications/push.service.ts |
Web Push API integration |
| Push Controller | apps/api/src/push-notifications/push.controller.ts |
Push subscription endpoints |
| Push Repository | apps/api/src/push-notifications/push.repository.ts |
Push subscription persistence |
| Push Schema | prisma/schema.prisma |
PushSubscription model |
| Push Migration | prisma/migrations/20260119000000_add_push_subscriptions/ |
Database migration |
| Load Tests | load-tests/k6/scenarios/pwa-endpoints.js |
K6 load tests for push endpoints |
Environment Variables Required for Push Notifications:
| Variable | Description |
|---|---|
VAPID_PUBLIC_KEY |
VAPID public key for Web Push (not secret) |
VAPID_PRIVATE_KEY |
VAPID private key for Web Push (secret) |
VAPID_SUBJECT |
Contact email in mailto: format (e.g., mailto:jan.wielemans@devgem.be) |
Generating VAPID Keys (one-time setup):
# Generate keys using web-push CLI
npx web-push generate-vapid-keys --json
This outputs JSON with publicKey and privateKey. Add these to:
1. Local .env file for development
2. Azure DevOps forma3d-staging variable group for staging
3. Production environment when ready
Important: Use the same VAPID keys across all environments. If you regenerate keys, all existing push subscriptions become invalid.
Phase 6 Implementation Notes (Completed 2026-01-18):
| Component | Path | Description |
|---|---|---|
| Health Indicators | apps/api/src/health/indicators/ |
Shopify, SimplyPrint, Sendcloud health checks |
| Dependencies Endpoint | apps/api/src/health/health.controller.ts |
/health/dependencies endpoint |
| Security Headers | apps/api/src/main.ts |
Helmet middleware with CSP, HSTS |
| Integration Tests | apps/api/test/integration/ |
Order flow, cancellation, error recovery |
| Load Tests | load-tests/k6/ |
K6 scenarios for order throughput and dashboard |
| Load Test Pipeline | azure-pipelines.yml |
Optional load test stage with test seeding |
| Operations Runbook | docs/04-development/runbook.md |
Incident response and maintenance procedures |
| Keys Inventory | docs/04-development/keys-certificates-inventory.md |
All credentials and renewal procedures |
| Environment Setup | docs/04-development/environment-setup.md |
Developer onboarding guide |
| Troubleshooting | docs/04-development/troubleshooting.md |
Common issues and resolutions |
| Alerting Rules | deployment/monitoring/alerting-rules.yml |
Monitoring alert definitions |
| Security Checklist | docs/04-development/security-audit-checklist.md |
Aikido verification and audit checklist |
Deliverables:
- ✅ Health indicators for all external services
- ✅ Helmet security headers (CSP, HSTS, XSS protection)
- ✅ Integration tests for critical flows
- ✅ K6 load testing infrastructure with pipeline integration
- ✅ Operations runbook with incident response
- ✅ Comprehensive documentation suite
- ✅ Security audit checklist for Aikido integration
- ✅ Alerting rules configuration
10. Feature Dependency Graph¶
Legend: - F1b.1 = Backend Observability (Sentry + OTEL) - F1b.2 = Frontend Observability (Sentry React) - F1b.3 = Structured Logging (Pino) - F1b.4 = Observability Library (libs/observability) - F1c.1 = Docker Image Build - F1c.2 = Container Registry Push - F1c.3 = Staging Deployment - F1c.4 = Traefik Configuration - F1d.1 = Acceptance Test Project (Playwright + Gherkin) - F1d.2 = Gherkin Feature Files - F1d.3 = Playwright Step Definitions - F1d.4 = Pipeline Integration - F5b.1 = Correlation ID Infrastructure - F5b.2 = Domain Contracts Library - F5b.3 = Repository Encapsulation - F5b.4 = Service Refactoring - F5c.1 = Database-backed Webhook Idempotency - F5c.2 = Cleanup Scheduled Job - F5d.1 = Vitest Configuration - F5d.2 = MSW API Mocking - F5d.3 = Hook and Context Tests - F5d.4 = UI Component Tests
11. Risk Mitigation¶
11.1 Technical Risks¶
| Risk | Mitigation |
|---|---|
| SimplyPrint API limitations | Early API research in Phase 2; fallback to polling |
| Shopify API rate limits | Request queuing, batch operations |
| Webhook delivery failures | Idempotency, polling fallback |
| Database performance | Indexing, query optimization |
11.2 Schedule Risks¶
| Risk | Mitigation |
|---|---|
| API integration complexity | Buffer time in estimates; spike early |
| Unclear requirements | Regular stakeholder reviews |
| Scope creep | Strict MVP scope; defer non-essentials |
12. Success Metrics¶
12.1 MVP Success (End of Phase 3)¶
| Metric | Target |
|---|---|
| Order-to-print automation | 95% |
| Print-to-fulfillment automation | 95% |
| Processing latency | < 2 minutes |
| System uptime | 99% |
12.2 Full Release Success (End of Phase 6)¶
| Metric | Target |
|---|---|
| Automation success rate | 99% |
| Daily order capacity | 1,000+ |
| Dashboard usability | Positive feedback |
| Test coverage | > 80% |
13. Resource Requirements¶
13.1 Development Team¶
- 1 Full-stack Developer (primary)
- 1 Part-time QA / DevOps support
13.2 Infrastructure¶
- Development environment (local)
- Staging environment (cloud VPS)
- Production environment (cloud VPS)
- PostgreSQL database (managed)
- Domain and SSL certificates
13.3 External Accounts¶
- Shopify Partner/Custom App access
- SimplyPrint API access
- Sendcloud API access
- GitHub repository
- CI/CD (GitHub Actions)
14. Timeline Summary¶
| Phase | Duration | Cumulative | Key Deliverable | Status |
|---|---|---|---|---|
| Phase 0: Foundation | 2 weeks | Week 2 | Project infrastructure | ✅ |
| Phase 1: Shopify Inbound | 3 weeks | Week 5 | Order reception | ✅ |
| Phase 1b: Observability | 1 week | Week 6 | Sentry + OpenTelemetry | ✅ |
| Phase 1c: Staging Deployment | 1 week | Week 7 | Automated deployment | ✅ |
| Phase 1d: Acceptance Testing | 0.5 weeks | Week 7.5 | Post-deploy testing | ✅ |
| Phase 2: SimplyPrint Core | 3 weeks | Week 10.5 | Print job automation | ✅ |
| Phase 3: Fulfillment Loop | 2 weeks | Week 12.5 | MVP Complete | ✅ |
| Phase 4: Dashboard MVP | 3 weeks | Week 15.5 | Admin interface | ✅ |
| Phase 5: Shipping | 2 weeks | Week 17.5 | Label automation | ✅ |
| Phase 5b: Domain Boundaries | 1 week | Week 18.5 | Microservices prep | ✅ |
| Phase 5c: Webhook Idempotency | 0.5 weeks | Week 19 | Tech debt TD-001 | ✅ |
| Phase 5d: Frontend Tests | 1 week | Week 20 | Tech debt TD-002 | ✅ |
| Phase 5e: JSON Schemas | 0.5 weeks | Week 20.5 | Tech debt TD-003 | ✅ |
| Phase 5f: Shared Types | 0.5 weeks | Week 21 | Tech debt TD-004 | ✅ |
| Phase 5g: Structured Logging | 0.5 weeks | Week 21.5 | Tech debt TD-005 | ✅ |
| Phase 5h: Controller Tests | 0.5 weeks | Week 22 | Tech debt TD-006 | ✅ |
| Phase 5i: Domain Contracts | 0.5 weeks | Week 22.5 | Tech debt TD-007 | ✅ |
| Phase 5j: Error Types | 0.5 weeks | Week 23 | Tech debt TD-008 | ✅ |
| Phase 5k: Configuration | 0.5 weeks | Week 23.5 | Tech debt TD-009 | ✅ |
| Phase 6: Hardening | 2 weeks | Week 25.5 | Production Ready | ✅ |
| Phase 7: PWA | 1 week | Week 26.5 | Cross-Platform Access | ✅ |
15. Approval¶
| Role | Name | Date |
|---|---|---|
| Project Sponsor | ||
| Technical Lead |
Revision History¶
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0 | 2026-01-09 | AI Assistant | Initial draft |
| 1.1 | 2026-01-10 | AI Assistant | Marked Phase 0 & 1 as complete, added F1.0 |
| 1.2 | 2026-01-10 | AI Assistant | Added F1.0b Aikido Security Platform integration |
| 1.3 | 2026-01-10 | AI Assistant | Added Phase 1b Sentry Observability (F1b.1-F1b.4) |
| 1.4 | 2026-01-10 | AI Assistant | Marked Phase 1b as complete with all features |
| 1.5 | 2026-01-10 | AI Assistant | Added Phase 1c Staging Deployment (F1c.1-F1c.4) |
| 1.6 | 2026-01-12 | AI Assistant | Marked Phase 1c as complete with all features |
| 1.7 | 2026-01-12 | AI Assistant | Added Phase 1d Acceptance Testing (F1d.1-F1d.4) |
| 1.8 | 2026-01-14 | AI Assistant | Marked Phase 2 & 3 complete — MVP Achieved! 🎯 |
| 1.9 | 2026-01-14 | AI Assistant | Marked Phase 4 complete — Dashboard MVP delivered! 🖥️ |
| 2.0 | 2026-01-16 | AI Assistant | Marked Phase 1d complete — All phases 0-4 now complete ✅ |
| 2.1 | 2026-01-16 | AI Assistant | Marked Phase 5 complete — Sendcloud shipping integration 📦 |
| 2.2 | 2026-01-17 | AI Assistant | Marked Phase 5b complete — Domain boundary separation for microservices prep 🏗️ |
| 2.3 | 2026-01-17 | AI Assistant | Added Phase 5c (Webhook Idempotency) — Tech debt TD-001 resolved 🔧 |
| 2.4 | 2026-01-17 | AI Assistant | Added Phase 5d (Frontend Tests) — Tech debt TD-002 resolved with 200 tests 🧪 |
| 2.5 | 2026-01-17 | AI Assistant | Added Phases 5e-5k (Tech Debt TD-003 to TD-009) — High priority debt roadmap 📋 |
| 2.6 | 2026-01-18 | AI Assistant | Marked Phase 6 complete — Production hardening with testing, monitoring, docs, security 🔒 |
| 2.7 | 2026-01-19 | AI Assistant | Added Phase 7: PWA for cross-platform mobile/desktop access (ADR-035) 📱 |
| 2.8 | 2026-01-19 | AI Assistant | Marked all tech debt phases (5e-5k) as complete — TD-003 to TD-009 resolved ✅ |
| 2.9 | 2026-01-19 | AI Assistant | Implemented Phase 7: PWA — Full PWA support with push notifications, offline mode, and app-like experience 📱 |