How smithy-lang/smithy-typescript works
Project Type and Purpose
• This is a monorepo for Smithy-TypeScript, a code-generation framework that reads Smithy models and emits TypeScript client and server SDKs.
• It has two halves:
• A Java/Gradle-based code generator (smithy-typescript-codegen plus plugins and integrations via SPI).
• A TypeScript/Yarn workspace of dozens of small, focused packages (core, middleware, util, protocol, handlers, etc.) that form the runtime libraries and generated SDKs.
Main Components
A. Java Code Generation Layer
• Smithy CLI / Gradle Plugin (invokes smithy build)
• smithy-typescript-codegen (Java code generators)
• TypeScriptIntegration implementations (in src/main/java/...)
• ProtocolGenerators (HTTP-binding, RPC)
• RuntimeClientPlugins (endpoint resolution, auth schemes)
• SPI registration files under META-INF/services
• Build artifacts produced under build/smithy/...
B. TypeScript Monorepo Workspace
• Root level: package.json, turbo.json, Yarn workspace config
• packages/ directory: ~100 packages (abort-controller, middleware-*, util-*, protocol-http, etc.)
• smithy-typescript-ssdk-libs/: server SDK support packages
• private/ & smithy-typescript-codegen-test: local models and test harness projects
• Build tooling: scripts/ (copy generated packages, test harness), Makefile, Gradle wrapper
C. CI/CD & Release Pipelines
• GitHub Actions workflows (.github/workflows/*.yml)
• Changesets for versioning in TS packages
• Gradle build & publish to Maven Local (Java)
• Yarn/turbo build, test, and publish to npm registry (TS)
Relationships & Data Flow
1. Smithy Model Input (user’s .smithy files)
↓
2. Smithy CLI/Gradle loads the Java plugin (smithy-typescript-codegen) via SPI
↓
3. Java Codegen
• Parses models → applies ProtocolGenerators & RuntimeClientPlugins → writes TypeScript sources under build/smithy/source/typescript-client-codegen (or server codegen projection)
↓
4. Copy Script (scripts/build-generated-test-packages.js)
• Stages generated TS packages into node_modules for integration
↓
5. TypeScript Workspace
• Yarn/turbo picks up all TS packages under packages/ and smithy-typescript-ssdk-libs/
• Builds each package (via tsc, Vitest/Jest)
• Runs integration tests against generated clients
↓
6. Publish
• Java artifacts to Maven Central or Maven Local
• TS packages to npm (or private registry) via GH Actions
Architectural Patterns & Principles
• Plugin & SPI in Java: loose coupling, custom ProtocolGenerators & integrations
• Monorepo with Yarn Workspaces + Turbo: single source, consistent tooling, fast builds
• Modular TS Packages: each small library has a single responsibility (e.g., compression, retry, signature)
• Middleware Stack pattern in generated clients: pluggable HTTP requests/response processing
Technologies & Frameworks
• Java/Gradle: Smithy CLI, codegen, SPI, Gradle Kotlin DSL
• TypeScript: Yarn workspaces, Turbo, Vitest/Jest, Changesets
• CI/CD: GitHub Actions, npm registry, Maven repositories