# Project Structure

This guide walks you through the Profiles project structure generated once you initialize a new project using the `pb init` command.

## Initial project structure

After initializing a new Profiles project, you will see the following project folder structure:

```text
.
├── logs/logfile.log
├── models/
│   ├── inputs.yaml
│   └── profiles.yaml
├── output/
├── .gitignore
├── pb_project.yaml
└── README.md
```

| Folder   | Description|
| :--------- | :------------------------- |
| `logs/`   | Stores the `logfile.log` file containing the logs from all `pb` runs. |
| `models/` | Stores the [`inputs`]({{< ref "profiles/dev-docs/inputs-yaml/" >}}), [`profiles`]({{< ref "profiles/dev-docs/profiles-yaml/" >}}), [`sql_models`]({{< ref "profiles/dev-docs/sql-model-yaml/" >}}), and [`macros`]({{< ref "profiles/dev-docs/macros-yaml.md" >}}) YAML files. |
| `output/` | Stores the compiled SQL files from each project run. <br/><br/>These files are then executed in your warehouse. |

| File | Description |
| :----------- | :------------------- |
| `.gitignore` | Specifies the files that Git ignores. |
| [`pb_project.yaml`]({{< ref "profiles/dev-docs/pb-project-yaml/" >}}) | Profiles project configuration. |
| `README.md` | Overview on using `pb` and the SQL queries for analysis. |

## Full project structure

After adding [`sql_models.yaml`]({{< ref "profiles/dev-docs/sql-model-yaml/" >}}) and [`macros.yaml`]({{< ref "profiles/dev-docs/macros-yaml.md" >}}) files (if used), the project structure looks as follows:

```text
.
├── logs/logfile.log
├── models/
│   ├── inputs.yaml
|   ├── macros.yaml
|   ├── profiles.yaml
│   └── sql_models.yaml
├── output/
├── .gitignore
├── pb_project.yaml
└── README.md
```

## SQL output structure

Profiles projects are compiled into SQL files which are executed in your data warehouse.

These compiled SQL queries are stored in a hierarchy of folders in the `output` folder.

```text
output/
└── <target>/
    └── seq_no/
        ├── 1/
        ├── 2/
        ├── ...
        └── latest/
            ├── compile/
            └── run/
```

The `output` folder contains folders for each warehouse connection target (for example, `dev`, `prod`, etc.).

Within each target folder is a `seq_no` folder containing separate folders for each sequence number (`1`, `2`, `3`, etc.), along with a `latest` symbolic link for the latest sequence number. The sequence number folders contain `compile` (compiled SQL files, staged for execution) and `run` (post execution SQL files) folders storing the SQL files and folders containing the SQL files.

### Naming convention

The SQL files and folders containing SQL files are named in the following format: `Material_<name>_<hash>_<seq_no>`.

For example: `Material_product_tier_32cf8f89_1`

<br />

