Skip to content
designing-architecture logo

Designing Architecture

designing-architecture

Guides software architecture decisions, design patterns, and system design principles. Use when designing systems, choosing patterns, or making architectural decisions.

SKILL.md

Full skill instructions

Designing Architecture

Principles and patterns for designing maintainable, scalable, and robust software systems.

When to Use This Skill

  • Designing new systems or features
  • Choosing between architectural patterns
  • Making technology decisions
  • Reviewing system design
  • Planning for scalability
  • Refactoring legacy systems

Core Architecture Principles

SOLID Principles

PrincipleSummaryViolation Sign
Single ResponsibilityOne reason to changeClass does too many things
Open/​ClosedOpen for extension, closed for modificationModifying existing code for new features
Liskov SubstitutionSubtypes replaceable for base typesOverrides break parent behavior
Interface SegregationSmall, focused interfacesClasses implement unused methods
Dependency InversionDepend on abstractionsHigh-level modules depend on low-level

The Dependency Rule

Outer layers depend on inner layers, NEVER the reverse.

┌─────────────────────────────────────┐
│     Frameworks & Drivers           │  ← Database, Web, UI
├─────────────────────────────────────┤
│     Interface Adapters             │  ← Controllers, Presenters, Gateways
├─────────────────────────────────────┤
│     Application Business Rules     │  ← Use Cases
├─────────────────────────────────────┤
│     Enterprise Business Rules      │  ← Entities
└─────────────────────────────────────┘

Dependencies point INWARD only.

Architectural Patterns

Layered Architecture

┌─────────────────────────────────────┐
│     Presentation Layer             │  ← UI, API Controllers
├─────────────────────────────────────┤
│     Application Layer              │  ← Use Cases, Services
├─────────────────────────────────────┤
│     Domain Layer                   │  ← Business Logic, Entities
├─────────────────────────────────────┤
│     Infrastructure Layer           │  ← Database, External APIs
└─────────────────────────────────────┘

Use when: Traditional applications, clear separation needed Avoid when: High-performance needs, event-driven systems

Hexagonal Architecture (Ports & Adapters)

           ┌───────────────┐
           │   Primary     │
           │   Adapters    │  ← REST API, CLI, GraphQL
           └───────┬───────┘
                   │
        ┌──────────▼──────────┐
        │                     │
        │   ┌───────────┐     │
        │   │   Core    │     │
Primary │   │  Domain   │     │ Secondary
Ports   │   │  Logic    │     │ Ports
        │   └───────────┘     │
        │                     │
        └──────────┬──────────┘
                   │
           ┌───────▼───────┐
           │   Secondary   │
           │   Adapters    │  ← Database, Message Queue, External API
           └───────────────┘

Use when: Testability is critical, multiple interfaces needed Avoid when: Simple CRUD applications

Microservices Architecture

┌─────────┐  ┌─────────┐  ┌─────────┐
│ Service │  │ Service │  │ Service │
│    A    │  │    B    │  │    C    │
└────┬────┘  └────┬────┘  └────┬────┘
     │            │            │
     └────────────┴────────────┘
                  │
           ┌──────▼──────┐
           │   Message   │
           │    Bus      │
           └─────────────┘

Use when: Independent scaling, team autonomy, polyglot needs Avoid when: Small teams, simple domains, tight coupling required

Event-Driven Architecture

Event Source → Event Bus → Event Handlers
     │              │              │
     ▼              ▼              ▼
  Produces    Routes Events    Consumes
  Events      (Kafka, RabbitMQ)  Events

Use when: Async processing, decoupling, audit trails Avoid when: Immediate consistency required, simple workflows


Design Patterns

Creational Patterns

PatternPurposeWhen to Use
FactoryCreate objects without specifying classObject creation logic is complex
BuilderConstruct complex objects step-by-stepMany optional parameters
SingletonSingle instance globallyShared resource (use sparingly)
Dependency InjectionInject dependencies externallyTestability, loose coupling

Structural Patterns

PatternPurposeWhen to Use
AdapterConvert interface to anotherIntegrating incompatible systems
DecoratorAdd behavior dynamicallyExtending functionality without inheritance
FacadeSimplified interface to complex systemHiding complexity
RepositoryAbstract data accessSeparating domain from persistence

Behavioral Patterns

PatternPurposeWhen to Use
StrategyInterchangeable algorithmsMultiple ways to do something
ObserverNotify dependents of changesEvent systems, reactive updates
CommandEncapsulate actions as objectsUndo/​redo, queuing, logging
Chain of ResponsibilityPass request along handlersMiddleware, validation chains

