> ## Documentation Index
> Fetch the complete documentation index at: https://dev-doc.dualmindlab.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Development Workflows

> Git workflow, testing strategy, and deployment process for DualMind Lab.

## Git workflow

DualMind Lab uses a simple branch-based workflow across all three repositories.

### Branch strategy

| Branch      | Purpose                                       |
| ----------- | --------------------------------------------- |
| `main`      | Production-ready code, deployed automatically |
| `feature/*` | New features (branch from `main`)             |
| `fix/*`     | Bug fixes                                     |
| `dev`       | Integration branch (optional)                 |

### Commit conventions

Use descriptive commit messages:

```text filename="Commit message format" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
feat: add streaming support for dual chat
fix: resolve FK violation on thread creation
refactor: extract model selection into service
docs: update API reference for voting endpoint
```

## Testing

### Backend tests

Located at `tests/DualMind.API.Tests/`:

```bash filename="Terminal" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
cd DualMind_Back
dotnet test
```

Test files:

* `SmokeTests.cs` — basic endpoint connectivity
* `UnitTest1.cs` — unit tests

### Frontend linting

```bash filename="Terminal" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
cd DualMind_UI
npm run lint        # Check for issues
npm run lint:fix    # Auto-fix
```

### Manual API testing

Use the Swagger UI at `/swagger` or curl:

```bash filename="API Testing (cURL)" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
# Health check (no auth)
curl http://localhost:5079/health

# Single chat (requires JWT)
curl -X POST http://localhost:5079/api/arena/chat \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello, world!"}'

# Dual chat
curl -X POST http://localhost:5079/api/arena/dualchat \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Explain AI", "selectionMode": "random"}'
```

## Deployment process

### Backend (Azure)

The backend deploys to Azure App Service via GitHub Actions:

```yaml filename=".github/workflows/master_dualmind-arena.yml" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
# Triggers on push to main
# Builds .NET 8 app
# Deploys to Azure App Service
```

### Frontend (Cloudflare Workers)

```bash filename="Terminal" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
cd DualMind_UI
npx wrangler deploy
```

### Admin panel (Cloudflare Workers)

```bash filename="Terminal" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
cd DualMind_Admin-UI
npm run deploy       # staging
npm run deploy:prod  # production
```

## Adding a new API endpoint

1. Create or update a controller in `Controllers/`
2. Add route attribute: `[Route("api/your-route")]`
3. Add HTTP method attribute: `[HttpGet]`, `[HttpPost]`, etc.
4. Add `[Authorize]` if auth required, `[AllowAnonymous]` if public
5. Inject required services via constructor
6. Add request/response models in `Core/Models/` if needed
7. Register any new services in `Program.cs`
8. Test via Swagger or curl
9. Update OpenAPI spec in `docs/openapi.yaml`

## Adding a new AI provider

1. Create a new service class implementing `IChatProvider` in `AI/Providers/`
2. Implement `ChatAsync()` and `StreamAsync()` methods
3. Register the typed HttpClient in `Program.cs`
4. Add the provider case in `ChatProviderFactory.GetProvider()`
5. Add provider record to `providers` table in Supabase
6. Add API keys to `provider_api_keys` table
7. Add models using this provider to `ai_models` table
