# profitble/auto architecture

> Architecture diagram of the GitHub repository profitble/auto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/profitble/auto
- Repository: https://github.com/profitble/auto

## Overview

##### File Structure
- Top-level files:
- README.md (project summary and usage)
- package.json, tsconfig.json (build/runtime config)
- src/ (code root)
- src/ contains:
- workflow.ts: central orchestrator that imports and chains node modules
- nodes/: each file is a self-contained “node” or step in the pipeline
- types.ts: shared type definitions
- There are no separate frontend/backend folders—this is purely a headless automation engine.

##### Extract Additional Architecture Insights
- README’s “Architecture” section confirms that each step is its own module and that workflow.ts wires them together.

##### Main Components
a. Trigger & Input Layer
- Webhook Trigger (receives data from Fillout/Tally)
b. Processing/Transformation Nodes
- Set Fields (field normalization & mapping)
- DocuSeal Contract (contract creation & signing link)
- Send Contract Email (email delivery)
- Wait for Signature (DocuSeal webhook handler)
- Notion Coaching Board (Notion API page & Kanban entry)
- Stripe Onboarding (Stripe Connect setup)
- Welcome Email (final onboarding email)
c. Orchestration Layer
- workflow.ts (imports nodes in sequence, handles errors, passes data context)
d. Shared Types
- types.ts (data contracts passed between nodes)
e. External Services
- Fillout/Tally form service
- DocuSeal API
- Email service (SMTP or SendGrid)
- Notion API
- Stripe API

##### Relationships and Interactions
- Data flow is strictly linear/sequential: Webhook → Set Fields → DocuSeal → Email → Wait → Notion → Stripe → Welcome.
- workflow.ts invokes each node, passing a context object that contains normalized fields and any tokens/IDs returned by external services.

##### Architectural Patterns & Principles
- Modular single-responsibility nodes (each TypeScript file in nodes/ focuses on one task)
- Orchestration via composition (workflow.ts assembles the pipeline)
- Strong typing and shared interfaces (types.ts)
- Event-driven trigger/input (webhook) and webhook-based callback (DocuSeal signature)

##### Relevant Technologies & Frameworks
- TypeScript (language)
- Node.js (runtime)
- npm scripts for dev tasks
- HTTP client libraries (e.g., axios or node-fetch) for API calls
- GitDiagram (for auto-visualizing import graph)

- Webhook → Fillout/Tally service
- DocuSeal Contract & Wait for Signature → DocuSeal API
- Send Contract Email & Welcome Email → Email service
- Notion Coaching Board → Notion API
- Stripe Onboarding → Stripe API

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Trigger & Input Layer"
        WT["Node: Webhook Trigger"]:::trigger
    end
    click WT "https://github.com/profitble/auto/blob/main/src/nodes/webhook-trigger.ts"

    WF["Orchestrator: workflow.ts"]:::orchestration
    click WF "https://github.com/profitble/auto/blob/main/src/workflow.ts"

    SF["Node: Set Fields"]:::process
    click SF "https://github.com/profitble/auto/blob/main/src/nodes/set-fields.ts"

    DC["Node: DocuSeal Contract"]:::process
    click DC "https://github.com/profitble/auto/blob/main/src/nodes/docuseal-contract.ts"

    SC["Node: Send Contract Email"]:::process
    click SC "https://github.com/profitble/auto/blob/main/src/nodes/send-contract-email.ts"

    WS["Node: Wait for Signature"]:::process
    click WS "https://github.com/profitble/auto/blob/main/src/nodes/wait-for-signature.ts"

    NB["Node: Notion Coaching Board"]:::process
    click NB "https://github.com/profitble/auto/blob/main/src/nodes/notion-coaching-board.ts"

    SO["Node: Stripe Onboarding"]:::process
    click SO "https://github.com/profitble/auto/blob/main/src/nodes/stripe-onboarding.ts"

    WE["Node: Welcome Email"]:::process
    click WE "https://github.com/profitble/auto/blob/main/src/nodes/welcome-email.ts"

    subgraph "Shared Types"
        ST["Types: data contracts"]:::types
    end
    click ST "https://github.com/profitble/auto/blob/main/src/types.ts"

    WT -->|"Invoke"| WF
    WF -->|"calls"| SF
    SF -->|"calls"| DC
    DC -->|"calls"| SC
    SC -->|"calls"| WS
    WS -->|"calls"| NB
    NB -->|"calls"| SO
    SO -->|"calls"| WE

    ST --> SF
    ST --> DC
    ST --> SC
    ST --> WS
    ST --> NB
    ST --> SO
    ST --> WE

    ex1["Fillout/Tally Form Service"]:::external
    WT -->|"receives webhook"| ex1

    ex2["DocuSeal API"]:::external
    DC ---->|"POST /contracts"| ex2
    WS ---->|"webhook callback"| ex2

    ex3["Email Service"]:::external
    SC ---->|"send email"| ex3
    WE ---->|"send email"| ex3

    ex4["Notion API"]:::external
    NB ---->|"create page"| ex4

    ex5["Stripe API"]:::external
    SO ---->|"setup connect"| ex5

    classDef trigger fill:#c6f5c6,stroke:#333,stroke-width:1px
    classDef orchestration fill:#e7e7e7,stroke:#333,stroke-width:1px
    classDef process fill:#c6dafc,stroke:#333,stroke-width:1px
    classDef external fill:#f9d5e5,stroke:#333,stroke-width:1px,stroke-dasharray:5 5
    classDef types fill:#ffe4b5,stroke:#333,stroke-width:1px,stroke-dasharray:2 2
```
