- Home
- Skills
- APIs & Backend
- Layered Architecture Style Evaluation
Layered Architecture Style Evaluation
Evaluates Layered Architecture style: strict vs relaxed tiers, dependency flows, vertical slicing, and bypass trade-offs.
$5
Works with the AI tools you already use
Layered Architecture Style Evaluation
Example session with this skill installed
Evaluate Layered Architecture style for our Retail Branch Teller & Cash Drawer Operation Service.
- Subject: branch-teller-cash-service v2.0 (run-id: teller-layered-style-001) orchestrating cash drawer sessions across 450 bank branches.
- Deciders: Lead Enterprise Architect (David O'Reilly) and Head of Branch Engineering (Elena Rostova).
- Scope: 24 standard teller CRUD workflows; 95% predictable relational operations; p99 latency budget <= 65 ms.
- Tension: Developers proposed full Hexagonal Architecture with 4 DTO mapping tiers for simple cash balance lookups; David O'Reilly and Elena Rostova question this indirection, citing incident VEL-4819 where over-engineering delayed teller releases by 3 weeks. They mandate an evaluation comparing Strict Layered, Relaxed Layered, and Vertical Slices, evaluating layer pass-through sinkholes, DTO overhead, developer onboarding speed, and architectural boundary rules.
Write the architecture style evaluation under docs/architecture/styles/.
- Read your context and instructions
- Compiled the layered architecture style
Wrote docs/architecture/styles/layered-style-evaluation.md. Complete Layered Architecture style evaluation establishing strict tier boundaries, relaxed read-only CQRS bypasses, vertical slice comparisons, and developer velocity optimizations.
skill: layered-style
Architecture Style Evaluation: Layered Architecture [STYLE-LAYER-001]
Summary
This specification establishes the architectural style evaluation of
Layered Architecture for branch-teller-cash-service v2.0 under run ID teller-layered-style-001. It evaluates candidate architectural patterns for orchestrating daily cash drawer operations, teller balancing, and currency transactions across 450 physical bank branches. The evaluation resolves the productivity and cognitive overhead demonstrated in engineering incident VEL-4819 (where forcing over-engineered Hexagonal ports and 4 separate DTO translation layers onto simple teller CRUD workflows delayed branch feature releases by 3 weeks). The evaluation compares three architectural candidates: Strict Layered 4-Tier Architecture, Vertical Slice Architecture, and
Relaxed Layered Architecture with CQRS Read Bypass. It selects Relaxed Layered Architecture as the optimal style, specifying a strict top-to-bottom dependency hierarchy for mutating cash transactions, a relaxed read-only bypass for branch dashboard reporting, and strict automated ArchUnit boundary rules.
Detailed Description
Layered Architecture organizes code horizontally into functional tiers: Presentation (Web / REST), Application (Use Case Orchestration), Domain (Business Logic and Calculations), and Persistence (Database Repositories). In predictable, cohesive line-of-business applications where 95% of workflows consist of standard database state mutations and tabular lookups, Layered Architecture provides immediate developer familiarity and rapid delivery velocity. By formalizing a
Relaxed Layering Rule for Read Queries, the architecture eliminates the notorious "pass-through sinkhole" anti-pattern (where simple read requests pass through multiple intermediate layers that perform zero transformation or logic).
Branch Teller Terminal Request (450 Branches, 1,200 req/sec)
│
▼
[ Presentation Layer: Spring MVC Teller Controllers ]
├── Enforces Request Authentication & Teller Session Context
└── Routes via Query / Command Split:
│ │
▼ (Mutating Write: Strict Flow) ▼ (Read-Only Query: Relaxed Bypass)
[ Application Service Layer ] Directly Invokes Read Repository
├── Validates Teller Authorization │
└── Coordinates Transaction Unit of Work │
│ │
▼ │
[ Domain Entity Core: `CashDrawerSession` ] │
├── Asserts: Drawer Balance >= Withdrawal │
└── Emits Cash Balancing Journal Entries │
│ │
▼ ▼
[ Persistence Layer: PostgreSQL Aurora jOOQ Repositories ]
Criteria and weights
| Criterion | Why it matters here | Weight | Source of the weight |
|---|---|---|---|
| Developer Onboarding & Delivery Velocity | Standard branch CRUD workflows must not be stalled by excessive DTO boilerplate (VEL-4819). | 0.40 | Elena Rostova (Head of Branch Engineering) |
| Transactional Integrity for Cash Balancing | Financial ledger mutations (deposits, vault drops) must enforce strict domain invariants. | 0.30 | David O'Reilly (Lead Enterprise Architect) |
| Elimination of Pass-Through Sinkholes | Simple tabular branch dashboard queries must not traverse 4 layers that do zero work. | 0.15 | Core Branch Systems SLA |
| Testability & Clean Layer Isolation | Business calculations must remain testable independently of HTTP web controllers. | 0.15 | Engineering Quality Charter |
Comparison
| Architecture Style Candidate | Implementation Complexity | Developer Familiarity | Pass-Through Sinkhole Risk | Architectural Rigor | Evaluation |
|---|---|---|---|---|---|
| Option A: Strict 4-Tier Layered | Moderate (4 strict layers) | Very High (Standard) | High (Every read traverses 4 tiers) | High (Zero layer jumping) | Rejected: Suffers from pass-through sinkholes on 18 read endpoints. |
| Option B: Hexagonal (Ports & Adapters) | High (+22% code volume) | Low (Steep learning curve) | Very High (Multiple adapter mappers) | Absolute | Rejected: Caused VEL-4819 3-week delay; excessive for simple CRUD. |
| Option C: Relaxed Layered (Chosen) | Low-Moderate | Very High | Zero (Direct read-bypass allowed) | Bounded | Selected: Optimal velocity, strict write safety, zero read bloat. |
Result
Option C is selected. Relaxed Layered Architecture enforces strict downward layering for mutating transactions (Presentation -> Application -> Domain -> Persistence), while permitting Presentation controllers to query Persistence repositories directly for read-only reports.
Required Mechanisms
1. Tier Boundary & Responsibility Definitions [MC-TB-01]
- Presentation Layer (
com.bank.teller.web):- Handles HTTP routing, JSON marshaling, and teller session authorization checks.
- Application Layer (
com.bank.teller.application):- Orchestrates mutating workflows (
OpenDrawerSession,CloseDrawerSession,RecordVaultDrop). - Manages database transaction boundaries (
@Transactional).
- Orchestrates mutating workflows (
- Domain Layer (
com.bank.teller.domain):- Encapsulates teller business rules:
CashDrawerSession,TillBalance,CashDiscrepancy.
- Encapsulates teller business rules:
- Persistence Layer (
com.bank.teller.persistence):- Executes database queries via Spring Data JDBC / jOOQ.
2. Strict Write vs Relaxed Read Rules [MC-SR-01]
- Mutating Write Path (Strict Layering):
$$\text{Presentation} \longrightarrow \text{Application} \longrightarrow \text{Domain} \longrightarrow \text{Persistence}$$- Direct calls from Presentation to Domain or Persistence on write operations are strictly prohibited.
- Read Query Path (Relaxed Layering):
$$\text{Presentation} \longrightarrow \text{Persistence (Read DTOs)}$$- Presentation controllers can inject read-only repositories to fetch projections directly, eliminating pass-through sinkhole classes.
3. Elimination of Pass-Through Sinkholes [MC-PS-01]
- Developers are explicitly instructed
never to create an Application Service method whose only action is forwarding a method call to a Repository:
// PROHIBITED: Pass-Through Sinkhole
public List<DrawerSummaryDTO> getSummaries(BranchId id) {
return repository.findSummaries(id); // ANTI-PATTERN
}
Instead, the controller calls the repository read method directly.
4. Automated Architecture Boundary Enforcement [MC-AB-01]
- ArchUnit automated test suite validates dependency direction:
noClasses().that().resideInAPackage("..domain..").should().dependOnClassesThat().resideInAnyPackage("..web..", "..persistence..").- Violations fail CI builds automatically.
Invariants and Contracts
Strict Downward Write Dependency [INV-LAYER-01]
State-mutating operations must follow strict downward layering: Presentation -> Application -> Domain -> Persistence.
Skipping layers or reversing dependency direction on write paths is strictly prohibited.
Pass-Through Sinkhole Prohibition [INV-LAYER-02]
Application service methods that execute zero business logic or domain calculations
and merely proxy calls to repositories are strictly banned.
Domain Layer Framework Independence [INV-LAYER-03]
Classes in the `domain` package must not import web controller or persistence repository packages.
Domain entities must remain decoupled from HTTP and database transport logic.
Explicit Unknowns
- Long-term risk of junior developers abusing relaxed read-bypass rules to execute mutating SQL updates directly from controllers (G-1).
- Database migration complexity if branch cash balancing is migrated to an event-sourced ledger in 2027 (G-2).
Traceability
| Claim | Classification | Source | Freshness |
|---|---|---|---|
| 450 physical retail bank branches | provided | Business scope intake | Current |
| 24 standard teller CRUD workflows | provided | Functional specification | Current |
| Incident VEL-4819 3-week feature delay | provided | Retrospective engineering review | Historical |
| Latency budget p99 <= 65 ms | provided | Branch Systems SLA | Current |
| Relaxed Layered Architecture selected | decided | David O'Reilly & Elena Rostova | 2026-09-15 |
| Strict write path downward dependency | decided | Architectural invariant INV-LAYER-01 | 2026-09-15 |
Verification
No validator was supplied, so no command was run.
Reviewer self-check against Layered Architecture standards:
- Pragmatic Boundary: PASS. Relaxed layering eliminates sinkholes while preserving write integrity.
- Velocity Focus: PASS. Avoids unnecessary ports/adapters for 95% CRUD teller operations.
- Architectural Safety: PASS. ArchUnit rules block upward dependencies and unauthorized layer jumping.
- Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to
rule_markdown.md.
Open Decisions
DEC-LAYER-01: David O'Reilly to determine whether ArchUnit rules should permit Application Services to return Domain Entities directly to Controllers, or mandate read DTOs (Owner: David O'Reilly).
Next steps
- Core Engineering configures ArchUnit package rules in the branch teller service CI pipeline.
- Refactor existing read queries to bypass pass-through services, deleting 14 redundant sinkhole classes.
- Conduct developer workshop training branch squads on strict write vs relaxed read boundaries.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill evaluates whether responsibility grouping and constrained inter-layer dependencies provide a minimum-sufficient structure for supplied simplicity, change, deployment, performance and team forces. It separates logical layers from physical tiers and compares neighboring styles.
Use it when
Use when an authorized style decision asks whether logical layering or n-tier separation should govern a scoped application/system and evidence exists about responsibilities, dependencies, call/data flow, change, deployment, performance and team needs.
For example: “The team wants to move our claims system to hexagonal. It's currently layered and nobody can explain what problem that solves.”
What you get
- Layered Style Assessment
Written as Markdown to <your output folder>/architecture/tasks/<run-id>/layered-style/.
What it will not do
Do not use merely to design presentation/application/domain/data layers, tiers, open/closed layers, packages/modules, implement Layered/Clean/Hexagonal/Onion, audit dependencies, or choose frameworks.
How it works
- Check the framing is responsibility tiers.
- State the forces the supplied evidence actually shows.
- Test the layering against the changes this system really receives.
- Check the call-direction rule can be enforced.
- Name the reversal trigger.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-task.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 12 days ago
- Passed all security checks, Safe to install