Domain-Driven Design Concepts

Strategic Design

ConceptDefinitionExample
Bounded ContextExplicit boundary for a domain modelOrder context, Shipping context
Ubiquitous LanguageShared vocabulary between devs and domain experts"Order", "Line Item", "Fulfillment"
Context MapHow bounded contexts relateCustomer shared between Sales and Support

Tactical Patterns

PatternPurposeExample
EntityObject with identityUser, Order
Value ObjectObject without identityMoney, Address
AggregateCluster of entities with rootOrder + LineItems
Domain EventSomething that happenedOrderPlaced, PaymentReceived
RepositoryCollection-like access to aggregatesOrderRepository
Domain ServiceLogic that doesn't fit entitiesPricingService

System Design Considerations

Scalability Patterns

PatternDescriptionTrade-off
Horizontal ScalingAdd more instancesStatelessness required
Vertical ScalingBigger machinesHardware limits
CachingStore computed resultsCache invalidation
Database ShardingSplit data across DBsQuery complexity
Read ReplicasSeparate read/​writeEventual consistency
CDNEdge content deliveryStatic content only

Resilience Patterns

PatternPurposeImplementation
Circuit BreakerPrevent cascade failuresFail fast when downstream is down
Retry with BackoffHandle transient failuresExponential delay between retries
BulkheadIsolate failuresSeparate thread pools per dependency
TimeoutBound waiting timeMax wait for responses
FallbackGraceful degradationDefault behavior when service unavailable

Data Consistency Patterns

PatternConsistencyUse When
ACID TransactionsStrongFinancial data, critical operations
SagaEventualDistributed transactions
Event SourcingEventualAudit trails, complex state
CQRSEventualDifferent read/​write models

Technology Decision Framework

When to Use a Database

NeedRecommendedAvoid
Relational data, ACIDPostgreSQL, MySQLMongoDB
Document storage, flexible schemaMongoDB, DynamoDBRelational
Key-value, high speedRedis, MemcachedRelational
Time seriesInfluxDB, TimescaleDBGeneric SQL
Graph relationshipsNeo4j, NeptuneRelational (for complex)
SearchElasticsearch, MeilisearchFull table scans

When to Use Message Queues

NeedPattern
Async processingQueue (SQS, RabbitMQ)
Event broadcastingPub/​Sub (SNS, Kafka)
Task schedulingDelayed queues
Load levelingQueue with workers
Event sourcingLog-based (Kafka)

Architecture Decision Records (ADR)

Template

# ADR-001: [Title]

## Status
[Proposed | Accepted | Deprecated | Superseded by ADR-XXX]

## Context
[Why is this decision needed?]

## Decision
[What is the decision?]

## Consequences
### Positive
- [Benefit 1]
- [Benefit 2]

### Negative
- [Trade-off 1]
- [Trade-off 2]

## Alternatives Considered
1. [Alternative 1] - [Why rejected]
2. [Alternative 2] - [Why rejected]

Anti-Patterns to Avoid

  1. Big Ball of Mud - No clear structure, everything depends on everything
  2. Golden Hammer - Using one pattern for all problems
  3. Premature Optimization - Designing for scale before proving need
  4. Analysis Paralysis - Over-designing, never shipping
  5. Distributed Monolith - Microservices with tight coupling
  6. Anemic Domain Model - Entities with only getters/​setters
  7. God Object - One class that does everything
  8. Leaky Abstraction - Implementation details leak through interfaces

Decision Checklist

Before finalizing an architecture decision, verify:

  • Does it solve the actual problem?
  • Is it the simplest solution that works?
  • Can the team maintain it?
  • Does it align with existing patterns?
  • Is it testable?
  • Can it evolve as requirements change?
  • Are the trade-offs acceptable?
  • Is the decision documented?

Quick Reference

SOLID:
  S - Single Responsibility
  O - Open/​Closed
  L - Liskov Substitution
  I - Interface Segregation
  D - Dependency Inversion

PATTERNS:
  Layered     → Simple, clear separation
  Hexagonal   → Testable, adaptable
  Microservices → Scalable, independent
  Event-Driven  → Decoupled, async

DDD BUILDING BLOCKS:
  Entity, Value Object, Aggregate
  Repository, Domain Event, Domain Service

SCALABILITY:
  Horizontal scaling, Caching, Sharding, CDN

RESILIENCE:
  Circuit Breaker, Retry, Bulkhead, Timeout

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View