# Site structure

A site is a self-contained directory holding everything one gateway runs: configuration, project sources, and the published store the gateway actually serves. This page walks the whole tree.

## The site folder, end to end.

```
my-site/
├── thermite-server            # optional — binary deployed into the site
├── config/
│   ├── server.toml            # gateway config — identity, devices, features
│   ├── license.json           # license (or trial.json while on trial)
│   ├── gateway.id             # generated on first boot — gateway identity
│   ├── node.toml              # node-local settings (redundant pairs)
│   └── gateway.tls.*.pem      # generated — gateway-to-gateway mesh TLS
├── projects/                  # authoring workspace — what engineers edit
│   └── press-line/
│       ├── project.toml       # manifest: id, slug, branding, auth
│       ├── users.toml         # project-local users
│       ├── tags/              # [[tags]] TOML files, subdirs allowed
│       ├── screens/           # one folder per screen, index.html each
│       ├── transactions/      # SQL logging groups
│       └── queries/           # named SQL queries
├── published/                 # runtime store — what the gateway serves
│   └── press-line/
│       ├── production/
│       │   ├── current        # pointer: names the live snapshot
│       │   └── snap-<id>/     # immutable snapshot of the project
│       └── drafts/wip/…
└── logs/
    ├── thermite-server.log.<date>
    └── audit.jsonl
```

## How the tools find the site.

The server and the CLI resolve the site root differently — worth knowing before you script either.

### `thermite-server`

Uses `--site <path>` when given; otherwise the directory containing the executable. A binary dropped into the site folder runs with no arguments.

### `thermite`

Uses `--site <path>` when given; otherwise walks up from the current directory until it finds `config/server.toml`. Running commands from anywhere inside the site just works.

## projects/ is what you edit. published/ is what runs.

The gateway never serves your working files. It serves immutable snapshots from `published/`, written by `thermite project draft` and `publish` — each one validated at publish time, recording the source git commit and branch on a best-effort basis when the workspace is a Git repo, and swapped in atomically via the `current` pointer. Source edits are served after publishing. To roll back project content, restore the earlier source revision and publish it again. The lifecycle has its own page: [Publishing & the CLI](https://thermitescada.com/docs/publishing.md).

## What belongs in git.

Version source in `projects/`: manifests, tags, screens, transactions, and queries. Keep reviewed templates such as `config/server.toml.example` in Git. Keep live configuration, credentials, identities, licences, and private keys in a secured recovery set. Thermite installs source-oriented ignore defaults when a site has no `.gitignore`, including these rules:

```
# Selected rules from the installed site .gitignore
/published/
/logs/
/config/server.toml*
!/config/server.toml.example
/config/backup.toml*
/config/node.toml*
/config/gateway.id*
/config/gateway.tls.*
/config/license.json*
/config/trial.json*
/projects/**/users.toml*
!/projects/**/users.toml.example
.env*
*.key
*-key.pem
```

Preserve `config/gateway.id` and its matching `config/license.json` together in the secured recovery backup. Existing ignore files are preserved; defaults do not detect secrets or untrack committed files. Add rules for custom `credentials_file` and private-key names, and review templates before committing.

## One site, many projects.

- One site = one gateway. A site can hold any number of projects, each an independent application with its own tags, screens, users, and roles.
- Project slugs and ids are unique across the site — the slug is the URL mount (`/p/<slug>/`) and the id keys sessions and tag scopes. `thermite project init` generates both.
- Tag paths are scoped per project — two projects can both define `plant/Temperature` without colliding.
- Devices and databases are site-level (declared in `server.toml`); a project's manifest scopes which of them it may use — see [Projects](https://thermitescada.com/docs/project-structure.md).
