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

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

The question should be specific, self-contained, and written in natural language.
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.
