# Project layout

> What each file in a Kurogane project does and how kurogane.toml ties them together.

A Kurogane project is a Rust crate with a frontend inside it. The starters generate this layout:

```text
my-app/
├── Cargo.toml        # the app crate
├── build.rs          # calls kurogane_build::build()
├── kurogane.toml     # the Kurogane manifest
├── src/
│   └── main.rs       # the entry point
└── frontend/         # a self-contained Vite project
    ├── index.html
    ├── main.ts
    ├── package.json
    └── vite.config.ts
```

Generated projects aren't git repositories and never join a parent Cargo workspace.

## Cargo.toml

The app crate depends on `kurogane` and builds with `kurogane-build`. Both are pinned to the same release:

```toml
[dependencies]
kurogane = "=<version>"
serde_json = "1"

[build-dependencies]
kurogane-build = "=<version>"

[workspace]
```

The pin keeps every build of the project on the same Kurogane. The empty `[workspace]` table keeps the project out of any workspace above it.

## build.rs

Every Kurogane app's build script calls `kurogane_build::build()`:

```rust
fn main() {
    kurogane_build::build();
}
```

On Windows it embeds the application manifest CEF's own executables carry. Without it Windows tells your app and the Chromium inside it that they run on Windows 8. It does nothing on other platforms.

## src/main.rs

The entry point builds an [`App`](https://kurogane-rs.org/docs/api/app/app.md) and runs it. [First app](https://kurogane-rs.org/docs/start/first-app.md#the-rust-side) walks through the starter's version.

Chromium runs this binary again for each of its helper processes. Code before the call that starts the runtime runs once in every process. Keep files, output, sockets and spawned processes out of it. Guard them with [`is_browser_process`](https://kurogane-rs.org/docs/api/app/is_browser_process.md) instead.

## frontend/

The frontend is a normal Vite project. It works on its own as in any Vite app:

```bash
cd frontend
npm install
npm run dev
```

Three directories hold the frontend at different stages:

| Directory | Holds | Used by |
|---|---|---|
| `frontend/` | the frontend source | the dev server during development |
| `frontend/dist/` | the built frontend | `kurogane bundle` |
| `content/` | the built frontend inside a bundle | your app in release builds |

`kurogane bundle` builds the frontend into `frontend/dist/` and copies it into the bundle's `content/`. A release build loads it from there with `App::new("content")`. `frontend/dist/` is a build-time path only.

## kurogane.toml

The manifest tells the CLI where the frontend is and how to work with it. The starters write this:

```toml
[app]
name = "my-app"
frontend = "frontend"
frontend-dist = "frontend/dist"
frontend-install = "npm --prefix frontend install"
frontend-run = "npm --prefix frontend run dev"
frontend-build = "npm --prefix frontend run build"
```

| Key | What it is |
|---|---|
| `name` | display name of the app; defaults to the Cargo package name |
| `frontend` | frontend source directory |
| `frontend-dist` | build output that `kurogane bundle` packages |
| `frontend-install` | command that installs the frontend's dependencies |
| `frontend-run` | command that starts the dev server |
| `frontend-build` | command `kurogane bundle` runs before it builds your Rust code |

Paths are relative to the project root. `kurogane new` prints `frontend-install` and `frontend-run` in its **Next steps**. `kurogane dev` expects the dev server to run already.

`frontend-build` runs from the project root through the platform shell. That's `sh` on Linux and macOS and `cmd` on Windows. Shell syntax such as `&&` works.

The file is optional. Without it or one of its keys the defaults apply.

### Other tables

The manifest also describes how your app is packaged:

| Table | What it configures |
|---|---|
| `[app]` | identity (`identifier`, `publisher`, `description`, `copyright`, `icon`) and `sandbox` |
| `[[bundle.resources]]` | extra files a bundle carries |
| `[linux]` | the AppImage's desktop entry |
| `[macos]` | the `.app` bundle's `Info.plist` |
| `[macos.privacy]` | what macOS shows when a page asks for the camera or microphone |
| `[windows]` | the installer's shortcuts |
| `[signing.windows]` and `[signing.macos]` | code signing |

`[app]`, `[bundle]`, `[linux]` and `[windows]` ignore keys they don't know so older projects keep parsing. `[macos]`, the `[signing]` tables and each `[[bundle.resources]]` entry refuse an unknown key. The error names the key and its line.

## Projects from kurogane init

`kurogane init` adds Kurogane to an existing frontend project. Its npm project stays at the project root:

```text
my-vite-app/
├── Cargo.toml
├── build.rs
├── kurogane.toml
├── src/
│   └── main.rs
├── index.html
├── package.json
└── vite.config.ts
```

`init` leaves `frontend` unset. It writes `frontend-dist` to `kurogane.toml` and the dev server URL into `src/main.rs`.
