# Development (/docs/development)

## Run it locally [#run-it-locally]

You need Node 24 or newer, [pnpm](https://pnpm.io) and the
[Turso CLI](https://docs.turso.tech/cli), which serves the local database.

```sh
pnpm install
cp apps/goatside/.env.example apps/goatside/.env.local   # then fill it in
pnpm dev          # local DB on :8080, app on :3000, this site on :3001
pnpm db:migrate   # first run, and after schema changes
```

Sign in at [localhost:3000](http://localhost:3000) with the `GOATSIDE_USERNAME` and
`GOATSIDE_PASSWORD` from your `.env.local`. Locally, AI needs an `AI_GATEWAY_API_KEY`
from the AI Gateway dashboard. Without one, entries save uncategorized.

## Repo layout [#repo-layout]

| Path            | What                                                                               |
| --------------- | ---------------------------------------------------------------------------------- |
| `apps/goatside` | The app you self-host, on TanStack Start, deployed to Vercel                       |
| `apps/web`      | This site, the landing page and these docs, built with Fumadocs                    |
| `packages/core` | The entry parser, account matching, money and dates, in plain TypeScript           |
| `packages/db`   | The Drizzle schema and migrations for Turso                                        |
| `packages/auth` | Sign-in for the one account, with credentials from env and a signed session cookie |
| `packages/ai`   | The agent's logic for categories, people, accounts and questions                   |
| `packages/ui`   | shadcn/ui components on Base UI, the coin brand, theme and styles                  |

## Commands [#commands]

```sh
pnpm typecheck
pnpm test         # vitest
pnpm lint         # oxlint
pnpm format       # oxfmt
pnpm db:generate  # new migration after editing packages/db/src/schema
pnpm db:studio    # browse the local DB
```

`pnpm install` sets up a pre-commit hook with [lefthook](https://lefthook.dev). It formats
the files you stage with oxfmt and lints them with oxlint, so a commit with a lint warning
stops. To skip it once, commit with `--no-verify`.

Sample data and evals:

```sh
# 3 months of sample data into a separate local DB (local URLs only)
TURSO_DATABASE_URL=http://127.0.0.1:8090 pnpm --filter @workspace/db demo

# live accuracy evals for categorizing (needs AI_GATEWAY_API_KEY)
pnpm --filter @workspace/ai eval

# chat agent scenarios against a local demo DB (writes to it)
TURSO_DATABASE_URL=http://127.0.0.1:8090 pnpm --filter app eval:ask
```

Add shadcn components from an app directory. The CLI installs them into `packages/ui`:

```sh
pnpm dlx shadcn@latest add drawer -c apps/goatside
```

## Writing these docs [#writing-these-docs]

The docs are MDX files in `apps/web/content/docs`. [Fumadocs](https://fumadocs.dev)
renders them on TanStack Start. Each folder's `meta.json` sets the order in the sidebar.
The site also serves every page as Markdown at its URL plus `.md`, and the whole set at
[`/llms.txt`](/llms.txt) and [`/llms-full.txt`](/llms-full.txt).
