See What's Possible

Three live demo stores. One framework. Fashion, farm subscriptions, general shops — all from a single codebase.

Code Patterns

Learn hexagonal architecture through real examples

Domain Entity

Pure business logic with no dependencies

// domain/models/Product.ts
export class Product {
  constructor(
    readonly id: ProductId,
    readonly name: string,
    readonly price: Money,
    readonly inventory: Inventory
  ) {}

  canFulfill(quantity: number): boolean {
    return this.inventory.available >= quantity;
  }

  calculateTotal(quantity: number): Money {
    return this.price.multiply(quantity);
  }
}

Port Definition

Infrastructure-agnostic interface

// ports/ProductRepository.ts
export interface ProductRepository {
  findById(id: ProductId): Promise<Product | null>;
  save(product: Product): Promise<void>;
  findByCategory(categoryId: CategoryId): Promise<Product[]>;
  search(query: string): Promise<Product[]>;
}

Adapter Implementation

Concrete implementation of the port

// adapters/postgres/PostgresProductRepository.ts
export class PostgresProductRepository implements ProductRepository {
  constructor(private readonly db: DrizzleClient) {}

  async findById(id: ProductId): Promise<Product | null> {
    const row = await this.db.query.products.findFirst({
      where: eq(products.id, id)
    });
    return row ? this.toDomain(row) : null;
  }

  // ... other methods
}