Skip to content

Commit e62c294

Browse files
committed
Add CLAUDE.md
1 parent d928df3 commit e62c294

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
### Building and Testing
8+
- `./gradlew build` - Build all modules and run tests
9+
- `./gradlew test` - Run unit tests across all modules
10+
- `./gradlew check` - Run all verification tasks (tests, linting, spotbugs)
11+
- `./gradlew spotlessCheck` - Check code formatting
12+
- `./gradlew spotlessApply` - Apply code formatting fixes
13+
- `./gradlew spotbugsMain` - Run SpotBugs static analysis
14+
15+
### Module-Specific Commands
16+
- `./gradlew :module-name:test` - Run tests for a specific module (e.g., `:core:test`)
17+
- `./gradlew :module-name:build` - Build a specific module
18+
- `./gradlew :examples:end-to-end:smithyBuild` - Generate code for examples
19+
20+
### Code Generation
21+
- Code generation happens during the `smithyBuild` task
22+
- Generated code is placed in `build/smithy/` directories
23+
- Use `smithy-build.json` files to configure code generation
24+
25+
## Architecture Overview
26+
27+
### Core Framework Structure
28+
This is a **Smithy Interface Definition Language (IDL)** implementation for Java with a layered architecture:
29+
30+
1. **Schema System** (`core/`) - Runtime representation of Smithy models with precompiled validation
31+
2. **Code Generation** (`codegen/`) - Transforms Smithy models into Java client/server code
32+
3. **Protocol Layer** - Pluggable protocol implementations (REST JSON, RPC CBOR, AWS protocols)
33+
4. **Transport Layer** - HTTP and other transport implementations
34+
5. **Runtime Components** - Client/server frameworks that generated code depends on
35+
36+
### Key Architectural Patterns
37+
38+
**Plugin Architecture**: Uses Java ServiceLoader extensively for protocol, transport, and codec discovery via `META-INF/services/` files.
39+
40+
**Schema-Driven Runtime**: Smithy models compile to runtime `Schema` objects with precomputed validations for performance.
41+
42+
**Async-First Design**: All client operations return `CompletableFuture<T>`, servers use job-based orchestration.
43+
44+
**Layered Protocol Architecture**:
45+
```
46+
Generated Client/Server Code
47+
48+
Protocol Layer (REST JSON, RPC CBOR, etc.)
49+
50+
Transport Layer (HTTP, etc.)
51+
52+
Codec Layer (JSON, CBOR, XML)
53+
```
54+
55+
### Module Organization
56+
57+
**Core Modules**:
58+
- `core/` - Schema system, serialization, validation
59+
- `codegen/` - Code generation framework and plugins
60+
- `client/` - Client runtime framework with protocol/transport abstraction
61+
- `server/` - Server framework with orchestrator pattern and handler architecture
62+
63+
**Protocol Implementations**:
64+
- `client-rpcv2-cbor/` - Binary RPC protocol using CBOR serialization
65+
- `aws/client/` - AWS protocol implementations (REST JSON, REST XML, AWS JSON)
66+
- `codecs/` - Protocol-agnostic serialization (JSON, CBOR, XML)
67+
68+
**AWS Integration**:
69+
- `aws/` - AWS-specific protocols, SigV4 auth, SDK v2 compatibility
70+
- Service bundling tools for packaging AWS service models
71+
72+
**MCP Integration**:
73+
- `mcp/` - Model Context Protocol server implementation
74+
- Supports both direct handler and proxy modes
75+
76+
### Code Generation Flow
77+
78+
1. **Input**: Smithy model files (`.smithy`) and `smithy-build.json` configuration
79+
2. **Processing**: CodeGenerationContext coordinates JavaSymbolProvider and specialized generators
80+
3. **Output**: Generated Java classes in `build/smithy/` with runtime dependencies on core modules
81+
4. **Integration**: JavaCodegenIntegration plugins extend generation process
82+
83+
### Testing Framework
84+
85+
- Uses JUnit 5 platform across all modules
86+
- Protocol compliance testing via `protocol-test-harness`
87+
- Integration tests in `src/it/` directories
88+
- Examples serve as functional tests
89+
90+
## Development Guidelines
91+
92+
### Code Conventions
93+
- Java 17+ required (toolchain uses Java 21, compiles to Java 17)
94+
- Uses Spotless for formatting with Eclipse formatter
95+
- SpotBugs for static analysis with custom filter rules
96+
- License headers required on all files (auto-applied by Spotless)
97+
98+
### Module Structure
99+
- Standard Gradle multi-module project
100+
- Integration tests in `src/it/` directories
101+
- Test fixtures in `src/testFixtures/` where appropriate
102+
- Resources in `src/main/resources/META-INF/` for service discovery
103+
104+
### Git Hooks
105+
- Pre-push hooks automatically installed on Unix systems via `addGitHooks` task
106+
- Requires `smithy` CLI to be installed for hook execution
107+
108+
### Important Implementation Notes
109+
110+
**Service Discovery**: New protocol/transport implementations must register via ServiceLoader in `META-INF/services/` files.
111+
112+
**Schema Performance**: The schema system precomputes validation constraints - avoid runtime constraint compilation.
113+
114+
**Generated Code Integration**: Generated clients/servers depend on corresponding runtime modules (`client-core`, `server-core`).
115+
116+
**Protocol Implementation**: Client and server protocol implementations are separate - both sides must be implemented for full protocol support.

0 commit comments

Comments
 (0)