> For the complete documentation index, see [llms.txt](https://docs.constellationnetwork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.constellationnetwork.io/metagraph-development/metagraph-framework/framework-architecture.md).

# Framework Architecture

This section contains information about the Metagraph Framework and its relation to the deployed architecture of a metagraph.

In order to understand how the framework functions, it is important to understand the multi-layered architecture of a metagraph. Make sure you're familiar with [Metagraph Architecture](https://docs.constellationnetwork.io/metagraphs/concepts/architecture) before continuing.

## Code Structure[​](https://docs.constellationnetwork.io/sdk/metagraph-framework/architecture#code-structure) <a href="#code-structure" id="code-structure"></a>

A new metagraph project generated from the [currency template](https://github.com/Constellation-Labs/currency.g8) will have the following module directory structure:

```
- modules/
- - l0/
- - - Main.scala
- - l1/
- - - Main.scala
- - data_l1/
- - - Main.scala
- - shared_data
- - - Main.scala
```

Let's break down each directory and its function.

**L0**[**​**](https://docs.constellationnetwork.io/sdk/metagraph-framework/architecture#l0)

This directory contains a `Main.scala` file with a Main object instance that extends `CurrencyL0App`. `CurrencyL0App` contains overridable functions that allow for customization of the operation of the metagraph L0 layer including validation, snapshot formation, and management of off chain state. It also contains the `rewards` overridable function that allows for minting of new tokens on the network.

**note**

While the class `CurrencyL0App` has the "Currency" in its name, it defines the L0 layer through which both Currency L1 and Data L1 data flows.

**L1**[**​**](https://docs.constellationnetwork.io/sdk/metagraph-framework/architecture#l1)

This directory contains a `Main.scala` file with a Main object instance that extends `CurrencyL1App`. `CurrencyL1App` contains overridable functions relevant to customizing token validation behavior such as `transactionValidator`.

**L1 Data**[**​**](https://docs.constellationnetwork.io/sdk/metagraph-framework/architecture#l1-data)

This directory also contains a `Main.scala` file, with a Main object instance that extends `CurrencyL1App`. In order to have this L1 behave as a DataApplication, the `dataApplication` method should be overridden with your custom configuration. The metagraph examples repo has implemented examples to reference, for example the [NFT example](https://github.com/Constellation-Labs/metagraph-examples/blob/main/examples/nft/modules/data_l1/src/main/scala/com/my/nft/data_l1/Main.scala).

**Shared Data**[**​**](https://docs.constellationnetwork.io/sdk/metagraph-framework/architecture#shared-data)

This directory contains an empty Main.scala file but is provided as a suggestion for application directory structure. Several of the lifecycle functions are run on both Data L1 and on L0. For example, serializers/deserializers, validators, and data types will likely shared between layers. Organizing them in a separate directory makes their use in multiple layers clear.

See the [Data Application Lifecycle](https://docs.constellationnetwork.io/sdk/metagraph-framework/data/lifecycle-functions) for more information.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.constellationnetwork.io/metagraph-development/metagraph-framework/framework-architecture.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
