The factory uses a compiler-like architecture rather than simple string templating. This ensures type safety and enables deep validation.
- Location:
src/generators/{type}/parser.ts - Role: Reads raw input (YAML/JSON) and converts it into the
ProjectConfigIR. - Logic: Heuristics are applied here (e.g., "if port 80 is exposed, set
publiclyAccessible: true").
- Location:
src/validators/ - Role: Enforces rules on the IR.
- Validators:
SecurityValidator: Checks NIST compliance (encryption, access).CostValidator: Estimates monthly spend.ContractValidator: Checks alignment with application requirements.SecretsValidator: Verifies secret existence.
- Location:
src/core/factory.ts - Role: Iterates over the validated IR and delegates to registered Generators.
- CDK Integration: Creates a
cdk.Appandcdk.Stack, applying Aspects (likecdk-nag) before purely synthesizing.
- Location:
src/templates/ - Role: Reusable L3 CDK constructs. These are functions that take a specific Resource Config (e.g.,
FargateServiceConfig) and return aConstruct.
The repository uses pnpm workspaces.
packages/cdk-factory: The core library and CLI. (Currently the main package).
scripts/: Maintenance scripts.