# Application

A deroll `App` is responsible for the main loop of the Cartesi application.
It fetches advance requests (inputs) sent to the application, handling them to [advance handlers](./advance-handlers), and inspect requests to [inspect handlers](./inspect-handlers).

The source of these requests is the Cartesi device inside the Cartesi Machine, which fetches requests from the outside using Cartesi I/O primitives.

You can construct an `App` that communicates with the device using the [createApp](./create-app) function.

```ts twoslash
/// <reference types="node" />
// ---cut---
import { createApp } from "@deroll/app";

// create application
const app = createApp(); // [!code focus]
```

You then call the `app.start()` method. That will enter in a continuous loop, fetching requests and handling them to the application request handlers.

```ts twoslash
/// <reference types="node" />
// ---cut---
import { createApp } from "@deroll/app";

// create application
const app = createApp();

// start app // [!code ++]
app.start().catch((e) => process.exit(1)); // [!code ++]
```

In the example above we are catching exceptions and exiting the application. Keep in mind that exiting a Cartesi rollups application means that the rollups is terminated forever.

To do anything useful the application must implement [AdvanceHandler's](./advance-handlers) and [InspectHandler's](./inspect-handlers), which is the subject of the following sections.
