Album Workflow - State Machine
Overview
The Album Workflow is the core business logic of PhotoFlow, implementing a state machine that manages photo albums through their lifecycle—from initial creation to final delivery.
Album States
The album progresses through the following states:
State | Description | Entry Condition |
|---|---|---|
| Album created, waiting for raw photos | Album creation |
| Raw photos uploaded and synced | SyncRawTag trigger |
| Photos processed, ready for client rating | SyncStockTag trigger + Raw tag Ready |
| Client confirmed rating completion | Rate trigger |
| Photographer syncs rated photos | Rate trigger |
| Photos being retouched | ConfirmRate trigger |
| Client reviewing retouched photos | FinishRetouch trigger |
| Client requested changes | RequestRevision trigger |
| Client approved all photos | ConfirmFeedback trigger |
| Final state with approved photos | Finish trigger |
| Album archived/completed | Close trigger |
State Machine Diagram
Triggers
Trigger | Description | Who Can Execute |
|---|---|---|
| Upload/sync raw photos from Google Drive | Photographer |
| Process and prepare photos for rating | Photographer |
| Client confirms rating is complete | Anonymous |
| Sync rated photos to Google Drive | Photographer |
| Complete retouching, ready for feedback | Photographer |
| Client requests changes to photos | Anonymous |
| Client approves all photos | Anonymous |
| Finalize album with approved photos | Photographer |
| Archive/close album | Admin |
Album Tag Types
Each state corresponds to an Album Tag that holds the photos for that stage:
Tag Type | Description | Created During |
|---|---|---|
| Original raw photos | Init → Raw transition |
| Processed stock photos | Raw → Stock transition |
| Photos after client rating | Stock → Rate transition |
| Retouched photos | Rate → Retouch transition |
| Final approved photos | → Finish transition |
Album Tag Status
State Machine Implementation
The state machine is implemented using the Stateless library:
Transition Validation
Each transition validates the corresponding AlbumTag status:
Transition | Validation |
|---|---|
Raw → Stock | Raw tag status == Ready |
Stock → Rate | Stock tag status == Ready |
ConfirmRate → Retouch | Stock tag status == Ready |
Retouch → Feedback | Retouch tag status == Ready/WaitingToSync/WaitingInputUrl/SyncFailed |
Retouch → Finish | Retouch tag status == Ready |
ConfirmedFeedback → Finish | Retouch tag status == Ready |
Workflow Scenarios
Scenario 1: Normal Flow (No Revisions)
Scenario 2: With Revision Cycle
Scenario 3: Direct Finish from Retouch
SignalR Notifications
State transitions trigger SignalR notifications:
Event | Trigger | Payload |
|---|---|---|
| Any state transition | albumId, oldState, newState |
| New tag created | albumId, albumTagId, type |
| Tag status change | albumId, albumTagId, oldStatus, newStatus |
| During sync | albumId, processedCount, totalCount |
| Sync finished | albumId, totalCount |
API Endpoints
Get Available Transitions
Response:
Trigger State Change
Error Handling and Rollback
The system includes automatic rollback for failed transitions:
Related Documentation
Photo Synchronization
Client Feedback Portal
Authorization Policies