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

# Root Layout and Provider Tree

> The entry point of the app and its deeply nested provider architecture.

# Root Layout and Provider Tree

The root layout (`app/_layout.tsx`) is the absolute entry point of the CommitT application. Before any screen renders, it wraps the entire component tree in a deeply nested provider architecture. Each layer depends on the one above it, and the order cannot be changed without breaking the system.

***

## Provider Nesting Order

| Layer | Provider               | Responsibility                                                                                                                                             |
| :---- | :--------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1     | ResurrectionProvider   | System reset capability. Increments an iteration counter to trigger full client rebirth on catastrophic failure.                                           |
| 2     | SQLiteProvider         | Initializes the local commit.db database. Runs migrateDbIfNeeded() on mount to detect schema mismatches and execute Nuke and Pave.                         |
| 3     | ConvexClientWrapper    | Manages the lifecycle of the ConvexReactClient. Destroys and re-creates the client on each resurrection iteration.                                         |
| 4     | SecurityShield         | Root and jailbreak detection via JailMonkey. If a compromised device is detected, the entire tree below is unmounted and replaced with a violation screen. |
| 5     | GestureHandlerRootView | Required by react-native-gesture-handler for drag-and-drop and swipe gestures across the app.                                                              |
| 6     | KeyboardProvider       | Powers react-native-keyboard-controller for smooth keyboard avoidance animations.                                                                          |
| 7     | AppThemeProvider       | Dark-mode theming and design token management.                                                                                                             |
| 8     | HeroUINativeProvider   | HeroUI component library initialization.                                                                                                                   |
| 9     | ThemeProvider          | React Navigation theme (forced to pure black background).                                                                                                  |

<Warning>
  The SecurityShield sits above the navigation stack. If a rooted device or jailbreak is detected, the entire app tree below is unmounted. There is no way to navigate around it.
</Warning>

***

## Invisible Root Components

Three invisible components are mounted alongside the navigation stack:

* **HydrationEngine** -- Runs useHydrationSync() in the background, continuously pulling delta payloads from Convex and feeding them into the Sync Engine.
* **HealOverlay** -- A recovery UI that appears when the database is being reconstructed. Reads progress from useHealStore.
* **ChaosFab** -- Development-only floating action button for injecting failures and testing resilience.

***

## Console Hijack

Before any provider mounts, the root layout activates the global Logger polyfill:

```typescript theme={null}
Logger.installPolyfill();
```

This intercepts every console.log, console.warn, and console.error call across the entire app and writes them to persistent daily log files on disk. This is critical for Release builds where logcat access is unavailable.
