# SuggestionAliasController

**Kind:** Controller

**Source:** [`atloria-monorepo/apps/api/src/suggestion/suggestion.controller.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/api/src/suggestion/suggestion.controller.ts#L90)

Flat alias routes (/suggestions/...) for clients keyed by suggestionId
alone — the web app's api-client adapter (apps/web/src/lib/api-client.ts)
and the

`SuggestionAliasController` exposes flat `/suggestions/...` routes for clients that identify suggestions directly by `suggestionId`. It acts as a compatibility-oriented HTTP layer—used by the web API client adapter—and delegates suggestion operations to the existing suggestion domain/service logic rather than duplicating business rules.

## Diagram

```mermaid
graph LR
  Web[Web app API client adapter] -->|HTTP /suggestions/:suggestionId/...| Controller[SuggestionAliasController]
  Controller -->|delegates request| Service[Suggestion service / domain logic]
  Service --> Repository[Suggestion persistence]
  Repository --> DB[(Database)]
```

## Usage

```ts
// apps/web/src/lib/api-client.ts

export async function getSuggestion(suggestionId: string) {
  const response = await fetch(`/suggestions/${suggestionId}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
    },
  });

  if (!response.ok) {
    throw new Error(`Unable to load suggestion ${suggestionId}`);
  }

  return response.json();
}

// Usage from the web application
const suggestion = await getSuggestion('suggestion_123');
console.log(suggestion);
```

## AI Coding Instructions

- Keep alias routes flat and keyed by `suggestionId`, following the `/suggestions/:suggestionId/...` convention expected by the web API client adapter.
- Delegate request handling to the existing suggestion service or controller logic; do not duplicate validation, authorization, or business rules in alias endpoints.
- Preserve request and response DTO shapes used by the canonical suggestion API so clients can use alias routes without special-case parsing.
- Update `apps/web/src/lib/api-client.ts` whenever alias route paths, HTTP methods, or response contracts change.
- Validate and authorize access to the resolved suggestion before performing actions; a flat route must not bypass parent-resource access checks.

## Relationships

- MODULE_DECLARES → `list`
- MODULE_DECLARES → `create`
- MODULE_DECLARES → `accept`
- MODULE_DECLARES → `reject`
- MODULE_DECLARES → `delete`
- MODULE_DECLARES → `getById`
- DEPENDS_ON → `SuggestionService`

## Referenced By

- `SuggestionModule` (MODULE_DECLARES)
