How trpc/trpc-openapi works
Main Components
a. Core Components:
• tRPC Router Integration Layer
• OpenAPI Generator
• HTTP Adapters Layer
• Type System (Zod Integration)
b. Supported Framework Adapters:
• Express Adapter
• Next.js Adapter
• Fastify Adapter
• AWS Lambda Adapter
• Nuxt Adapter
• Node HTTP Adapter
• Standalone Adapter
┌─────────────────────────────────────────────────────┐
• Client Applications │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────┐
• Framework Layer │
• ┌─────┐ ┌────────┐ ┌───────┐ ┌──────────────┐ │
• Express│ │Next.js │ │Fastify│ │Other Adapters│ │
• ┘ └────────┘ └───────┘ └──────────────┘ │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────┐
• trpc-openapi Core Layer │
• ┌─────────────────┐ ┌────────────────────┐ │
• HTTP Handler │←────→│ OpenAPI Generator │ │
• ┘ └────────────────────┘ │
• ┌─────────────────┐ ┌────────────────────┐ │
• Request Parser │←────→│ Response Formatter │ │
• ┘ └────────────────────┘ │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────┐
• tRPC Layer │
• ┌─────────────┐ ┌──────────────┐ ┌──────────┐ │
• tRPC Router │←→│ Procedures │←→│ Context │ │
• ┘ └──────────────┘ └──────────┘ │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────┐
• Validation Layer (Zod) │
• ┘
Important Elements to Highlight
a. Request Flow:
• How requests flow from clients through the adapters
• Transformation from REST to tRPC procedures
• Demonstrate validation and context handling
b. OpenAPI Generation:
• Generation of OpenAPI documentation
• Metadata processing
• Schema generation from Zod types
c. Security Layer:
• Authentication/authorization handling
• How protected routes are managed
• Security scheme implementation
Additional Details
• Component types and their purposes
• Security flow indicators
Implementation Notes
• The pluggable nature of the framework adapters
• The transformation between REST and tRPC
• The OpenAPI document generation process
• Error handling and response formatting
• Type safety and validation
Key Relationships
Clear connections between:
• Framework adapters and the core handler
• OpenAPI generator and tRPC procedures
• Request/response transformation flow
• Security middleware integration
Remember to include version information (supporting tRPC v10) and note any deprecated or archived functionality as mentioned in the README.