Skip to content
Back to skills

Layered Architecture

ASecurity

Layered architecture patterns for separating presentation, application, domain, and data layers.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 9, 2026
ai-agentstypescriptgoapidatabasebackend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned October 9, 2026

npx -y skills add alisattorov06/ali-kiro --skill layered-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Layered Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Layered Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alisattorov06-layered-architecture/badge)](https://www.skillsdirectory.com/skills/alisattorov06-layered-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: layered-architecture
description: Layered architecture patterns for separating presentation, application, domain, and data layers.
origin: FlowDeck
---

# layered-architecture

## When to Activate
When building traditional monolithic or client-server applications where clear vertical separation of concerns improves maintainability (e.g., MVC applications, REST APIs, data-driven apps).

## Steps
1. **Identify natural layers** - Determine the distinct vertical tiers based on responsibility (e.g., presentation, business logic, data access).
2. **Define layer responsibilities** - Establish clear contracts for what each layer can and cannot depend on.
3. **Implement top-down dependencies** - Higher layers (presentation) depend on lower layers (data), but never vice versa.
4. **Create layer interfaces** - Use interfaces or abstract classes to define how adjacent layers communicate.
5. **Enforce layer access rules** - Use module visibility, package private, or architectural linting tools to prevent cross-layer pollution.
6. **Keep thin layers** - Avoid bloating any single layer; if the business logic layer grows large, consider extracting domain objects.

## Examples
```typescript
// Presentation Layer - Controllers/Handlers
class OrderController {
  constructor(private readonly orderService: OrderService) {}

  async createOrder(req: Request, res: Response): Promise<void> {
    const order = await this.orderService.createOrder(req.body)
    res.status(201).json(order)
  }
}

// Business Logic Layer - Services
class OrderService {
  constructor(
    private readonly orderRepository: OrderRepository,
    private readonly paymentGateway: PaymentGateway
  ) {}

  async createOrder(data: CreateOrderDto): Promise<Order> {
    const order = new Order(data.items)

    if (data.paymentMethod === 'prepaid') {
      await this.paymentGateway.charge(order.total, data.paymentToken)
    }

    return this.orderRepository.save(order)
  }
}

// Data Access Layer - Repositories
interface OrderRepository {
  save(order: Order): Promise<void>
  findById(id: string): Promise<Order | null>
  findByCustomer(customerId: string): Promise<Order[]>
}

class PostgresOrderRepository implements OrderRepository {
  constructor(private readonly db: Database) {}

  async save(order: Order): Promise<void> {
    await this.db.query('INSERT INTO orders (...) VALUES (...)', order.toDbFormat())
  }
}
```

## Related Skills
- clean-architecture
- hexagonal-architecture
- ddd-architecture
- backend-patterns

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.