Healthcare Workflow System
Complete System Architecture & Data Flow Documentation
System Overview
SprkzDoc Healthcare Workflow System is a comprehensive platform for managing patient enrollment and document workflows in healthcare settings.
The system consists of multiple specialized applications working together to create seamless, role-based form completion workflows.
PDF Configuration & Field Management
Workflow Template Creation
Journey Instance Management
Notification & Magic Link System
Patients, Medical Staff, Providers
Core Backend Services
Complete System Flow
This diagram shows the complete end-to-end flow from PDF configuration to journey completion, including all system components and their interactions.
S3 + DynamoDB)] Sourdough1 --> JourneyMan subgraph JourneyMan["2️⃣ JourneyMan - Workflow Templates"] JM1[Select FormMan PDF] JM2[Define Workflow Steps] JM3[Configure Viewer Settings] JM4[Set Message Templates] JM5[Add Webhook Steps] JM1 --> JM2 --> JM3 --> JM4 --> JM5 end JourneyMan --> |Journey Template| Sourdough2[(Sourdough API
DynamoDB)] Sourdough2 --> JourneyGuideCreate subgraph JourneyGuideCreate["3️⃣ JourneyGuide - Create Instance"] JG1[Select Template] JG2[Enter Patient Details] JG3[Enter Participant Contact Info] JG4[Customize Workflow if needed] JG5[Create Journey Instance] JG1 --> JG2 --> JG3 --> JG4 --> JG5 end JourneyGuideCreate --> |Journey Instance| Sourdough3[(Sourdough API
DynamoDB)] Sourdough3 --> ActionsAPISend subgraph ActionsAPISend["4️⃣ Actions API - Send Notification"] A1[Generate 22-char nanoid] A2[Create Magic Link:
baseURL/nanoid] A3[Substitute Variables
in Message Template] A4[Send via Email/SMS/Fax] A5[Store Action Record] A1 --> A2 --> A3 --> A4 --> A5 end ActionsAPISend --> |Action Record| MySQL1[(MySQL
actions table)] ActionsAPISend --> |Email/SMS| Participant subgraph Participant["5️⃣ Participant Receives Message"] P1[📧 Email Notification] P2[📱 SMS Notification] P3[📠 Fax Notification] P4[Click Magic Link] P1 --> P4 P2 --> P4 P3 --> P4 end Participant --> |Click Link| ActionsAPITrack subgraph ActionsAPITrack["6️⃣ Actions API - Track Access"] AT1[Extract nanoid from URL] AT2[Query MySQL for Action] AT3[Validate Magic Link
not expired, status='sent'] AT4[Log Access
IP, User Agent, Timestamp] AT5[Get stepId & journeyId] AT1 --> AT2 --> AT3 --> AT4 --> AT5 end ActionsAPITrack --> |Access Log| MySQL2[(MySQL
magic_link_access)] ActionsAPITrack --> |stepId, journeyId| JourneyGuideViewer subgraph JourneyGuideViewer["7️⃣ JourneyGuide - Fastpass Viewer"] JGV1[Load Journey Context] JGV2[Determine Role
Patient/Med-Staff/Provider] JGV3[Apply Viewer Config] JGV4[Render PDF with
Role-Specific Fields] JGV5[Participant Completes Fields] JGV6[Upload Attachments if Required] JGV7[Validate Required Fields] JGV8[Submit Completion] JGV1 --> JGV2 --> JGV3 --> JGV4 --> JGV5 --> JGV6 --> JGV7 --> JGV8 end JourneyGuideViewer --> |Form Data + Attachments| Sourdough4[(Sourdough API
S3 + DynamoDB)] Sourdough4 --> NextStep subgraph NextStep["8️⃣ Next Step Triggered"] NS1[Mark Step as Completed] NS2[Update Journey Status] NS3{More Steps?} NS4[Get Next Step] NS5{Step Type?} NS6[User Step:
Trigger Next Participant] NS7[Webhook Step:
Execute HTTP Request] NS8[Mark Journey Complete] NS1 --> NS2 --> NS3 NS3 -->|Yes| NS4 --> NS5 NS5 -->|User| NS6 NS5 -->|Webhook| NS7 NS6 --> ActionsAPISend NS7 --> NS3 NS3 -->|No| NS8 end NS8 --> End([Journey Complete 🎉]) style FormMan fill:#667eea,stroke:#333,stroke-width:2px,color:#fff style JourneyMan fill:#f093fb,stroke:#333,stroke-width:2px,color:#fff style JourneyGuideCreate fill:#4facfe,stroke:#333,stroke-width:2px,color:#fff style ActionsAPISend fill:#43e97b,stroke:#333,stroke-width:2px,color:#fff style Participant fill:#fa709a,stroke:#333,stroke-width:2px,color:#fff style ActionsAPITrack fill:#30cfd0,stroke:#333,stroke-width:2px,color:#fff style JourneyGuideViewer fill:#ff9a9e,stroke:#333,stroke-width:2px,color:#fff style NextStep fill:#a8edea,stroke:#333,stroke-width:2px,color:#333
Simplified Flow (High-Level)
A condensed view of the workflow showing the main stages and decision points.
Configure PDF] --> B[JourneyMan
Create Template] B --> C[JourneyGuide
Launch Instance] C --> D[Actions API
Send Notification] D --> E[Participant
Receives Message] E --> F[Actions API
Track Click] F --> G[JourneyGuide
Complete Form] G --> H{More
Steps?} H -->|Yes| D H -->|No| I[Complete] style A fill:#667eea,stroke:#333,stroke-width:2px,color:#fff style B fill:#f093fb,stroke:#333,stroke-width:2px,color:#fff style C fill:#4facfe,stroke:#333,stroke-width:2px,color:#fff style D fill:#43e97b,stroke:#333,stroke-width:2px,color:#fff style E fill:#fa709a,stroke:#333,stroke-width:2px,color:#fff style F fill:#30cfd0,stroke:#333,stroke-width:2px,color:#fff style G fill:#ff9a9e,stroke:#333,stroke-width:2px,color:#fff style I fill:#98fb98,stroke:#333,stroke-width:2px,color:#333
Data Flow Architecture
System architecture showing frontend applications, backend services, data storage, and external integrations.
API Gateway + Lambda] Actions[Actions API
Bun + Elysia] end subgraph Storage["Data Storage"] S3[(S3
PDF Files)] DynamoDB[(DynamoDB
Journeys, Templates, Steps)] MySQL[(MySQL
Actions, Magic Links)] end subgraph External["External Services"] SES[Amazon SES
Email] Twilio[Twilio
SMS] Webhooks[External APIs
EMR, CRM, etc.] end FormMan --> Sourdough JourneyMan --> Sourdough JourneyGuide --> Sourdough JourneyGuide --> Actions Sourdough --> S3 Sourdough --> DynamoDB Actions --> MySQL Actions --> SES Actions --> Twilio Actions --> Webhooks DynamoDB -.->|Query| JourneyGuide MySQL -.->|Lookup| JourneyGuide style FormMan fill:#667eea,stroke:#333,stroke-width:2px,color:#fff style JourneyMan fill:#f093fb,stroke:#333,stroke-width:2px,color:#fff style JourneyGuide fill:#4facfe,stroke:#333,stroke-width:2px,color:#fff style Sourdough fill:#8B5CF6,stroke:#333,stroke-width:2px,color:#fff style Actions fill:#43e97b,stroke:#333,stroke-width:2px,color:#fff
Technology Stack
Frontend: React.js hosted on S3/CloudFront for global delivery
Backend: Sourdough API (Lambda/API Gateway) + Actions API (Bun/Elysia)
Storage: S3 (files), DynamoDB (NoSQL), MySQL (relational)
External: Amazon SES (email), Twilio (SMS), Webhook integrations
Sequence Diagram - Patient Enrollment Flow
Detailed sequence of interactions during a typical patient enrollment journey.
(aB3dEf9Gh2...) Actions->>Patient: 5. Send Email with Magic Link Patient->>Actions: 6. Click Magic Link Actions->>Actions: Validate & Log Access Actions->>Viewer: 7. Redirect with nanoid Viewer->>Actions: Lookup nanoid Actions-->>Viewer: Return stepId, journeyId Viewer->>DB: Load Journey Context DB-->>Viewer: Step Details, Role, Fields Patient->>Viewer: 8. Complete Form Fields Viewer->>DB: Submit Form Data DB->>JourneyGuide: Mark Step Complete JourneyGuide->>Actions: Trigger Step 2 (Med-Staff) Note over Actions,Patient: Cycle repeats for each role...
State Diagram - Journey Lifecycle
Journey state transitions from creation to completion or cancellation.
(Send First Notification) InProgress --> InProgress: Step Completed
(Trigger Next User Step) InProgress --> InProgress: Webhook Executed
(Continue to Next Step) InProgress --> Blocked: Error or Timeout Blocked --> InProgress: Manual Retry
or Issue Resolved Blocked --> Cancelled: Admin Cancellation InProgress --> Completed: All Steps Finished Cancelled --> [*] Completed --> [*] note right of InProgress Active journey cycling through: 1. Send notification 2. Participant completes 3. Trigger next step 4. Repeat until done end note
Component Interaction Matrix
Visual representation of how each component interacts with data stores.
Magic Link Flow Detail
In-depth look at how magic links are generated, stored, validated, and used to provide secure, one-time access to forms.
using nanoid library] B --> C[Build Magic Link
baseUrl + '/' + nanoid] C --> D[Store in actions table:
action_id = nanoid] D --> E[Substitute magicLink
in message template] E --> F[Send Email/SMS] F --> G[Participant Clicks Link] G --> H[Actions API /l/:actionId] H --> I{Valid?
Not expired?} I -->|No| J[Show Error Page] I -->|Yes| K[Log Access in
magic_link_access table] K --> L[Query actions table:
SELECT stepId, journeyId
WHERE action_id = nanoid] L --> M[Redirect to JourneyGuide
with context] M --> N[JourneyGuide Viewer] N --> O[Load Journey from DynamoDB] O --> P[Render Role-Specific Form] style B fill:#43e97b,color:#fff style C fill:#43e97b,color:#fff style F fill:#fa709a,color:#fff style K fill:#30cfd0,color:#fff style N fill:#ff9a9e,color:#fff
Magic Link Security Features
Unique IDs: 22-character nanoids provide collision-resistant unique identifiers
One-Time Use: Links can be configured for single-use or time-limited access
Tracking: All access attempts are logged with IP, timestamp, and user agent
Expiration: Links automatically expire after a configurable time period