| name | documenso-reference-architecture |
| description | 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".
|
| allowed-tools | Read, Grep |
| version | 1.13.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","documenso","documenso-reference"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
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