> ## 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.

# Customize the starter project

> How to adapt the Atoti Limits starter project: configuration first, then customizations with Spring beans, workflows and security, overrides as a last resort, and how to keep customizations easy to migrate.

You can modify the starter project to suit your needs. We recommend that you make changes in the following order:

1. **Configurations**: these are usually non-code related changes and are the easiest to migrate.
2. **Customizations**: these are usually code additions that can be easily “swapped in” to the existing codebase to
   either safely override or augment existing functionality.
3. **Overrides**: these are usually code changes that require a more in-depth understanding of the codebase and may
   require changes to existing code. In general, it is not technically possible to perform these changes as a configuration
   or customization.
   These are the hardest to migrate, and if you need to do them **we recommend you raise a [Jira](https://activeviam.atlassian.net/jira/your-work)**
   for us to see if there is a better alternative or if there is a gap in our product that needs to be addressed.

## How to configure the starter project

We recommend that you configure the application as much as possible before customizing existing code. The following
configurations are commonly used:

### How to set application properties

Application properties are used to configure functionality of Atoti Limits and most of its dependencies. These
can be found in the [properties](../../reference/properties) section and updated by modifying the
`src/main/resources/application.yml` file, or by using environment variables.

### How to configure the database

By default, the application uses an in-memory H2 database and expects any initial data to be loaded from CSV files.

> [!NOTE]
>
> Using the H2 database in production is not recommended. Instead, please use a production-grade database. There is none
> in particular that we recommend, but popular choices include:
>
> * [Postgresql](https://www.postgresql.org/)
> * [MSSQL](https://www.microsoft.com/en-us/sql-server)
> * [MySQL](https://www.mysql.com/)

If you wish to persist Atoti Limits data to an external database, you’ll need to configure the database
connection in the `application.yml` file. You will need to create and deploy your own database server, but once the
connection is configured, Atoti Limits will automatically create the required tables and schemas for you. See
[Persistence](./connect/persistence) for more information on how to set up the database connection.

### How to improve performance

Depending on a multitude of factors, such as the number of limits you have, the cardinality of the scopes for your
limits, and/or the volume/schema of the data in the connected Atoti server, the performance of your Atoti Limits
implementation may vary. See [Performance](https://docs.activeviam.com/atoti-intelligence/workflows/limits/6.2/dev/install/connect/performance.md) for information on
options to improve performance.

## How to add customizations

> [!NOTE]
>
> When you add new code as a customization to the starter project, we **highly recommend** that you use your own package
> name and avoid using the `com.activeviam` package. This will separate your code from our code and make it much easier to
> migrate. All customizations should be done in the `limits-starter` module, or in a separate module that depends on
> `limits-starter`.

### How to customize with Spring beans

The application follows Spring best practices. To customize, you can override existing beans and components by defining
them in your application. **This is the safest form of overriding or augmenting existing code behavior.** We aim to use
`@ConditionalOnMissingBean` as much as possible to allow for easy customization. If we have not exposed a bean you wish
to override as `@ConditionalOnMissingBean`, **please raise a [Jira](https://activeviam.atlassian.net/jira/your-work)
with us** and mark your bean as `@Primary`.

### How to customize Activiti workflows

The application includes default Activiti workflows located in `src/main/resources/processes/`. See [Limit Workflow](../configure/workflows)
for information on the default workflows. If you want to use custom workflows, you need to:

1. Create your BPMN file. You can either edit the existing BPMN files or use a BPMN editor, such as [BPMN.io](https://bpmn.io/).
2. Import any Spring beans or services required by your workflow. This is detailed further in [adding custom workflow
   tasks](../extend/custom-workflow-service).
3. Add the new processes in `src/main/resources/processes/`.
4. Restart the application to ensure the changes are picked up.

### How to customize security

The application comes with a default security configuration using Spring security. **You need to customize this by
implementing your own security configuration.** This is done by implementing and exposing the following interfaces:

* `com.activeviam.web.spring.api.config.ICorsConfig`: This interface is used to configure CORS settings.
* `org.springframework.security.web.SecurityFilterChain`: This interface is used to configure security filters for REST
  requests.
* `org.springframework.security.core.userdetails.UserDetailsService`: This interface is used to load user-specific data.

### How to configure roles and permissions

Configure the roles assigned to users to control what actions users can perform and assign
permissions to custom roles to control what data they can access in Atoti Limits. See [Roles and Permissions](../configure/roles)
for more information on the default roles provided by Atoti Limits and how to configure custom roles and
permissions.

### What else can you customize?

The ability to customize the application is not limited to these examples. Please see the [Extending the Module](../extend)
section for more in-depth information on the different ways you can customize the application.

## How to override the code

If you cannot configure or customize the application to meet your requirements, you may need to override the
application. This is the most complex form of modification as it requires an in-depth knowledge of the core codebase and
may result in unintended consequences. It is also the most difficult code to migrate, because it may be difficult to
remember if the code was an override in the first place or is a legitimate starter class. We recommend adding a javadoc
to differentiate overrides from released source code.

> [!WARNING]
>
> If you need to override our code we recommend that you raise a [Jira](https://activeviam.atlassian.net/jira/your-work)
> ticket with us to see if there is a better alternative or if there is a gap in our product that needs to be addressed.

## How to migrate to a new version of Atoti Limits

When migrating to a new version of Atoti Limits, we recommend the following steps:

1. Ensure your code customizations are under a separate package name from the `com.activeviam` package.
2. Create a new branch in your VCS for the upgrade.
3. If you have overridden any of our code, move it to a `tmp.com.activiam` package. This should only apply to
   **overrides**, not to starter code.
4. Install the starter project for your new version, replacing the old starter `com.activeviam` packages with the new
   packages.
5. Verify if any of the `tmp.com.activeviam` code can be removed. If so, remove it, otherwise, please raise a [Jira](https://activeviam.atlassian.net/jira/your-work)
   and merge it with the new code.
6. Run `mvn clean install`
7. If you have any compilation errors, consult the [changelog](https://docs.activeviam.com/atoti-intelligence/workflows/limits/6.2/releases/changelog.md) and [migration guide](https://docs.activeviam.com/atoti-intelligence/workflows/limits/6.2/releases/migration-guide.md) for the new version.
8. Repeat steps 6-7 until the code compiles and is correctly installed.
