Skip to content

Commit 5ea2292

Browse files
authored
Merge pull request #839 from brucehoff/home-week-hackathon
Home week hackathon
2 parents 851c33e + 22234a7 commit 5ea2292

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
/.idea
1010
/.vscode
1111
**/.DS_Store
12+
.claude/*
13+
!.claude/skills/

CLAUDE.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build Commands
6+
7+
```bash
8+
mvn clean test # Build and run all tests
9+
mvn clean package # Build executable JAR
10+
mvn test -Dtest=S3ConfigValidatorTest # Run a single test class
11+
mvn test -Dtest=S3ConfigValidatorTest#testValidate # Run a single test method
12+
```
13+
14+
CI runs `mvn --batch-mode clean test` on PRs to `develop` and `release-*` branches.
15+
16+
## Architecture
17+
18+
Synapse Stack Builder is a Java application that generates and deploys AWS CloudFormation stacks for the Synapse research platform. The core pipeline is:
19+
20+
**JSON config files → Descriptor objects → Builders → Velocity templates → CloudFormation JSON → AWS deployment**
21+
22+
### Key Patterns
23+
24+
- **Guice DI**: `TemplateGuiceModule` is the central wiring point — all builders, AWS clients, config objects, and Velocity engine are bound here.
25+
- **Velocity templates**: `.vtp` files in `src/main/resources/templates/` are merged with context to produce CloudFormation JSON. The Velocity engine loads templates from both classpath and filesystem.
26+
- **VelocityContextProvider**: Pluggable interface (registered via Guice Multibinder) that contributes variables to template contexts. This is the main extensibility point — new resource types add a provider implementation and bind it in the module.
27+
- **Descriptor/Builder pattern**: Resources are defined as descriptor objects (e.g., `EnvironmentDescriptor`, `S3BucketDescriptor`) with builder-style methods, then transformed into CloudFormation resources via templates.
28+
- **Configuration-driven**: JSON config files (`src/main/resources/templates/`) define S3 buckets, SNS/SQS queues, Kinesis streams, AppConfig, Athena queries, etc. These are deserialized into typed config objects and validated by corresponding `*Validator` classes.
29+
30+
### Stack Deployment Order
31+
32+
Stacks are deployed in dependency order:
33+
1. **Global Resources** — KMS keys, IAM roles, helper Lambdas
34+
2. **VPC** — Network infrastructure, subnets by color (red/blue/green/orange for AZs)
35+
3. **Shared Resources** — RDS databases, encryption, secrets
36+
4. **Environment Stacks** — Elastic Beanstalk environments (repo services, workers, tables, migration)
37+
5. **CDN & Network** — CloudFront distributions, Network Load Balancers
38+
39+
### Entry Points
40+
41+
Multiple `*Main` classes each build a specific stack type: `RepositoryBuilderMain`, `VpcBuilderMain`, `S3BuilderMain`, `CdnBuilderMain`, `DataWarehouseBuilderMain`, `GlobalResourcesBuilderMain`, etc.
42+
43+
## Main Packages (`org.sagebionetworks.template`)
44+
45+
| Package | Purpose |
46+
|---------|---------|
47+
| `repo/` | Repository/Elastic Beanstalk infrastructure (sub-packages: `appconfig/`, `beanstalk/`, `kinesis/`, `queues/`, `cloudwatchlogs/`, `glue/`, `athena/`, `agent/`) |
48+
| `s3/` | S3 bucket configuration and building |
49+
| `vpc/` | VPC and subnet templates |
50+
| `cdn/` | CloudFront CDN resources |
51+
| `datawarehouse/` | Data warehouse infrastructure and backfill |
52+
| `global/` | Account-level global AWS resources |
53+
| `ip/` | IP address pool management |
54+
| `config/` | Configuration management |
55+
56+
## Testing
57+
58+
Tests use JUnit 5 with Mockito. Standard pattern:
59+
60+
```java
61+
@ExtendWith(MockitoExtension.class)
62+
public class FooTest {
63+
@Mock private SomeDependency mockDep;
64+
@InjectMocks private Foo foo;
65+
66+
@Test
67+
public void testSomething() { ... }
68+
}
69+
```
70+
71+
Test files follow `*Test.java` naming. Integration tests use `*IntegrationTest.java`.

0 commit comments

Comments
 (0)