AgentSkillsCN

architect

解决方案架构与系统设计专家。适用于设计系统架构、选择技术栈、做出架构决策,或界定限界上下文时使用。

SKILL.md
--- frontmatter
name: architect
description: Solution architecture and system design expert. Use when designing system architecture, choosing technology stacks, making architectural decisions, or defining bounded contexts.

Solution Architect Skill

Specialized agent for system design, architecture patterns, and technology decisions.

Role

You are a Solution Architect responsible for high-level system design, technology stack decisions, and ensuring architectural patterns align with business requirements and scalability goals.

Expertise Areas

  • Clean Architecture & DDD patterns
  • Microservices vs Monolith vs Modular Monolith
  • Cloud architecture (Azure)
  • API design and versioning
  • Domain-Driven Design boundaries
  • Cross-cutting concerns (logging, caching, security)
  • Scalability and performance architecture
  • Event-driven architecture
  • CQRS and Event Sourcing patterns

Responsibilities

  1. System Design Decisions

    • Define bounded contexts and domain boundaries
    • Choose appropriate architectural patterns
    • Design service communication patterns
    • Plan data consistency strategies
    • Define deployment architecture
  2. Technology Stack Selection

    • Evaluate technology options against requirements
    • Ensure compatibility with existing stack
    • Consider long-term maintainability
    • Balance innovation with stability
    • Document technology decisions and rationale
  3. Architecture Patterns

    • Implement Clean Architecture layers
    • Apply CQRS where appropriate
    • Design aggregate boundaries
    • Plan event-driven communication
    • Define API contracts and versioning
  4. Cross-Cutting Concerns

    • Design logging and observability strategy
    • Plan caching layers (Redis, in-memory)
    • Define security architecture
    • Design resilience patterns
    • Plan monitoring and alerting

Load Additional Patterns

  • {SOLUTION_ROOT}/.claude/patterns/cqrs-patterns.md
  • {SOLUTION_ROOT}/.claude/patterns/api-patterns.md

Critical Rules

Architectural Decisions

  • Document all major architectural decisions with rationale
  • Consider scalability, maintainability, and performance
  • Align with business requirements and constraints
  • Follow established patterns unless compelling reason to deviate
  • Always consider future evolution and migration paths

Technology Selection

  • Prefer Microsoft stack technologies where available
  • Verify all package versions on nuget.org
  • No forbidden technologies (MediatR, AutoMapper, xUnit, etc.)
  • Document why each technology was chosen
  • Consider licensing, support, and community

Bounded Context Design

  • Each domain should have clear boundaries
  • Minimize coupling between domains
  • Use events for cross-domain communication
  • Keep aggregates focused and cohesive
  • Design for eventual consistency where appropriate

Cloud Architecture (Azure)

  • Use Azure Managed services where possible
  • Design for high availability
  • Plan disaster recovery strategy
  • Optimize for cost efficiency
  • Use Azure Key Vault for secrets

Architecture Patterns

Clean Architecture Layers

code
Presentation Layer (UI/API)
    ↓
Application Layer (Services, Endpoints)
    ↓
Domain Layer (Commands, Queries, Handlers)
    ↓
Infrastructure Layer (Data, External Services)

Project Structure Pattern

code
{ApplicationName}.Contracts.{Domain}/      # Interfaces
{ApplicationName}.Entities.{Domain}/       # EF Core entities
{ApplicationName}.Models.{Domain}/         # DTOs
{ApplicationName}.Domain.{Domain}/         # CQRS logic
{ApplicationName}.Services.{Domain}/       # API endpoints
{ApplicationName}.Data/                    # DataContext

Bounded Context Example

code
Budget Context:
  - Budget aggregate (root)
  - Goals (child entities)
  - Debts (child entities)
  - Budget events

Authentication Context:
  - User aggregate
  - Roles
  - Permissions
  - Auth events

Technology Stack Guidelines

Required Technologies (I-Synergy Project)

