---
url: https://rustrak.dev/reference/contributing/
---

# Contributing

How to set up Rustrak locally and get a change merged.

## Setup

### Prerequisites

- Rust through `rustup`. The version is pinned in `rust-toolchain.toml` (1.98), and `rustup` installs it on the first `cargo` command
- Node.js 22.18 or later
- pnpm 12
- Docker, optional: only for PostgreSQL or to build images

### Clone and install

```bash
git clone https://github.com/rustrak/rustrak.git
cd rustrak
pnpm install
```

### Start development

```bash
# Run the server on :8080, with SQLite. The .env keeps the database and
# source maps inside the checkout instead of /data.
cd apps/server && cp .env.example .env && cargo run

# Run the dashboard on :3000, proxying the API to :8080 (separate terminal)
cd apps/dashboard && pnpm dev
```

The server uses SQLite unless told otherwise. To work against PostgreSQL:

```bash
docker compose -f docker-compose.dev.yml up -d postgres
cd apps/server && DATABASE_URL=postgres://rustrak:rustrak@localhost:5432/rustrak \
  cargo run --no-default-features --features postgres
```

To have the server itself serve the dashboard, as it does in production, run
`pnpm build --filter=@rustrak/server` from the root: it builds the dashboard,
copies it to `apps/server/static` with `scripts/bundle-dashboard.sh`, and
builds the server.

## Project structure

```
rustrak/
├── apps/
│   ├── server/         # Rust server: API, ingest, MCP, and the dashboard from static/
│   ├── dashboard/      # React SPA, compiled into apps/server/static
│   └── docs/           # Documentation site
├── packages/
│   ├── ui/             # Design system
│   ├── client/         # TypeScript API client
│   ├── test-sentry/    # CLI that sends test events
│   └── benchmarks/     # Load and throughput benchmarks
├── scripts/
│   └── bundle-dashboard.sh   # copies the dashboard build into apps/server/static
└── docker-compose.yml
```

## Workflow

### Branches

- `main`: stable releases
- `next`: pre-releases
- `feat/*`, `fix/*`, `docs/*`: your work, branched from `main`

### Commits

Use conventional commits, in English:

```
feat: archive issues from the list
fix: count rate-limited events once
docs: document user feedback
```

A change users will notice comes with a changeset (`pnpm changeset`). Name `@rustrak/server`; the client and dashboard follow, since all three share one version.

### Pull requests

1. Branch from `main`
2. Make the change, with its tests
3. Run `pnpm run ci`, which runs what CI runs
4. Open the pull request

## Server (Rust)

### Tests

```bash
cd apps/server
cargo test
```

### Style

```bash
cargo fmt
cargo clippy
```

### Migrations

Each backend has its own set, in `migrations/sqlite` and `migrations/postgres`. Add a migration to both:

```bash
sqlx migrate add -r --source migrations/sqlite description
sqlx migrate add -r --source migrations/postgres description
```

The server runs pending migrations at startup.

## Dashboard

React 19, TanStack Router and Vite. It compiles to static files that the Rust
server hands out, so there is no Node process in production: `pnpm dev` runs
Vite on `:3000` and proxies the API prefixes to the server, which is the same
one-origin arrangement production has.

### Tests

```bash
cd apps/dashboard
pnpm test
pnpm lint
```

### Strings and translations

Every user-facing sentence lives in `src/shared/i18n/messages/`, one JSON dictionary per locale, and nowhere else. A new string goes into **all six** dictionaries, and is read through a translator rather than written inline.

Dates, numbers and percentages are never formatted by hand. `toLocaleString()` and a bare `Intl` formatter use the browser's locale rather than the one the reader chose in Rustrak. Use `use-intl`'s `useFormatter` with one of the named formats in `src/shared/i18n/config.ts`. The architecture suites fail the build on all of this.

### Adding a language

The server needs no change: it accepts any well-formed language tag, so a locale is added entirely in the dashboard.

1. Copy `src/shared/i18n/messages/en.json` to your locale's tag, for example `fr.json`, and translate the values. Keep every key: a missing one renders as the raw key, not as English
2. Add the language's name, written in that language, under `locale` in every dictionary, the new one included: the language selector reads it from there
3. Add the tag to `LOCALES` in `src/shared/i18n/config.ts`
4. Add a loader for the dictionary to `CATALOGUES` in `src/shared/i18n/intl.ts`
5. Add the dictionary to `OTHER_LOCALES` in `src/__tests__/architecture/message-keys.test.ts`, which holds every locale to the same keys as English
6. Add the tag to `LOCALES` in `packages/plugin/src/messages.ts`, so plugin authors are warned when it is missing
7. Run `pnpm test`

## Documentation

### Run locally

```bash
pnpm dev:docs   # http://localhost:3001
```

### Add pages

1. Create `.mdx` in `content/`
2. Add to `_meta.js`
3. Link from related pages

## Getting help

Report a bug or ask a question in [GitHub issues](https://github.com/rustrak/rustrak/issues).
