How it works · Definition vs. implementation

The contract in one module, the code in another

A Chenile service is two modules. Consumers depend only on the -api module, the contract; the -service module holds a plain Java implementation that nobody depends on, so it can change, move or be replaced.

One contract in order-api, implementations in order-service invoice-service compiles against order-api, which holds only the OrderService interface and its model. It calls the save operation; OrderController in order-service hands the request to the chenile-highway, where the policies run; constructServiceReference picks the implementation bean, the default OrderServiceImpl or, for trajectory t1, T1OrderService; the implementation runs and the Order goes back to the consumer. order-api what consumers depend on public interface OrderService { Order save(Order order);}public class Order { … } contract only: no Spring, no transport order-service · what nobody depends on invoice-servicea consumer OrderController@RestController + @ChenileController chenile-highwayvia ControllerSupport which bean serves it?mock › trajectory › selector › default OrderServiceImplbean _orderService_ T1OrderService@ConditionalOnTrajectory t1 both implement OrderService compiles against calls the operation
defined by
trajectory
view
Step 1

Exchange

Payload

Three ways to define a service

The same definition, written three ways

Whichever you choose, Chenile ends up with the same service definition. What differs is whether the class you wrote takes part in the request flow.

JSON service definition

Operations, URLs and parameters as data, checked against the implementation at startup. No controller class: an HTTP request lands on Chenile's own HttpEntryPoint. Nothing you wrote stands between the caller and the policies.

@ChenileController alone

A Java definition that never runs. Chenile reads it at startup and sends every call to the bean named in serviceName; the method bodies only return a placeholder for the compiler. It adds no HTTP routes, so the service is reached through proxies, events, messaging and workflows. The purest form in Java.

@ChenileController + @RestController

Defines the service and is the entry point for REST calls: an HTTP request enters the controller method, which calls process(...). Proxy, event and message calls skip it. A deliberate compromise, so that nobody writes a Chenile controller and a REST controller with the same structure.

Why Chenile accepts that compromise is in the concept. The annotations are in the annotation-based services guide and the JSON format in the service definition JSON guide.

✅ s1-api — the definition

What consumers depend on. Pure contract.

  • The service interface (S1Service)
  • The model objects
  • No implementation, no transport, no Spring
  • Packaged as a library — never deployed alone

⚙️ s1-service — the implementation

What nobody depends on. Swappable.

  • A plain POJO implementing the interface
  • A health checker for deep readiness probes
  • Wired through a Chenile controller
  • Horizontal concerns handled by policies, not code
// The whole service. Business logic and nothing else —
// no auth, no logging, no tenancy checks tangled in here.
public class S1ServiceImpl implements S1Service {
    @Override
    public S1Entity op1(S1Entity s1Entity) {
        s1Entity.id = "S1ServiceImpl";
        return s1Entity;               // policies run around this, not inside it
    }
}