This guide covers development setup, architecture, and contribution guidelines for the Threat Composer project.
This monorepo hosts multiple packages that make up the Threat Composer ecosystem:
- threat-composer: Core UI components library
- threat-composer-app: Web application (SPA)
- threat-composer-app-browser-extension: Browser extension for Chrome/Firefox
- threat-composer-infra: AWS CDK infrastructure code
- threat-composer-ai: AI-powered CLI and MCP server for automated threat modeling
The repository is defined and maintained using projen and aws-prototyping-sdk.
| Project | Path | Description | Tech Stack |
|---|---|---|---|
| threat-composer | packages/threat-composer | UI components for threat-composer | React, CloudScape design system |
| threat-composer-app | packages/threat-composer-app | threat-composer Single Page App (SPA) bootstrapped by create-react-app | React |
| threat-composer-infra | packages/threat-composer-infra | threat-composer Infrastructure CDK App | aws-prototyping-sdk constructs |
| threat-composer-app-browser-extension | packages/threat-composer-app-browser-extension | threat-composer browser extension | wxt, React |
| threat-composer-ai | packages/threat-composer-ai | AI-powered CLI and MCP server | Python, Strands, FastMCP |
- NodeJS (version 20 or higher)
- Yarn - Install via
npm install -g yarn - PDK - Install via
npm install -g @aws/pdk - git-secrets
- oss-attribution-generator - Install via
npm install -g oss-attribution-generator
- AWS CLI (version 2 or higher) - For infrastructure deployment
- AWS CDK v2 - Install via
npm install -g aws-cdk - Python 3.10+ - For threat-composer-ai package
- UV - Python package manager for threat-composer-ai
git clone https://github.com/awslabs/threat-composer.git
cd threat-composerpdk install --frozen-lockfileThis will install all dependencies for all packages in the monorepo.
pdk buildThis builds all packages in the correct dependency order.
The threat-composer package contains the core UI components. The recommended development environment is Storybook.
pdk run storybookOpen http://localhost:6006 to view it in the browser. The page will reload if you make edits.
This is the recommended development environment for UI component work.
cd packages/threat-composer
yarn testpdk run devThis starts the web application in development mode. Open http://localhost:3000 to view it in the browser.
cd packages/threat-composer-app
yarn buildThe build artifacts will be in the build/ directory.
See the Browser Extension README for detailed instructions.
Quick start:
cd packages/threat-composer-app-browser-extension
# Chrome development
yarn run dev
# Firefox development
yarn run dev:firefox# Deploy dev environment
./scripts/deployDev.sh
# Deploy with CI/CD pipeline
./scripts/deployAll.shcd packages/threat-composer-infra
# Synthesize CloudFormation template
cdk synth
# Deploy stack
cdk deploy
# Destroy stack
cdk destroycd packages/threat-composer-ai
# Install dependencies
uv sync
# Run CLI
uv run threat-composer-ai-cli /path/to/codebase
# Run MCP server
uv run threat-composer-ai-mcp
# Run tests
uv run pytest# Install all dependencies
pdk install --frozen-lockfile
# Build all packages
pdk build
# Run Storybook
pdk run storybook
# Start web app dev server
pdk run dev
# Run all tests
pdk test
# Lint all packages
pdk run lint
# Format code
pdk run formatNavigate to the package directory and use yarn/npm commands:
cd packages/threat-composer
# Run tests
yarn test
# Build package
yarn build
# Lint
yarn lintsrc/
├── components/ # React components
│ ├── application/ # Application info components
│ ├── architecture/ # Architecture components
│ ├── assumptions/ # Assumptions components
│ ├── threats/ # Threat components
│ └── mitigations/ # Mitigation components
├── contexts/ # React contexts
├── hooks/ # Custom React hooks
├── utils/ # Utility functions
├── data/ # Reference data
│ ├── workspaceExamples/
│ ├── threatPacks/
│ └── mitigationPacks/
└── styles/ # Global styles
src/
├── components/ # App-specific components
├── containers/ # Container components
├── routes/ # Route definitions
├── hooks/ # App-specific hooks
└── utils/ # App utilities
src/
├── application-stack.ts # Application CloudFormation stack
├── application-stage.ts # Application stage
├── pipeline-stack.ts # CI/CD pipeline stack
└── pipeline.ts # Pipeline definition
# Run all tests
pdk test
# Run tests for specific package
cd packages/threat-composer
yarn test
# Run tests in watch mode
yarn test --watch
# Run tests with coverage
yarn test --coverage# Lint all packages
pdk run eslintThe project uses Prettier for code formatting:
# Format all code
pdk run format# Type check all packages
pdk run type-check
# Type check specific package
cd packages/threat-composer
yarn type-checkpdk buildcd packages/threat-composer
yarn buildcd packages/threat-composer-app-browser-extension
# Build for Chrome
yarn build
# Build for Firefox
yarn build:firefox
# Create distribution ZIP
yarn run zip
yarn run zip:firefoxSee Web App Documentation for detailed deployment instructions.
Quick deploy:
# Deploy dev environment
./scripts/deployDev.sh
# Deploy with CI/CD
./scripts/deployAll.sh- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
pdk test - Run linting:
pdk run lint - Commit your changes:
git commit -m "Add my feature" - Push to your fork:
git push origin feature/my-feature - Create a Pull Request
Follow conventional commit format:
type(scope): subject
body
footer
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test changeschore: Build process or auxiliary tool changes
- All changes require a pull request
- At least one approval required
- All CI checks must pass
- Code must follow project style guidelines
git clean -fXd
pdk install --frozen-lockfile- Check existing GitHub Issues
- Review Discussions
- Read package-specific READMEs
- Consult documentation in
docs/directory
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
For bugs, issues, and feature requests, please use GitHub Issues.
For general questions and discussions, use GitHub Discussions.