# Supported Languages

OpenBerth auto-detects the language and framework from your project files.

Detection order: Go → Python → Node.js → Static HTML (first match wins).

## Node.js

**Detection:** `package.json` exists with a `start` script or a recognized framework dependency.

**Default version:** Node 20 (override with `.nvmrc`, `.node-version`, or `engines.node` in package.json).

**Recognized frameworks:**

| Framework              | Detection                                | Default Port |
|-----------------------|------------------------------------------|--------------|
| Next.js               | `next` in dependencies                   | 3000         |
| Nuxt                  | `nuxt` in dependencies                   | 3000         |
| SvelteKit             | `@sveltejs/kit` in dependencies          | 3000         |
| Vite                  | `vite` in dependencies                   | 4173         |
| Create React App      | `react-scripts` in dependencies          | 3000         |
| Vue CLI               | `@vue/cli-service` in dependencies       | 8080         |
| Angular               | `@angular/cli` or `@angular/core` in dependencies | 4200         |
| Generic Node          | `start` script in package.json          | 3000         |

**Package managers:** npm, yarn, and pnpm are supported. OpenBerth detects the lock file and uses the correct installer.

## Python

**Detection:** Any of these files: `requirements.txt`, `pyproject.toml`, `Pipfile`, `setup.py`, `setup.cfg`, `app.py`, `main.py`, `manage.py`.

**Default version:** Python 3.12 (override with `.python-version`, `requires-python` in pyproject.toml, or `runtime.txt`).

**Recognized frameworks:**

| Framework              | Detection                                | Default Port |
|-----------------------|------------------------------------------|--------------|
| Django                | `manage.py` exists                       | 8000         |
| FastAPI               | `fastapi` in requirements/pyproject      | 8000         |
| Flask                 | `flask` in requirements/pyproject       | 8000         |
| Generic Python        | `app.py` or `main.py` exists            | 8000         |

## Go

**Detection:** `go.mod` exists.

**Default version:** Go 1.22 (reads the `go` directive from go.mod).

**Build:** `CGO_ENABLED=0 go build` produces a static binary. Runtime uses a minimal `debian:bookworm-slim` image.

**Default port:** 8080. Use the `PORT` environment variable in your code.

## Static HTML

**Detection:** `index.html` exists (and no other language matched first).

Served directly by Caddy (Alpine). No build step. Supports the `/_data/*` REST API for storing data without a backend.

## Single-file deploy

The CLI can deploy individual files directly — no project setup needed. These are scaffolded client-side into full projects before uploading:

| Extension | What happens                                               |
|-----------|-----------------------------------------------------------|
| `.jsx`, `.tsx` | Scaffolded into a Vite + React project with Tailwind CSS |
| `.vue`    | Scaffolded into a Vite + Vue project with Tailwind CSS   |
| `.svelte` | Scaffolded into a Vite + Svelte project with Tailwind CSS |
| `.html`   | Deployed as static HTML                                   |
| `.md`     | Rendered to a styled static HTML page                     |
| `.ipynb`  | Rendered to a static HTML page with code cells and outputs  |

Usage: `berth deploy notes.md` or `berth deploy analysis.ipynb`. The scaffolder parses imports to detect npm dependencies and detects Tailwind from class names.

## Overriding detection with .berth.json

If auto-detection picks the wrong framework or your project uses a framework OpenBerth doesn’t recognize, you can override detection by adding server-side fields to your `.berth.json` file:

| Field       | What it does                                                  |
|-------------|--------------------------------------------------------------|
| `language`  | Forces language provider: `node`, `python`, `go`, or `static`|
| `build`     | Overrides the build command                                   |
| `start`     | Overrides the production start command                        |
| `install`   | Overrides the dependency install command                      |
| `dev`       | Overrides the dev server command (sandbox mode)             |

**Two modes:**

- **Patch mode** — Detection succeeds but you want to change specific commands. Just add the fields you want to override and they’ll be applied on top of the detected result.
- **Fallback mode** — Detection fails entirely. Provide at least `language` and `start`, and OpenBerth will construct a working configuration from language defaults plus your overrides.

These fields coexist with CLI fields (`name`, `ttl`, `memory`, `port`, etc.) in the same `.berth.json` file. The CLI reads its fields client-side; the server reads the override fields server-side from the uploaded code.
