agentsclimarketplace

Documenso reference architecture

Skill ComeOnOliver/skillshub/skills/jeremylongshore/claude-code-plugins-plus-skills/documenso-reference-architecture

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill documenso-reference-architecture

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Implement Documenso reference architecture with best-practice project layout. Use when designing new Documenso integrations, reviewing project structure, or establishing architecture standards for document signing applications. Trigger with phrases like "documenso architecture", "documenso best practices", "documenso project structure", "how to organize documenso".

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.7 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it

Documenso Reference Architecture

Overview

Production-ready architecture for Documenso document signing integrations. Covers project layout, layered service architecture, webhook processing, and data flow.

Prerequisites

  • Understanding of layered architecture principles
  • Documenso SDK knowledge (see documenso-sdk-patterns)
  • TypeScript project with Node.js 18+

Recommended Project Structure

my-signing-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ documenso/
β”‚   β”‚   β”œβ”€β”€ client.ts              # Singleton SDK client
β”‚   β”‚   β”œβ”€β”€ errors.ts              # Custom error classes
β”‚   β”‚   β”œβ”€β”€ retry.ts               # Retry/backoff logic
β”‚   β”‚   └── types.ts               # Shared types
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ document-service.ts    # Document CRUD operations
β”‚   β”‚   β”œβ”€β”€ template-service.ts    # Template-based workflows
β”‚   β”‚   └── signing-service.ts     # Orchestrates signing flows
β”‚   β”œβ”€β”€ webhooks/
β”‚   β”‚   β”œβ”€β”€ handler.ts             # Express webhook router
β”‚   β”‚   β”œβ”€β”€ verify.ts              # Secret verification
β”‚   β”‚   └── processors/
β”‚   β”‚       β”œβ”€β”€ document-completed.ts
β”‚   β”‚       β”œβ”€β”€ document-signed.ts
β”‚   β”‚       └── document-rejected.ts
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ health.ts              # Health check endpoint
β”‚   β”‚   └── routes.ts              # API routes
β”‚   └── config/
β”‚       └── index.ts               # Environment configuration
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ verify-connection.ts       # Quick health check
β”‚   β”œβ”€β”€ create-test-doc.ts         # Test document generator
β”‚   └── cleanup-test-docs.ts       # Test data cleanup
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/
β”‚   β”‚   └── document-service.test.ts
β”‚   β”œβ”€β”€ integration/
β”‚   β”‚   └── document-lifecycle.test.ts
β”‚   └── mocks/
β”‚       └── documenso.ts           # Mock client factory
β”œβ”€β”€ .env.development
β”œβ”€β”€ .env.production
β”œβ”€β”€ docker-compose.yml             # Self-hosted Documenso (dev)
└── package.json

Layer Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  API / Controllers                                       β”‚
β”‚  Routes, request validation, response formatting         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Service Layer                                           β”‚
β”‚  Business logic, orchestration, authorization            β”‚
β”‚  (document-service, template-service, signing-service)   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Documenso Client Layer                                  β”‚
β”‚  SDK wrapper, retry, error handling, caching             β”‚
β”‚  (client.ts, retry.ts, errors.ts)                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  External Services                                       β”‚
β”‚  Documenso API, S3/GCS storage, email, database         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Rules:

  • Controllers never call Documenso directly -- always go through services
  • Services never import @documenso/sdk-typescript directly -- use the client wrapper
  • Webhook processors are isolated -- one file per event type
  • Error handling happens at the client layer, not in controllers

Data Flow

User Request
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   POST /api/sign
β”‚   API    │──────────────────────────────┐
β”‚  Router  β”‚                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                              β–Ό
                                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                   β”‚   Signing    β”‚
                                   β”‚   Service    β”‚
                                   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                     β–Ό                     β–Ό
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚ Template β”‚         β”‚ Document β”‚          β”‚   Your   β”‚
             β”‚ Service  β”‚         β”‚ Service  β”‚          β”‚    DB    β”‚
             β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚                    β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Documenso   β”‚
                    β”‚  Client      │──→ Documenso API
                    β”‚  (singleton) β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Webhook Flow:
Documenso API ──POST──→ /webhooks/documenso
                             β”‚
                        β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
                        β”‚ Verify  │──→ Check X-Documenso-Secret
                        β”‚ Secret  β”‚
                        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                             β”‚
                        β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
                        β”‚ Router  │──→ Route by event type
                        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                             β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό              β–Ό              β–Ό
        completed.ts    signed.ts     rejected.ts
        (archive PDF)  (update DB)  (alert sender)

Setup Script

#!/bin/bash
set -euo pipefail

mkdir -p src/{documenso,services,webhooks/processors,api,config}
mkdir -p scripts tests/{unit,integration,mocks}

# Create .env.example
cat > .env.example << 'EOF'
DOCUMENSO_API_KEY=
DOCUMENSO_BASE_URL=https://app.documenso.com/api/v2
DOCUMENSO_WEBHOOK_SECRET=
LOG_LEVEL=info
NODE_ENV=development
EOF

echo "Project scaffolded. Copy .env.example to .env and fill in values."

Key Design Decisions

DecisionRationale
Singleton clientAvoids re-initialization overhead per request
Service layerSeparates business logic from API details
One processor per webhook eventIsolates side effects, easy to test
Mock client for testsFast unit tests without API calls
Template-first approachFewer API calls, consistent field placement

Error Handling

IssueCauseSolution
Circular dependenciesWrong layeringServices import client, never the reverse
Config not loadingWrong env fileVerify NODE_ENV matches config loader
Webhook processor crashUnhandled error in processorWrap each processor in try/catch
Test isolationShared client stateCall resetClient() in beforeEach

Resources

Next Steps

For multi-environment setup, see documenso-multi-env-setup.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,984. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.