Skip to content

xfoundries/jfoundry

Repository files navigation

jfoundry

English | 中文


jfoundry is a practical DDD framework for Java, built on jMolecules and designed for Hexagonal Architecture and Onion Architecture.

It helps business projects make domain modeling, architecture boundaries, and reliable integration executable in code. The core defines DDD concepts, architecture semantics, application contracts, domain events, persistence SPI, and messaging SPI without depending on a runtime framework. Spring, Quarkus, and Helidon assemble the same core through peer runtime integration modules.

Why jfoundry

DDD projects often lose their intended boundaries in implementation: domain code imports framework or ORM APIs, transaction ownership is unclear, repositories become generic query interfaces, and external events are not delivered reliably. jfoundry provides:

  • jMolecules-based DDD, Hexagonal, Onion, and CQRS semantics.
  • Explicit dependency direction across domain, application, infrastructure, and runtime integration.
  • Reusable ArchUnit rules for executable architecture constraints.
  • Optional production capabilities for persistence, reliable messaging, transactions, and runtime assembly.

Architecture

The domain model stays independent of Spring, ORM, HTTP, brokers, and database clients. Application contracts orchestrate use cases and define capability SPI; infrastructure implements technical adapters; runtime integrations assemble them.

runtime integration
  -> application / infrastructure adapters
       -> application contracts
            -> domain

Dependencies point inward. This keeps runtime integrations outside the core rather than making a particular framework a requirement for every application.

jfoundry module architecture

Capabilities

Area Capability
Domain modeling Aggregates, value objects, domain events, repository contracts, and domain exceptions
Architecture Hexagonal and Onion semantics with ArchUnit rules
Application Application services, transaction boundaries, CQRS, and domain-event orchestration
Persistence Aggregate persistence contracts with JPA and MyBatis-Plus implementations
Reliable messaging Transactional Outbox, Inbox idempotency, messaging, and serialization SPI
Runtime integration Spring Framework and Spring Boot assembly; Quarkus and Helidon CDI/Jakarta Transactions, JPA, Outbox/Inbox, and REST Problem Details assembly

Choose Your Path

Minimal Setup

Every application imports the runtime-neutral BOM, then adds only the starters and capability implementations it requires. A Spring Boot, Quarkus, or Helidon application additionally imports its matching runtime BOM; runtime BOMs manage their platform ecosystems and do not replace the JFoundry BOM.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.github.xfoundries</groupId>
            <artifactId>jfoundry-dependencies</artifactId>
            <version>${jfoundry.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Domain Model Example

// Money.java
import org.jfoundry.domain.valueobject.ValueObject;

import java.math.BigDecimal;

public record Money(BigDecimal amount, String currency) implements ValueObject {
}
// OrderId.java
import org.jmolecules.ddd.types.Identifier;

public record OrderId(String value) implements Identifier {
}
// Order.java
import org.jfoundry.domain.entity.agg.BaseAggregateRoot;

public final class Order extends BaseAggregateRoot<Order, OrderId> {

    private Money total;

    public Order(OrderId id, Money total) {
        super(id);
        this.total = total;
    }

    public void changeTotal(Money total) {
        this.total = total;
    }
}

Documentation

Getting Started

Capabilities

Implementations

Reference

Framework Semantics

Modeling

Release and Compatibility

For the complete documentation structure, see the Documentation Index.

Build

mvn validate
mvn test
mvn clean install

License

Apache License 2.0

About

jfoundry is a practical DDD framework for Java, built on jMolecules and designed for Hexagonal Architecture and Onion Architecture.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages