Skip to content

Contributing to Emmett โ€‹

WARNING

We created this page with the help of the GenAI tool.

We're currently double-checking it to ensure the information is 100% correct and free of hallucinations.

We welcome contributions! This guide covers everything you need to get started.

Ways to Contribute โ€‹

TypeDescription
๐Ÿ› Bug ReportsFound something broken? Open an issue
๐Ÿ’ก Feature RequestsHave an idea? Start a discussion
๐Ÿ“– DocumentationImprove guides, fix typos, add examples
๐Ÿงช TestsIncrease coverage, add edge cases
๐Ÿ’ป CodeFix bugs, implement features

Getting Started โ€‹

Prerequisites โ€‹

  • Node.js 22+
  • npm 11+
  • Docker (for integration tests)

Setup โ€‹

bash
# Clone the repository
git clone https://github.com/event-driven-io/emmett.git
cd emmett

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm run test

Project Structure โ€‹

src/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ emmett/              # Core package
โ”‚   โ”œโ”€โ”€ emmett-postgresql/   # PostgreSQL event store
โ”‚   โ”œโ”€โ”€ emmett-esdb/         # EventStoreDB adapter
โ”‚   โ”œโ”€โ”€ emmett-mongodb/      # MongoDB event store
โ”‚   โ”œโ”€โ”€ emmett-sqlite/       # SQLite event store
โ”‚   โ”œโ”€โ”€ emmett-expressjs/    # Express.js integration
โ”‚   โ”œโ”€โ”€ emmett-fastify/      # Fastify integration
โ”‚   โ”œโ”€โ”€ emmett-testcontainers/  # Test utilities
โ”‚   โ””โ”€โ”€ emmett-shims/        # Polyfills
โ”œโ”€โ”€ docs/                    # Documentation (VitePress)
โ””โ”€โ”€ samples/                 # Sample applications

Development Workflow โ€‹

Running Tests โ€‹

bash
# All tests
npm run test

# Specific package
npm -ws @event-driven-io/emmett run test

# Watch mode
npm --ws @event-driven-io/emmett run test:watch

# With coverage
npm run test:coverage

Building โ€‹

bash
# All packages
npm run build

# Specific package
npm --ws @event-driven-io/emmett run build

# Watch mode (development)
npm --ws @event-driven-io/emmett run build:watch

Linting and Formatting โ€‹

bash
# Check linting
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

Making Changes โ€‹

1. Create a Branch โ€‹

bash
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-description

2. Make Your Changes โ€‹

  • Follow existing code style
  • Add tests for new functionality
  • Update documentation if needed

3. Test Your Changes โ€‹

bash
# Run tests for affected packages
npm run test

# Run full build
npm run build

4. Commit Your Changes โ€‹

Remember to make your commit message meaningful and group changes into commits logically.

5. Open a Pull Request โ€‹

  • Fill out the PR template
  • Link related issues
  • Wait for CI to pass
  • Address review feedback

Code Style โ€‹

TypeScript Guidelines โ€‹

typescript
// โœ… Good: Use explicit types for exports
export type ShoppingCartEvent =
  | Event<'ProductItemAdded', { productId: string; quantity: number }>
  | Event<'ShoppingCartConfirmed', { confirmedAt: Date }>;

// โœ… Good: Use readonly for immutable data
interface ShoppingCart {
  readonly id: string;
  readonly items: readonly ProductItem[];
}

// โœ… Good: Prefer const assertions
const STATUSES = ['Pending', 'Confirmed', 'Cancelled'] as const;

// โœ… Good: Use discriminated unions
type Result<T> = { success: true; value: T } | { success: false; error: Error };

Testing Guidelines โ€‹

typescript
// โœ… Good: Use BDD-style specifications
describe('Shopping Cart', () => {
  it('adds product to empty cart', () =>
    spec([]).when(addProductCommand).then([productAddedEvent]));
});

// โœ… Good: Test edge cases
it('rejects negative quantity', () =>
  spec([])
    .when({ type: 'AddProduct', data: { quantity: -1 } })
    .thenThrows(ValidationError));

Adding a New Package โ€‹

  1. Create package directory under src/packages/
  2. Add package.json with proper naming
  3. Add to workspace in root npm-workspace.yaml
  4. Create README following package README template
  5. Add to documentation

Documentation โ€‹

Running Docs Locally โ€‹

bash
cd src/docs
npm install
npm run dev

Writing Documentation โ€‹

  • Use VitePress markdown features
  • Include working code examples
  • Follow the Diataxis framework:
    • Tutorials: Learning-oriented (Getting Started)
    • How-to Guides: Task-oriented (Guides)
    • Reference: Information-oriented (API Reference)
    • Explanation: Understanding-oriented (deep dives)

Issue Guidelines โ€‹

Bug Reports โ€‹

Include:

  • Emmett version
  • Node.js version
  • Minimal reproduction
  • Expected vs actual behavior
  • Error messages/stack traces

Feature Requests โ€‹

Include:

  • Use case description
  • Proposed API (if applicable)
  • Alternatives considered

Getting Help โ€‹

Recognition โ€‹

Contributors are recognized in:

  • Release notes
  • README contributors section
  • GitHub contributors page

Code of Conduct โ€‹

We follow the Contributor Covenant. Be respectful, inclusive, and constructive.

License โ€‹

By contributing, you agree that your contributions will be licensed under the MIT License.

See Also โ€‹