# Getting started

> Clone the template, bring up local infrastructure, and run both the API and the frontend.

## Prerequisites

You will need the following installed:

- **.NET 10 SDK**
- **Node.js 22+** and **pnpm**
- **Docker** (for local infrastructure and the integration test suite)

## Scaffold your project

To start a real product, use the interactive scaffold script. It clones the template and renames
everything across all three apps (API, SPA and the landing site): project name, namespaces, domains,
support email and API-key prefix. It also regenerates dev and prod secrets, writes the env files and
reinitialises git:

```sh
curl -fsSL https://hub.marketingconcurrent.nl/scripts/new.sh | bash
```

It prompts for the project name and everything else it needs, with sensible defaults. Pass `--help`
to see every flag if you would rather set them on the command line.

## Or clone the template

To explore the template as-is, clone it directly:

```sh
git clone https://github.com/mchub/mchub.git
cd mchub
```

## 1. Start local infrastructure

A single Compose file brings up Postgres, Redis, RabbitMQ, MinIO, Mailpit and the full observability
stack:

```sh
docker compose up -d
```

This is everything the API depends on at runtime. The services and their ports are listed in
[project structure](/docs/project-structure#port-map).

## 2. Run the API

```sh
dotnet run --project api/src/McHub.Api
```

The API starts on `http://localhost:5076` (and `https://localhost:5077`). Its interactive OpenAPI reference is served at
`/scalar`, and applying database migrations happens automatically on start in development.

## 3. Run the frontend

```sh
cd frontend
pnpm install
pnpm dev
```

The SPA starts on `http://localhost:3003`, which matches the `Cors:AllowedOrigins` the API allows by
default.

## Verify it works

In development the API automatically seeds two accounts on first startup:

| Account | Email              | Password          | Role  |
|---------|--------------------|-------------------|-------|
| Admin   | admin@test.local   | LocalDev123!   | Admin |
| User    | user@test.local    | LocalDev123!   | User  |

Open `http://localhost:3003` and sign in with either account. The admin account has full access to
`/admin`; the user account sees the regular dashboard.

The accounts are created once (idempotent) and only in the `Development` environment. They are
skipped entirely in production.

To promote your own account to admin instead, add its email to the `Admin:AdminEmails` array in
`api/src/McHub.Api/appsettings.json`:

```json
"Admin": {
  "AdminEmails": ["you@example.com"]
}
```

Set this before you first start the API and the account is an admin the moment you register. If the
API is already running, restart it to pick up the change.

Open Grafana at `http://localhost:3010` and you will see traces and metrics already flowing for the
requests you just made.

## The fast test loop

Most of the time you want the quick unit + architecture suite, which runs in a few seconds and needs
no Docker:

```sh
dotnet test api/fast.slnf --nologo
```

The full suite, including integration tests backed by Testcontainers, runs with:

```sh
dotnet test api/mchub.slnx --nologo
```

## Next steps

- Learn the [repository layout](/docs/project-structure).
- Read the [architecture overview](/docs/architecture).
- Add your first feature by following the [vertical slice recipe](/docs/vertical-slices).
