# Angular Hexagonal

> Hexagonal/clean architecture for Angular with domain layer (branded IDs, readonly interfaces, pure functions), application layer (QueryBase, UseCaseBase, DTOs, Mappers), infrastructure layer (API clients, repositories), and presentation layer. Use when structuring modules, understanding layer boundaries, working with Result<T>, branded types, or creating files in domain/application/infrastructure…

- **Type:** Skill
- **Install:** `agentstack add skill-cuongtl1992-vibe-skills-angular-hexagonal`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [cuongtl1992](https://agentstack.voostack.com/s/cuongtl1992)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [cuongtl1992](https://github.com/cuongtl1992)
- **Source:** https://github.com/cuongtl1992/vibe-skills/tree/main/skills/frontend/angular-hexagonal

## Install

```sh
agentstack add skill-cuongtl1992-vibe-skills-angular-hexagonal
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Hexagonal Architecture for Angular

Four-layer architecture: Domain → Application → Infrastructure → Presentation.

## Layer Dependency Rules

| Layer          | Can Depend On       | Contains                                                  |
| -------------- | ------------------- | --------------------------------------------------------- |
| Domain         | Nothing             | Branded IDs, interfaces, pure functions, repository ports |
| Application    | Domain              | QueryBase, UseCaseBase, DTOs, Mappers                     |
| Infrastructure | Domain, Application | API clients, repository impls, providers                  |
| Presentation   | Application         | Pages, components, state services, routes                 |

## Domain Layer — Plain Interfaces + Functions

```typescript
// Branded Types for type-safe IDs
export type EntityId = number & { __brand: 'EntityId' };
export const EntityId = (value: number) => value as EntityId;

// Readonly Interface
export interface Entity {
  readonly id: EntityId;
  readonly name: string;
  readonly isActive: boolean;
}

// Factory Function → Result
export function createEntity(params: CreateEntityParams): Result {
  if (!params.name?.trim()) return Result.failure('Name is required');
  return Result.success({ id: EntityId(0), name: params.name.trim(), isActive: true });
}

// Pure Functions
export function canDeactivate(entity: Entity): boolean {
  return entity.isActive;
}
```

## Application Layer — Deep Nesting

```
application/
├── queries//get-s/get-s.query.ts
├── usecases//create-/create-.usecase.ts
├── dtos/.dto.ts
└── mappers/.mapper.ts
```

### QueryBase (reads) / UseCaseBase (writes)

```typescript
@Injectable()
export class GetEntitiesQuery extends QueryBase> {
  private readonly repository = inject(ENTITY_REPOSITORY);

  async execute(params: FilterParams): Promise>> {
    return this.repository.find(params);
  }
}
```

## Result Pattern

```typescript
Result.success(value);
Result.success(value, message);
Result.failure(errorMessage);
result.isSuccess / result.isFailure;
result.value;
result.errorMessage / result.successMessage;
```

## Mapper — Static Class

```typescript
export class EntityMapper {
  static toDomain(dto: EntityDto): Entity { ... }
  static toCreateDto(params: CreateEntityParams): CreateEntityRequest { ... }
}
```

Never `@Injectable()`. No state. No DI.

## Module File Structure

```
libs/features//src/lib/
├── domain/
│   ├── entities/.ts
│   ├── repositories/.repository.ts
│   └── index.ts
├── application/
│   ├── queries//get-s/
│   ├── usecases//create-/
│   ├── dtos/.dto.ts
│   ├── mappers/.mapper.ts
│   └── index.ts
├── infrastructure/
│   ├── api/-api.client.ts
│   ├── repositories/.repository.ts
│   ├── providers/index.ts
│   └── index.ts
└── presentation/
    ├── pages//
    ├── components/-form/
    ├── state/-list-state.service.ts
    ├── .routes.ts
    └── index.ts
```

## Barrel Exports

Every directory has an `index.ts` that re-exports its contents.

For detailed layer patterns, see [references/layer-patterns.md](references/layer-patterns.md).
For code generation workflow, see [references/code-generation.md](references/code-generation.md).

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [cuongtl1992](https://github.com/cuongtl1992)
- **Source:** [cuongtl1992/vibe-skills](https://github.com/cuongtl1992/vibe-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-cuongtl1992-vibe-skills-angular-hexagonal
- Seller: https://agentstack.voostack.com/s/cuongtl1992
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
