# Repository layout

> What each folder and top-level file of the Visto AI repository holds, from the review engine to the UI, the evals and the docs.

Web page: https://visto-ai.com/docs/repository-layout/

A map of the repository, for finding your way before a change. The service's code is under `src/`, the web UI under `ui/`, and the rules the model is given under `contract/`.

## The service

| Path | What it holds |
|---|---|
| `src/main.ts`, `src/service.ts` | Starting and stopping the service: reading the config, the instance lock, migrations, the settings sync, the job lanes and the HTTP listener. |
| `src/config` | Loading and validating the configuration, and the part of it the UI can edit. |
| `src/engine` | The review engine: building the context, the model call, the checks on the answer, and rendering the review. |
| `src/engine/score` | Blocks, the rules that score without the model, and the floors from `.visto-ai.yml`. |
| `src/engine/scorer` | The optional second scorer and its client. |
| `src/forge` | The boundary to git services. `src/forge/github` holds the GitHub sources, the webhook reader, the writer that posts, and `npm run app:create`. |
| `src/shell` | Around the engine: receiving a webhook, the queue of review jobs, running, publishing and following up a review, the daily spend limit and the model's health, alerts, the learning pass and the nightly lessons judge, and the health of extension modules, MCP servers and memory. |
| `src/gate` | The merge gate: which pull requests are gated, the check it writes, and the `/done` and skip commands. |
| `src/approval` | Automatic approval: which threads are closed for it, the decision, the audit sample's draw, its texts, and the withdrawal job. |
| `src/memory` | The memory rules the service and the evals share: signals from comments, what a review is shown, lessons and their judge, reverts, and reading a time. |
| `src/extensions` | The contract of an extension module, its loader and its time limit. |
| `src/mcp` | The MCP client: an event-stream reader, JSON-RPC over Streamable HTTP, and a session that lists and calls tools. |
| `src/db` | The Postgres client, the migrations and every table's statements. |
| `src/ui` | The UI's server side: serving the built files, sign-in through GitHub and by password, sessions, accounts, the JSON API and its answer types (`api-types.ts`, the one file the frontend reads). `npm run accounts` (`accounts-cli.ts`) makes the first admin and is the way back in. |

## The evals

| Path | What it holds |
|---|---|
| `src/eval` | The `replay` and `compare` commands, the plain control, and the entry point of every `eval:*` script (`cli.ts`). |
| `src/eval/history` | `import-history` and the history file it writes; `seed.ts`, the writes of `seed-memory`. |
| `src/eval/backtest` | `backtest`, `score-noise`, `memory-count` and `score-compare`: labels, Safety, Benefit and Focus, noise, and memory as of each case. |
| `src/eval/lessons` | The evals' lessons: `export-findings` (with `seed-memory` and the CLI, the only eval code that reaches a database), the nights over an export, the judge's kept answers, the lessons file, and `lesson-cases`. |
| `src/eval/judge` | `judge`: matching findings to reference comments, and recall, precision and F1. |
| `src/eval/aacr` | `import-aacr`: turning AACR-Bench into a case file and a history file. |
| `src/eval/live` | The same measure on stored data, for the UI's Repositories page. |

## Everything else

| Path | What it holds |
|---|---|
| `ui` | The web UI, a package of its own with its own lock file: React, Vite and Tailwind CSS, its components, pages and tests. `npm --prefix ui run build` writes `ui/dist`, which the service serves. |
| `contract` | The rules the model is given: the review contract and its twin for the second scorer. |
| `examples` | An example extension module. |
| `test` | The test setup that blocks the network, and checks of the repository's boundaries and of this guide. |
| `docs/guide` | This guide. [Extension contract](https://visto-ai.com/docs/extension-contract/) states the contract an extension module is written against. |
| `docs/benchmarks` | Benchmark write-ups, one per run (see [Benchmark](https://visto-ai.com/docs/benchmark/)). |
| `docs/superpowers` | Design notes and implementation plans. |
| `.github` | CI, the conventional-commit check and the release workflow. |
| `config.example.yml`, `env.example` | The documented configuration and environment to copy (see [Configuration](https://visto-ai.com/docs/configuration/)). |
| `compose.yaml`, `Dockerfile` | Running the service and Postgres with Docker Compose, and building the image (see [Running the service](https://visto-ai.com/docs/running-the-service/)). |
