Skip to content

Commit 55735d6

Browse files
add claude code md (#82)
1 parent 86536cd commit 55735d6

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

CLAUDE.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
MultiCloudJ is a cloud-agnostic Java SDK providing unified interfaces for cloud services across AWS, GCP, and Alibaba Cloud. The SDK uses Java Service Provider Interface (SPI) pattern to load provider-specific implementations at runtime.
8+
9+
## Architecture
10+
11+
### Module Structure
12+
13+
The project follows a hierarchical module organization:
14+
15+
**Common Modules:**
16+
- `multicloudj-common`: Core abstractions, exceptions, and utilities shared across all services
17+
- `multicloudj-common-aws`: AWS-specific common utilities and abstractions
18+
- `multicloudj-common-gcp`: GCP-specific common utilities and abstractions
19+
- `multicloudj-common-ali`: Alibaba Cloud-specific common utilities and abstractions
20+
21+
**Service Modules:** Each service has a `-client` module (cloud-agnostic API) and provider-specific implementation modules:
22+
- **Blob Storage**: `blob/blob-client` (API), `blob/blob-aws`, `blob/blob-gcp`, `blob/blob-ali`
23+
- **Document Store**: `docstore/docstore-client` (API), `docstore/docstore-aws`, `docstore/docstore-gcp-firestore`, `docstore/docstore-gcp-spanner`, `docstore/docstore-ali`
24+
- **STS (Security Token Service)**: `sts/sts-client` (API), `sts/sts-aws`, `sts/sts-gcp`, `sts/sts-ali`
25+
- **PubSub**: `pubsub/pubsub-client` (API), `pubsub/pubsub-aws`, `pubsub/pubsub-gcp`
26+
27+
**Other Modules:**
28+
- `examples`: Example code demonstrating SDK usage
29+
- `coverage-report`: Aggregated code coverage reports
30+
31+
### Provider Discovery Pattern
32+
33+
The SDK uses Java ServiceLoader for provider discovery. Provider-specific implementations are loaded dynamically based on `providerId` (e.g., "aws", "gcp", "ali"). All provider implementations:
34+
1. Extend abstract classes from `-client` modules (e.g., `AbstractBlobStore`, `AbstractBlobClient`)
35+
2. Implement the `Provider` interface with `getProviderId()` method
36+
3. Are registered in `META-INF/services/` files for ServiceLoader
37+
38+
### Client Architecture
39+
40+
Services expose two types of clients:
41+
- **Service-level clients** (e.g., `BlobClient`): Service-wide operations like listing buckets
42+
- **Resource-level clients** (e.g., `BucketClient`, `TopicClient`): Operations on specific resources
43+
44+
Clients are instantiated using builder pattern: `BlobClient.builder("aws").withRegion("us-west-2").build()`
45+
46+
## Common Commands
47+
48+
49+
### Building and Testing
50+
51+
```bash
52+
# Full build with all unit tests
53+
a. mvn clean install
54+
55+
# Build without tests, before running any tests, always run this step.
56+
b. mvn clean install -DskipTests
57+
58+
# Run unit tests only
59+
c. mvn clean test
60+
61+
# Run the full test suite including unit and integration tests
62+
d. mvn clean verify
63+
64+
# Run tests for specific module, but make sure you run command b. before this
65+
e. mvn test -pl blob/blob-aws
66+
67+
# Run specific test class, but make sure you run command b. before this
68+
f. mvn test -pl blob/blob-aws -Dtest=AwsBlobStoreTest
69+
70+
# Run integration tests with recording mode (updates test fixtures)
71+
g. mvn test -pl blob/blob-aws -Dtest=AwsBlobStoreIT -Drecord
72+
73+
```
74+
75+
## Testing Conventions
76+
77+
### Test Types
78+
79+
- **Unit tests** (`*Test.java`): Mock-based tests, no external dependencies
80+
- **Conformance tests** (`AbstractBlobStoreIT`, etc.): Base test suites in `-client` modules that provider implementations extend to ensure API compliance
81+
- Conformance tests are also integration tests. Conformance tests are written once on Abstract class such as `AbstractBlobStoreIT` and executed by each cloud such as `AwsBlobStoreIT`.
82+
- We never run the conformance tests through abstract class, only the implementation gets executed such as `AwsBlobStoreIT`
83+
- Conformance tests are executed in 2 modes:
84+
- record mode: with `-Drecord` and the credentials are supplied. This mode uses wiremock as a forward proxy and record all the http transactions as request/response
85+
- replay mode: default mode with no credentials required. This mode uses wiremock as a forward proxy and replays the previously recorded responses by record mode.
86+
87+
### Special instructions for Running Conformance Tests in record mode
88+
89+
Conformance tests require valid cloud credentials:
90+
- AWS: Set `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`, if they are not available, ask the user.
91+
- GCP: Set `GOOGLE_APPLICATION_CREDENTIALS` pointing to service account JSON, if they are not available, ask the user.
92+
- Alibaba: It depends upon the cloud service, for tablestore it's:
93+
- `TABLESTORE_ACCESS_KEY_ID`, `TABLESTORE_ACCESS_KEY_SECRET`, `TABLESTORE_SESSION_TOKEN`
94+
95+
## Development Guidelines
96+
97+
### Dependency management
98+
- Never add cloud specific dependency in cloud-agnostic package.
99+
- for example, `docstore-client` should never depend upon `multicloud-common-gcp`, `docstore-aws` etc
100+
101+
### Adding New Functionality
102+
103+
1. Define cloud-agnostic API in `-client` for end user, for example `BucketClient`, `DocstoreClient`
104+
2. Define cloud-agnostic API in `-client` module's abstract class in driver such as `AbstractBlobStore`, `AbstractDocstore`
105+
3. Implement functionality in each provider-specific module (aws, gcp, ali)
106+
4. Add unit tests to provider modules
107+
5. Add/update conformance tests in `-client` module
108+
6. Ensure checkstyle passes (Google Java Style Guide)
109+
110+
### Working with Multiple Cloud Providers
111+
112+
Features must be implementable across all supported cloud providers. If a feature is provider-specific, discuss in an issue before implementing. The SDK prioritizes cross-cloud compatibility over provider-specific capabilities.
113+
114+
## Build Configuration
115+
116+
- **Java Version**: Requires Java 11+, targets Java 11 bytecode
117+
- **Build Tool**: Maven 3.8+
118+
- **Parent POM**: `multicloudj-parent` in root `pom.xml`
119+
- **Version Management**: Uses `${revision}` property with flatten-maven-plugin
120+
- **Code Coverage**: JaCoCo plugin enabled, reports in `coverage-report` module

0 commit comments

Comments
 (0)