> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/sandbox/platform/architecture/sandbox-ui/low-level-design/root-app.md).

# Root App

## **Overview**

The Root App is a pure JavaScript application based on the Single-SPA framework. It serves as the primary orchestrator for loading and managing multiple micro frontends within a single-page application (SPA). The application uses Single-SPA's layout engine and micro frontend configuration to dynamically load and render micro frontends based on a predefined layout.

## **Components**

1. **Single-SPA Core**
   * **Purpose**: Provide the core functionalities for registering, loading, and managing micro frontends.
   * **Responsibilities**:
     * Register micro frontend applications.
     * Start the Single-SPA application orchestrator.
     * Manage lifecycle events of the micro frontends.
2. **Single-SPA Layout**
   * **Purpose**: Define the layout structure of the microfrontends.
   * **Responsibilities**:
     * Parse the layout configuration.
     * Construct routes based on the layout.
     * Activate the layout engine to manage micro frontend positioning and rendering.
3. **Micro frontends Applications**
   * **Purpose**: Individual micro frontend applications that provide specific functionalities within the root app.
   * **Responsibilities**:
     * Implement specific business logic and UI components.
     * Be dynamically loaded based on the route and layout configuration.
4. **Custom Properties**
   * **Purpose**: Provide dynamic properties to microfrontends.
   * **Responsibilities**:
     * Extract and pass the root tenant information from the URL.
     * Provide the base application URL to micro frontends.

## **Key Functions & Configuration**

1. **`getRootTenant` Function**
   * **Purpose**: Extract the root tenant from the URL.
2. **Layout Configuration**
   * **Purpose**: Define the layout structure using Single-SPA layout configuration.
3. **Micro frontend Applications**
   * **Purpose**: Define and register micro frontends based on the layout configuration.
4. **Layout Engine**
   * **Purpose**: Manage the positioning and rendering of microfrontends.
5. **Register Applications**
   * **Purpose**: Register each micro frontend application with custom properties.
6. **Start Single-SPA**
   * **Purpose**: Start the Single-SPA orchestrator.

## **Data Flow**

1. **Initialization**
   * On application start, the `getRootTenant` function extracts the root tenant from the URL.
   * The `constructRoutes` function parses the micro frontend layout configuration.
2. **Application Registration**
   * The `constructApplications` function constructs the applications based on the routes.
   * Each application is registered with custom properties, including `rootTenant` and `baseAppURL`.
3. **Layout Management**
   * The `constructLayoutEngine` function activates the layout engine to manage micro frontend positioning.
4. **Application Start**
   * The `start` function initializes the Single-SPA framework, enabling micro frontend orchestration.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digit.org/sandbox/platform/architecture/sandbox-ui/low-level-design/root-app.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
