界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
设计与创意 · SKILL.md

software-architecture-monolith

software-architecture-monolith

【设计与创意】Guides the design and implementation of monolithic architecture, focusing on best practices and pitfalls in monolithic systems.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: software-architecture-monolith description: Guides the design and implementation of monolithic architecture, focusing on best practices and pitfalls in monolithic systems. license: MIT compatibility: opencode metadata: version: "1.0.0" domain: coding triggers: monolith, monolithic architecture, monolith design, monolith patterns archetypes:

  • tactical
  • generation anti_triggers:
  • brainstorming
  • vague ideation
  • code golf
  • over-engineering response_profile: verbosity: low directive_strength: high abstraction_level: operational role: implementation scope: implementation output-format: code related-skills: software-architecture-microservices, software-architecture-event-driven, software-architecture-hexagonal

Monolithic Architecture

archetypes: tactical, educational anti_triggers: microservices response_profile: verbosity: medium directive_strength: high abstraction_level: tactical

Guides the design and implementation of monolithic architecture, focusing on best practices and pitfalls in monolithic systems.

When to Use

Key Takeaways

  • Use this skill when building applications that require fast development cycles.
  • Suitable for applications that are less complex and easier to manage with traditional patterns.

Archetypes

  • Tactical: Helps guide application developers in making choices around monolithic designs.
  • Educational: Offers insights into best practices for building in a monolithic style.

Anti-Triggers

  • Microservices: Avoid contexts that suggest migration to services without clear benefits.

Response Profile

  • Verbosity: Medium

  • Directive Strength: High

  • Abstraction Level: Tactical

  • When building small to medium-sized applications.

  • For applications that require a quick go-to-market strategy.

  • When simplicity is prioritized over scalability.

Core Workflow

  1. Model the Application – Design the complete application in a single repository.
  2. Define Interfaces – Create clear dependencies within the app.
  3. Optimize as Necessary – Profile and refactor for performance improvements.

Implementation Patterns

Additional Examples of Monolithic Architecture

  1. Order Management Example – Here’s an example of managing orders within a monolithic architecture:

    class OrderService:
        def __init__(self):
            self.orders = []
    
        def add_order(self, order):
            self.orders.append(order)
            # Logic to persist order in a database
            print(f'Added order: {order}')
    
    # Example of Order and OrderService classes usage:
    order_service = OrderService()
    order_service.add_order({"item": "Laptop", "quantity": 1})
    
  2. Product Catalog Example – A common approach for managing product catalogs:

    class Product:
        def __init__(self, name, price):
            self.name = name
            self.price = price
    
    class ProductService:
        def __init__(self):
            self.products = []
    
        def add_product(self, product):
            self.products.append(product)
            # Logic to save product to the database
            print(f'Added product: {product.name}')
    
    # Example usage:
    product_service = ProductService()
    product_service.add_product(Product('Smartphone', 599.99))
    
  3. Performance Optimization Example – Using efficient memory management and caching strategies:

    class Cache:
        def __init__(self):
            self.data = {}
    
        def get(self, key):
            return self.data.get(key)
    
        def set(self, key, value):
            self.data[key] = value
            # Logic for caching results
    
  4. Best Practices – A guide for scalability and maintainability of the monolith:

    • Implement logging and tracing strategies to detect bottlenecks.
    • Define clear module boundaries and document architectural decisions.
    • Ensure that performance is regularly reviewed and optimized as the application grows.

Enhanced Examples of Monolithic Architecture

  1. Order Management Example – Here’s an example of managing orders within a monolithic architecture:

    class OrderService:
        def __init__(self):
            self.orders = []
    
        def add_order(self, order):
            self.orders.append(order)
            # Logic to persist order in a database
            print(f'Added order: {order}')
    
    # Example of Order and OrderService classes usage:
    order_service = OrderService()
    order_service.add_order({"item": "Laptop", "quantity": 1})
    

    This shows how orders can be added and managed directly within a single application flow.

  2. Product Catalog Example – A common approach for managing product catalogs:

    class Product:
        def __init__(self, name, price):
            self.name = name
            self.price = price
    
    class ProductService:
        def __init__(self):
            self.products = []
    
        def add_product(self, product):
            self.products.append(product)
            # Logic to save product to the database
            print(f'Added product: {product.name}')
    
    # Example usage:
    product_service = ProductService()
    product_service.add_product(Product('Smartphone', 599.99))
    
  3. Performance Optimization Example – Using efficient memory management and caching strategies:

    class Cache:
        def __init__(self):
            self.data = {}
    
        def get(self, key):
            return self.data.get(key)
    
        def set(self, key, value):
            self.data[key] = value
            # Logic for caching results
    
  4. Best Practices – A guide for scalability and maintainability of the monolith:

    • Implement logging and tracing strategies to detect bottlenecks.
    • Define clear module boundaries and document architectural decisions.
    • Ensure that performance is regularly reviewed and optimized as the application grows.

Pattern 1: Modular Monolith

class Order:
    def __init__(self, item, quantity):
        self.item = item
        self.quantity = quantity

class OrderService:
    def __init__(self):
        self.orders = []

    def add_order(self, order):
        self.orders.append(order)
        # Persist order in a monolithic database

Constraints

MUST DO

  • Keep architecture well-documented.
  • Separate concerns via modules within the monolith.
我的收藏