> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to set up the Spring Boot Starter

> Step-by-step guide for setting up Atoti What-If using the Spring Boot Starter.

## What is the Spring Boot Starter

The Atoti What-If Spring Boot Starter provides auto-configuration for all What-If components. Instead of manually defining beans for the simulation engine, workflow, persistence, and security managers, the starter configures these automatically.

Benefits of using the starter:

* Minimal configuration required
* Sensible defaults for all components
* Easy customization through properties
* Ability to override any auto-configured bean

## Prerequisites

* Java 21 or later
* Spring Boot 3.x
* Atoti Server 6.1.x
* Hibernate on the classpath (for JPA persistence)

## How to add the dependency

```xml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
<dependency>
    <groupId>com.activeviam.apps</groupId>
    <artifactId>atoti-what-if-spring-boot-starter</artifactId>
    <version>5.0.0-AS6.1</version>
</dependency>
```

## How to provide required beans

The starter requires two beans from your application:

### IDatabaseService

The `IDatabaseService` is typically provided by your Atoti Server application. Most applications already have this bean configured.

### IWhatIfPersistenceProperties

Provides Hibernate configuration for simulation persistence. This bean must return a `Map<String, String>` of Hibernate properties. The properties can be built in any way, such as from a properties file, environment variables, or hardcoded values.

Example using an inline map:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IWhatIfPersistenceProperties whatIfPersistenceProperties() {
    return () -> Map.of(
        "hibernate.hbm2ddl.auto", "update",
        "hibernate.connection.url", "jdbc:h2:mem:submissions;DB_CLOSE_DELAY=-1",
        "hibernate.connection.driver_class", "org.h2.Driver",
        "hibernate.dialect", "org.hibernate.dialect.H2Dialect",
        "hibernate.default_schema", "submissions"
    );
}
```

Example loading from a properties file:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IWhatIfPersistenceProperties whatIfPersistenceProperties(
        @Value("classpath:hibernate.properties") Resource resource) throws IOException {
    Properties props = new Properties();
    props.load(resource.getInputStream());
    return () -> props.entrySet().stream()
        .collect(Collectors.toMap(
            e -> String.valueOf(e.getKey()),
            e -> String.valueOf(e.getValue())
        ));
}
```

## How to configure properties

Additional configuration is available through `atoti.what-if.*` properties in your `application.yml` or `application.properties`.

### Enable/Disable What-If

All What-If features are enabled by default. To disable all What-If auto-configuration:

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
atoti:
  what-if:
    enable: false
```

### Security configuration

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
atoti:
  what-if:
    security:
      type: spring  # spring, none, or custom
      use-branch-permissions: true
```

### Distributed mode configuration

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
atoti:
  what-if:
    distribution:
      enabled: true
      query-node-name: "query-node"
      create-distributed-service: true
```

See the [configuration reference](./configuration-reference) for all available properties.

## How to customize auto-configured beans

Any auto-configured bean can be overridden by providing your own bean of the same type. The starter uses `@ConditionalOnMissingBean` annotations, so your custom beans take precedence.

Example: Custom ID generator

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IUniqueIdGenerator customIdGenerator() {
    return new MyCustomIdGenerator();
}
```

Example: Custom security manager

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IDatabaseSimulationsSecurityManager customSecurityManager(
        ISimulationPersistenceManager persistenceManager) {
    return new MyCustomSecurityManager(persistenceManager);
}
```

## Next steps

* [Implementation example](./dev-implementation-example) for creating simulation definitions
* [Components](./dev-components) to understand the library structure
* [Permissioning](./dev-permissioning) for security configuration details
