Spikard
A Rust-centric multi-language toolkit for building and validating typed web services. Generate type-safe API handlers from OpenAPI, GraphQL, gRPC/Protobuf, AsyncAPI, or JSON-RPC specifications and deploy to Python, TypeScript, Ruby, PHP, or WebAssembly.
Features
- Multi-Language Code Generation: Generate type-safe handlers from OpenAPI 3.0.x, GraphQL SDL, gRPC/Protobuf, AsyncAPI 2.x, or OpenRPC 1.x specifications
-
Project Scaffolding:
spikard initbootstraps production-ready projects with language-specific tooling - Automatic Quality Validation: Syntax, type checking, and linting automatically applied to generated code
- Zero-Copy Bindings: Performance-optimized FFI layers (PyO3, napi-rs, magnus, ext-php-rs, wasm-bindgen)
- Tower-HTTP Runtime: Complete HTTP/gRPC server with compression, rate limiting, authentication, and CORS
- Fixture-Driven Testing: Comprehensive test coverage with JSON-based fixtures
Supported Languages
| Language | Version | Package Manager |
|---|---|---|
| Python | 3.10+ | pip / uv |
| TypeScript | 5.x | npm / pnpm / yarn |
| Ruby | 3.2+ | bundler |
| PHP | 8.2+ | Composer |
| Rust | 2024 | cargo |
| WebAssembly | Latest | wasm-pack |
Quick Start
Installation
cargo install spikard-cliCreate a New Project
spikard init --name my_api --language python
cd my_api
uv sync
python -m my_api.appGenerate Handlers from Specification
# From OpenAPI
spikard codegen --spec openapi.json --language python --output ./generated
# From GraphQL schema
spikard codegen --spec schema.graphql --language typescript --output ./src/generated
# From Protobuf schema
spikard codegen --spec user_service.proto --language python --output ./generatedSee Init Command Guide for detailed options.
Code Examples
Generated handler patterns vary by language. See examples/ for complete runnable projects.
Python:
from spikard import Handler, Request, Response
@Handler("/users/{id}")
async def get_user(request: Request) -> Response:
user_id = request.path_params["id"]
return Response({"id": user_id, "name": "Alice"})TypeScript:
import { Handler, Request, Response } from "spikard";
export const getUser: Handler = async (request) => {
const user = { id: request.params.id, name: "Alice" };
return new Response(user);
};Ruby:
class GetUserHandler
def call(request)
{ id: request.path_params["id"], name: "Alice" }
end
endPHP:
class Handlers {
public function getUser(Request $request): Response {
return new Response(["id" => $request->pathParams["id"], "name" => "Alice"]);
}
}Code Generation Support
Spikard generates type-safe handlers from multiple API specifications:
| Format | Support | Languages |
|---|---|---|
| OpenAPI 3.0.x | ✅ | Python, TypeScript, Ruby, PHP |
| GraphQL SDL | ✅ | Python, TypeScript, Ruby, PHP, Rust |
| gRPC/Protobuf | ✅ | Python, TypeScript, Ruby, PHP, Rust |
| AsyncAPI 2.x | ✅ | Python, TypeScript, Ruby, PHP |
| OpenRPC 1.x | ✅ | Python, TypeScript, Ruby, PHP |
All generated code is automatically validated for syntax, types, and style before output.
Development
Install dependencies and build all language bindings:
task setup # Install all dependencies
task build # Build all language bindings
task test # Run all tests
task lint # Check code quality
task format # Apply formattingLanguage-specific commands:
task build:python # Build Python bindings
task build:node # Build Node.js bindings
task build:ruby # Build Ruby bindings
task build:php # Build PHP bindings
task test:rust # Run Rust tests
task test:python # Run Python tests
task test:js # Run TypeScript testsDocumentation
- Getting Started - Project bootstrapping and quick start
- gRPC/Protobuf Guide - Complete gRPC implementation guide
- Code Generation Guide - OpenAPI, GraphQL, Protobuf code generation
- Testing Guide - Testing patterns across all languages
- Architecture Decision Records - Design decisions and trade-offs
- Language-Specific Guides - Implementation patterns and best practices
- See examples/ for runnable sample projects in all languages
Architecture Highlights
Thin Binding Pattern: All language bindings delegate heavy lifting to the Rust core. Bindings handle language-specific type conversions only; no business logic duplication ensures consistency across platforms.
Zero-Copy Serialization: Direct PyO3 type construction eliminates JSON round-trips, providing 30-40% performance improvement in Python bindings.
Quality-First Generation: Automatic syntax, type, and style validation applied to all generated code. 95%+ test coverage on core generators.
Contributing
See CONTRIBUTING.md for guidelines. Code quality standards:
-
Rust:
clippy -D warnings, 95%+ coverage -
Python:
mypy --strict, 95%+ coverage - TypeScript: Strict mode, 80%+ coverage
- Ruby/PHP: 80%+ coverage
Pull request workflow: fork, create feature branch, run task lint and task test, update CHANGELOG.md, submit PR.
License
Licensed under the MIT License. See LICENSE file for details.