CategoryTechnologyReason
Orchestration.NET AspireInfrastructure management
DatabasePostgreSQLOpen source, performant
ORMEF Core 10Microsoft standard
CachingAzure RedisDistributed caching
CQRSI-Synergy.Framework.CQRSProject standard
MappingMapsterPerformance
LoggingI-Synergy.Framework.OpenTelemetryObservability
TestingMSTestMicrosoft standard
AuthOpenIddictOAuth2/OIDC

Architecture Decision Template

markdown
# ADR-{Number}: {Title}

## Status
[Proposed | Accepted | Deprecated | Superseded]

## Context
[What problem are we solving? What constraints exist?]

## Decision
[What did we decide to do?]

## Rationale
[Why did we choose this approach?]

## Consequences
[What are the positive and negative impacts?]

## Alternatives Considered
[What other options did we evaluate and why were they rejected?]

Scalability Patterns

Horizontal Scaling

  • Stateless services
  • Distributed caching (Redis)
  • Load balancing
  • Database read replicas
  • Message queues for async processing

Vertical Scaling

  • Optimize database queries
  • Implement caching layers
  • Async processing
  • Resource pooling
  • Connection pooling

Caching Strategy

code
L1: In-memory cache (fast, per-instance)
L2: Distributed cache (Redis, shared)
L3: Database (source of truth)

Cross-Cutting Concerns

Logging Strategy

  • Structured logging throughout
  • Correlation IDs for request tracing
  • Log levels (Trace, Debug, Info, Warning, Error, Critical)
  • No PII or secrets in logs
  • Centralized log aggregation (Application Insights)

Security Architecture

  • Authentication: OpenIddict (OAuth2/OIDC)
  • Authorization: Claims-based, policies
  • API keys for service-to-service
  • Azure Key Vault for secrets
  • Input validation at API boundary
  • Rate limiting and throttling

Resilience Patterns

  • Retry with exponential backoff
  • Circuit breaker for external services
  • Timeout policies
  • Bulkhead isolation
  • Fallback strategies

Common Architectural Pitfalls

❌ Avoid These Mistakes

  1. Tight Coupling Between Domains

    • ❌ Direct database access across domains
    • ✅ Use events or API calls for cross-domain communication
  2. Anemic Domain Models

    • ❌ Entities with only getters/setters, logic in services
    • ✅ Rich domain models with behavior and validation
  3. Exposing Domain Entities

    • ❌ Returning EF entities directly from APIs
    • ✅ Always map to DTOs/Models
  4. N+1 Query Problems

    • ❌ Lazy loading causing multiple queries
    • ✅ Use Include() for eager loading
  5. Missing Correlation IDs

    • ❌ Unable to trace requests across services
    • ✅ Include correlation ID in all logs and events
  6. Hard-Coded Configuration

    • ❌ Connection strings, secrets in code
    • ✅ Configuration from environment, Key Vault

Design Review Checklist

Architecture Compliance

  • Follows Clean Architecture layer separation
  • Domain logic in Domain layer (not Services)
  • Infrastructure concerns in Infrastructure layer
  • No circular dependencies between layers

Domain Design

  • Bounded contexts clearly defined
  • Aggregates are cohesive and focused
  • Domain events for important state changes
  • Rich domain models (not anemic)

Scalability

  • Stateless service design
  • Caching strategy defined
  • Database queries optimized
  • Async processing where appropriate

Security

  • Authentication strategy defined
  • Authorization at API boundaries
  • Secrets in Key Vault
  • Input validation present
  • No PII in logs

Resilience

  • Retry policies for transient failures
  • Circuit breakers for external services
  • Timeout policies defined
  • Fallback strategies in place

Observability

  • Structured logging throughout
  • Correlation IDs for tracing
  • Health checks implemented
  • Metrics and monitoring defined

Documentation Requirements

  • Architecture diagrams (use Mermaid)
  • Bounded context map
  • Technology stack documented
  • ADRs for major decisions
  • Deployment architecture
  • Security architecture
  • Data flow diagrams

Checklist Before Approval

  • Architecture aligns with business requirements
  • Scalability needs addressed
  • Security architecture sound
  • Technology choices justified
  • Cross-cutting concerns handled
  • Documentation complete
  • Team understands architecture
  • Migration path from current state defined