xiaohongshu
xiaohongshu
designing-architecture
Guides software architecture decisions, design patterns, and system design principles. Use when designing systems, choosing patterns, or making architectural decisions.
Full skill instructions
Principles and patterns for designing maintainable, scalable, and robust software systems.
| Principle | Summary | Violation Sign |
|---|---|---|
| Single Responsibility | One reason to change | Class does too many things |
| Open/Closed | Open for extension, closed for modification | Modifying existing code for new features |
| Liskov Substitution | Subtypes replaceable for base types | Overrides break parent behavior |
| Interface Segregation | Small, focused interfaces | Classes implement unused methods |
| Dependency Inversion | Depend on abstractions | High-level modules depend on low-level |
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.
┌─────────────────────────────────────┐
│ 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
┌───────────────┐
│ 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
┌─────────┐ ┌─────────┐ ┌─────────┐
│ 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 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
| Pattern | Purpose | When to Use |
|---|---|---|
| Factory | Create objects without specifying class | Object creation logic is complex |
| Builder | Construct complex objects step-by-step | Many optional parameters |
| Singleton | Single instance globally | Shared resource (use sparingly) |
| Dependency Injection | Inject dependencies externally | Testability, loose coupling |
| Pattern | Purpose | When to Use |
|---|---|---|
| Adapter | Convert interface to another | Integrating incompatible systems |
| Decorator | Add behavior dynamically | Extending functionality without inheritance |
| Facade | Simplified interface to complex system | Hiding complexity |
| Repository | Abstract data access | Separating domain from persistence |
| Pattern | Purpose | When to Use |
|---|---|---|
| Strategy | Interchangeable algorithms | Multiple ways to do something |
| Observer | Notify dependents of changes | Event systems, reactive updates |
| Command | Encapsulate actions as objects | Undo/redo, queuing, logging |
| Chain of Responsibility | Pass request along handlers | Middleware, validation chains |
| Concept | Definition | Example |
|---|---|---|
| Bounded Context | Explicit boundary for a domain model | Order context, Shipping context |
| Ubiquitous Language | Shared vocabulary between devs and domain experts | "Order", "Line Item", "Fulfillment" |
| Context Map | How bounded contexts relate | Customer shared between Sales and Support |
| Pattern | Purpose | Example |
|---|---|---|
| Entity | Object with identity | User, Order |
| Value Object | Object without identity | Money, Address |
| Aggregate | Cluster of entities with root | Order + LineItems |
| Domain Event | Something that happened | OrderPlaced, PaymentReceived |
| Repository | Collection-like access to aggregates | OrderRepository |
| Domain Service | Logic that doesn't fit entities | PricingService |
| Pattern | Description | Trade-off |
|---|---|---|
| Horizontal Scaling | Add more instances | Statelessness required |
| Vertical Scaling | Bigger machines | Hardware limits |
| Caching | Store computed results | Cache invalidation |
| Database Sharding | Split data across DBs | Query complexity |
| Read Replicas | Separate read/write | Eventual consistency |
| CDN | Edge content delivery | Static content only |
| Pattern | Purpose | Implementation |
|---|---|---|
| Circuit Breaker | Prevent cascade failures | Fail fast when downstream is down |
| Retry with Backoff | Handle transient failures | Exponential delay between retries |
| Bulkhead | Isolate failures | Separate thread pools per dependency |
| Timeout | Bound waiting time | Max wait for responses |
| Fallback | Graceful degradation | Default behavior when service unavailable |
| Pattern | Consistency | Use When |
|---|---|---|
| ACID Transactions | Strong | Financial data, critical operations |
| Saga | Eventual | Distributed transactions |
| Event Sourcing | Eventual | Audit trails, complex state |
| CQRS | Eventual | Different read/write models |
| Need | Recommended | Avoid |
|---|---|---|
| Relational data, ACID | PostgreSQL, MySQL | MongoDB |
| Document storage, flexible schema | MongoDB, DynamoDB | Relational |
| Key-value, high speed | Redis, Memcached | Relational |
| Time series | InfluxDB, TimescaleDB | Generic SQL |
| Graph relationships | Neo4j, Neptune | Relational (for complex) |
| Search | Elasticsearch, Meilisearch | Full table scans |
| Need | Pattern |
|---|---|
| Async processing | Queue (SQS, RabbitMQ) |
| Event broadcasting | Pub/Sub (SNS, Kafka) |
| Task scheduling | Delayed queues |
| Load leveling | Queue with workers |
| Event sourcing | Log-based (Kafka) |
# 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]
Before finalizing an architecture decision, verify:
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
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
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...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
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...
Display project status, active tracks, and next actions
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.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience