---
url: /saas-starter/v0.9.0/guide/overview.md
---
# ApiHost

::: tip One page for every option
This page covers every choice of `--Persistence`, `--Auth`, `--IncludeTests` and `--Aspire`.
A label says which options a part is for; the copy in your app's `docs/` folder has only yours.
`ApiHost` stands for your app's name.
:::

::: info Marten
A full-stack app: a [Wolverine](https://wolverinefx.net/) API on ASP.NET Core and a React frontend
(Vite, TypeScript, Tailwind CSS and [shadcn/ui](https://ui.shadcn.com/) components).
Data lives in PostgreSQL through [Marten](https://martendb.io/).
In production the API also serves the built React app, so it deploys as one service.
:::

::: info EF Core
A full-stack app: a [Wolverine](https://wolverinefx.net/) API on ASP.NET Core and a React frontend
(Vite, TypeScript, Tailwind CSS and [shadcn/ui](https://ui.shadcn.com/) components).
Data lives in PostgreSQL through EF Core.
In production the API also serves the built React app, so it deploys as one service.
:::

## Run it

::: info Without Aspire
You need the .NET 11 SDK, Node.js 22.22 or later, and Docker with the Compose plugin.
:::

::: info With Aspire
You need the .NET 11 SDK, Node.js 22.22 or later, and Docker with the Compose plugin.

**With Aspire**, one command starts the database, the API and the dev server, and opens a
dashboard with their logs and traces ([how](./how-to/run-with-aspire.md)):

```bash
cd src/Client && npm install && cd ../..
dotnet run --project src/ApiHost.AppHost        # then open http://localhost:5173
```

Or start each part yourself:
:::

```bash
docker compose up -d                  # PostgreSQL on localhost:5432
dotnet run --project src/ApiHost        # the API on http://localhost:5133
```

In a second terminal:

```bash
cd src/Client
npm install
npm run dev                           # open http://localhost:5173
```

::: info With accounts
The Vite dev server forwards `/api` (including the SignalR WebSocket) to the API, so the browser
only talks to one origin. If something doesn't start, see [Troubleshooting](./troubleshooting.md).

Log in as **demo@example.com** / **Demo123!**. This user is created at startup in Development
only, is an admin (so `/admin` works), and the dev server pre-fills the login form with it. Change it under `DevelopmentUser` in
`src/ApiHost/appsettings.Development.json` and in `src/Client/.env.development`.

`docker compose up -d` also starts [Mailpit](https://mailpit.axllent.org/), which catches every
email the app sends in Development (confirmation, password reset, invitations): read them at
http://localhost:8025. New accounts must confirm their email before they can log in; the demo
user is already confirmed.
:::

::: info Without accounts
The Vite dev server forwards `/api` (including the SignalR WebSocket) to the API, so the browser
only talks to one origin. If something doesn't start, see [Troubleshooting](./troubleshooting.md).
:::

To try the API without the UI, open `src/ApiHost/ApiHost.http` in Visual Studio, Rider, or VS Code
with the REST Client extension, and run the requests in order. Or browse the interactive API
reference at http://localhost:5133/scalar (Development only), generated from the OpenAPI document
at `/openapi/v1.json`.

## Project layout

```
src/ApiHost/
  Program.cs              All wiring: Wolverine, persistence, validation, SignalR, auth                                        (With accounts)
  Program.cs              All wiring: Wolverine, persistence, validation, SignalR                                              (Without accounts)
  Features/Todos/         The example feature: endpoints, messages, handler, model
  Features/Auth/          Log in (password, Google/GitHub, passkey, two-factor code), register, confirm email, reset password  (With accounts)
  Features/Account/       The signed-in user: profile, password, sign-in methods, passkeys, two-factor, delete account         (With accounts)
  Features/Admin/         Admin endpoints: users, roles, locks and invitations                                                 (With accounts)
  Features/Organisations/ Organisations: switching, members and roles, invitations, joining                                    (With organisations)
  Organisations/          The organisation model, its store, and choosing a session's organisation                             (With organisations)
  Realtime/AppHub.cs      SignalR hub that pushes messages to browsers
  Storage/                File storage (IFileStorage): local disk, S3-compatible or Azure Blob
  Analytics/              Google Tag Manager settings, for the client's cookie banner
  Data/Marten/            Marten setup: event store, projections, indexes                                                      (Marten)
  Data/EfCore/            AppDbContext, migrations, and migrate-on-startup                                                     (EF Core)
  Identity/               Users, JWT and refresh tokens, roles, lockout, two-factor, rate limits (used by the features)        (With accounts)
  Identity/Email/         Account emails: messages, their handler, and the SMTP sender (MailKit)                               (With accounts)
  Identity/External/      Google and GitHub set-up, and linking a provider's account to a user                                 (With accounts)
  Identity/Passkeys/      Passkey set-up (Identity's WebAuthn support)                                                         (With accounts)
src/ApiHost.AppHost/      Aspire AppHost: starts everything for development, with the dashboard                                (With Aspire)
src/Client/src/
  root.tsx, App.tsx       The HTML document (with the description and link-preview tags), and the page frame
  routes.ts, routes/      Each URL and the route module for its page, with the page's title
  pages.ts                Every page's path, and which are public: pre-rendered, and in sitemap.xml
  components/             Layout (header, navigation, footer), home page, not-found page
  features/todos/         Todo page, TanStack Query hooks, SignalR hook (useTodoRealtime)
  features/auth/          Login, register, email confirmation and password reset pages, route guards                           (With accounts)
  features/account/       Settings page and the header's user menu                                                             (With accounts)
  features/admin/         Admin page (/admin): users, roles, locks and invitations                                             (With accounts)
  features/organisations/ The organisation switcher, /organisation (members, invitations) and /join                            (With organisations)
  lib/api/                Typed API client generated from the OpenAPI document
  test/                   Unit test setup: the fake API (MSW) and render helpers
docs/                       Documentation and how-to guides
deploy/                     Production docker-compose, Caddy, and a server guide
tests/ApiHost.Tests/        Integration tests against a real PostgreSQL                                                        (With the tests)
tests/e2e/                  End-to-end tests in a real browser (Playwright)                                                    (With the tests)
```

## Documentation

The [docs](./index.md) folder explains how the app works and how to change it:

* [Architecture](./architecture.md): the patterns the Todo example shows, and how to copy them.
* &#x20; [Accounts](./accounts.md): sign-in, emails, settings, lockout, roles and the admin page, Google/GitHub, passkeys and two-factor authentication. Organisations, their members and invitations are there too.
* &#x20; [Integrations](./integrations.md): API keys, the MCP endpoint for AI assistants, webhooks and secrets.
* &#x20; [Accounts](./accounts.md): sign-in, emails, settings, lockout, roles and the admin page, Google/GitHub, passkeys and two-factor authentication.
* [File storage](./file-storage.md): uploads to local disk, any S3-compatible store (AWS, R2,
  B2, Google Cloud Storage, self-hosted) or Azure Blob Storage.
* [Analytics and cookie consent](./analytics.md): Google Tag Manager behind a consent banner.
* [Security](./security.md): every protection the app has, and a checklist for deploying.
* [Testing](./testing.md), [Observability](./observability.md) and
  [Deployment](./deployment.md) (with all the production settings).
* [Tutorial: build a feature](./tutorial.md): a Contacts feature from start to finish.
* How-to guides:
  * [Add a feature: the checklist](./how-to/add-a-feature.md)
  * [Put Cloudflare in front](./how-to/put-cloudflare-in-front.md)
  * &#x20;[Change the database schema](./how-to/add-a-migration.md)
  * &#x20;[Send email through your email provider](./how-to/configure-email.md)
  * &#x20;[Set up Google and GitHub sign-in](./how-to/set-up-external-sign-in.md)
  * &#x20;[Add a role](./how-to/add-a-role.md) and [make someone an admin](./how-to/make-an-admin.md)
  * &#x20;[Change the JWT signing key](./how-to/rotate-the-signing-key.md)

## Common tasks

| Task | Command |
|---|---|
|  Run the API tests (Docker must be running) | `dotnet test` |
| Run the client's unit tests | `npm test` in `src/Client` |
|  Run the end-to-end tests ([how](./testing.md#end-to-end-tests)) | `npm test` in `tests/e2e`, with the app running |
| Update the client's API types | `npm run gen:api` in `src/Client`, with the API running |
| Lint the client | `npm run lint` in `src/Client` |
|  Add a database migration ([how](./how-to/add-a-migration.md)) | `dotnet ef migrations add <Name> --project src/ApiHost --output-dir Data/EfCore/Migrations` |
| List the app's command-line tools (code generation, database, diagnostics) | `dotnet run --project src/ApiHost -- help` |
| Publish for production ([deployment](./deployment.md)) | `dotnet publish src/ApiHost -c Release -o publish` |

## Created from a template

This project was created from the
[LibreSharp SaaS Starter](https://github.com/LibreSharp/saas-starter)
(`dotnet new saas-starter`). Its [documentation](https://libresharp.github.io/saas-starter/latest/)
has these guides for every option, and how to
[upgrade this app](https://libresharp.github.io/saas-starter/latest/upgrading/) to a newer version:
newer template versions (`dotnet new update`) affect new projects only, not this one.
`.saas-starter.json` records the template version and options this app was created with, for
upgrading. See the repository for the roadmap and issues. You can delete this section (but keep
`.saas-starter.json`).
