# Project structure and configuration

Understand the files in a generated game, configure its listing, and keep source, secrets, and build output separate.

Your downloaded kit is a standalone TypeScript project. Its files belong to you and do not depend on the SpawnKit repository.

<a id="files"></a>

## Find the file you need

**Typical generated project; optional tools add more files**

```text
my-game/
├── src/
│   ├── main.ts
│   └── score.ts
├── public/media/cover.svg
├── spawnkit/config.ts
├── spawnkit/vite.ts
├── spawnkit.config.ts
├── game.config.json
├── dev-domains.config.mjs
├── vite.config.ts
├── package.json
├── tsconfig.json
└── .spawn/state.json
```

| File or folder | Responsibility |
| --- | --- |
| `src/` | Game source. The renderer and selected modules determine its exact structure. |
| `public/` | Static files copied to the build without import processing. |
| `game.config.json` | Versioned scaffolding manifest; not the public game listing. |
| `spawnkit.config.ts` or `spawnkit.config.json` | One configuration for title, description, genre, dimension, and release-relative media paths. |
| `spawnkit/` | Local listing types, validation, and Vite plugin. No private package required. |
| `dev-domains.config.mjs` | Named local HTTPS endpoints. |
| `.spawn/state.json` | Generator ownership baseline used for safe module additions. |
| `.spawn/project.json` | Created by CLI linking; associates this folder with a hosted project. |
| `pnpm-lock.yaml` | Created by installation. Commit it for reproducible installs and source deployment. |
| `dist/` | Generated browser build. Rebuild instead of editing these files. |

<a id="scripts"></a>

## Run the project's scripts

**Install, develop, and validate**

```sh
pnpm install
pnpm dev
# Stop the development server before continuing.
pnpm lint
pnpm build
pnpm preview
```

`build` checks TypeScript and creates the Vite production output. `preview` serves that output locally. Test, E2E, and Storybook scripts exist only when their add-ons are selected; inspect `package.json` before using them. Generated projects and hosted source builds currently use pnpm.

<a id="assets"></a>

## Asset paths from source to release

**Static file mapping**

```text
public/media/cover.webp → dist/media/cover.webp
Listing coverPath: media/cover.webp
Browser URL: /media/cover.webp
```

Use `public/` for assets that need a stable filename. Assets imported from source are processed by Vite and may receive hashed filenames. Keep listing media under `public/` so their release-relative paths remain predictable. Match filename capitalization exactly; hosted files are case-sensitive.

For a full listing configuration and ZIP commands, see [Publishing examples](https://spawnkit.cloud/docs/publishing-examples).

<a id="environment"></a>

## Local environment and public configuration

**Optional .env override**

```sh
SPAWN_GAME_DOMAIN=my-game.spawnkit.games
```

No domain override is needed for local development. If you set `SPAWN_GAME_DOMAIN`, use your project's assigned production hostname, not an arbitrary custom name. Verified CLI linking normally supplies the assigned hostname automatically. Run `pnpm exec dev-domains urls` to see the addresses and `pnpm exec dev-domains doctor` to diagnose local setup.

> **Browser-visible values**
>
> Vite's `VITE_` variables are compiled into browser code. Never put private API keys, account tokens, or server credentials in them. Keep local `.env` files and credentials out of uploaded artifacts.

Changing the listing configuration requires a new production build. Changing `.spawn/project.json` by hand is not an authorization mechanism; use the CLI link flow to verify account access.
