

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456# Architecture & Design Principles7# Architecture & Design Principles89<goal>10Establish comprehensive architectural standards and design principles for building maintainable, scalable, and robust software following industry best practices adapted to the project's domain-driven structure.11</goal>1213## Core Architectural Principles1415### SOLID Principles1617<principle type="solid_srp">18**Single Responsibility Principle (SRP):**19- Each module, class, or function should have only one reason to change20- Separate business logic, data access, and presentation concerns21- Use domain-specific packages: `engine/{agent,task,tool,workflow,runtime,infra}/`22- *Implementation examples: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*23</principle>2425<principle type="solid_ocp">26**Open/Closed Principle (OCP):**27- Open for extension, closed for modification28- Use interfaces and composition over inheritance29- Leverage factory patterns for extensible behavior30- *Factory pattern implementation: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*31</principle>3233<principle type="solid_lsp">34**Liskov Substitution Principle (LSP):**35- Subtypes must be substitutable for their base types36- Interface implementations must honor contracts37- Ensure interface methods behave consistently38- *Interface design patterns: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*39</principle>4041<principle type="solid_isp">42**Interface Segregation Principle (ISP):**43- Clients should not depend on interfaces they don't use44- Create small, focused interfaces45- Use interface composition for complex behavior46- *Interface composition examples: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*47</principle>4849<principle type="solid_dip">50**Dependency Inversion Principle (DIP):**51- Depend on abstractions, not concretions52- Use dependency injection through constructors53- High-level modules should not depend on low-level modules54- *Constructor patterns: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*55</principle>5657### DRY Principle (Don't Repeat Yourself)5859<dry_strategies type="code_reuse">60**Code Reuse Strategies:**61- Extract common functionality into shared packages62- Use generic functions for similar operations63- Create utility packages for cross-cutting concerns6465```go66// ✅ Good: Reusable validation utility67func ValidateRequired(value string, fieldName string) error {68 if strings.TrimSpace(value) == "" {69 return fmt.Errorf("%s is required", fieldName)70 }71 return nil72}7374// Usage across multiple validators75func (v *UserValidator) ValidateName(name string) error {76 return ValidateRequired(name, "name")77}7879func (v *TaskValidator) ValidateTitle(title string) error {80 return ValidateRequired(title, "title")81}82```83</dry_strategies>8485<dry_strategies type="configuration_patterns">86**Configuration Patterns:**87- Centralize configuration with defaults88- Use template engine for dynamic configurations89- Avoid duplicating configuration logic90- *Configuration implementation: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*91</dry_strategies>9293### Clean Architecture9495<architecture_structure type="domain_driven">96**Domain-Driven Design Structure:**97```98engine/99├── agent/ # Agent domain logic100├── task/ # Task execution domain101├── tool/ # Tool management domain102├── workflow/ # Workflow orchestration domain103├── runtime/ # Runtime execution environment104├── infra/ # Infrastructure concerns105└── core/ # Shared domain primitives106```107</architecture_structure>108109<layer_separation>110**Layer Separation:**111- **Domain Layer** (`engine/core/`): Shared business entities, value objects, and cross-domain primitives112- **Application Layer** (`engine/{agent,task,tool,workflow}/`): Domain-specific business logic, use cases, and port interfaces (repositories, external services)113- **Infrastructure Layer** (`engine/infra/`): External concerns (DB, HTTP, etc.) and adapter implementations114- **Runtime Layer** (`engine/runtime/`): Execution environment and system orchestration115116**Interface Ownership Clarification:**117- **Port Interfaces** (e.g., Repository, ExternalService): Defined in Application Layer packages where they're used118- **Domain Entities**: Defined in Domain Layer (`engine/core/`) for cross-domain sharing119- **Adapter Implementations**: Defined in Infrastructure Layer, implementing Application Layer interfaces120</layer_separation>121122<dependency_flow>123```go124// ✅ Good: Dependencies flow inward125package task126127import (128 "context"129 "github.com/project/engine/core" // Domain entities130)131132type Service struct {133 repo Repository // Interface defined in domain134}135136type Repository interface { // Domain-defined interface137 Save(ctx context.Context, task *core.Task) error138 Find(ctx context.Context, id core.ID) (*core.Task, error)139}140141// Implementation in infrastructure layer142package infra143144import (145 "github.com/project/engine/task" // Application layer146)147148type PostgreSQLTaskRepository struct {149 db *sql.DB150}151152func (r *PostgreSQLTaskRepository) Save(ctx context.Context, task *core.Task) error {153 // Implementation details154}155```156</dependency_flow>157158### Clean Code Practices159160**Naming Conventions:**161- Use intention-revealing names162- Avoid mental mapping and abbreviations163- Use searchable names for important concepts164165<example type="naming_conventions">166```go167// ✅ Good: Clear, intention-revealing names168type WorkflowExecutionResult struct {169 TaskResults []TaskResult `json:"task_results"`170 ExecutionTime time.Duration `json:"execution_time"`171 Status ExecutionStatus `json:"status"`172}173174func (w *WorkflowService) ExecuteWorkflowWithRetry(175 ctx context.Context,176 workflowID core.ID,177 maxRetries int,178) (*WorkflowExecutionResult, error) {179 // Implementation180}181182// ❌ Bad: Unclear, abbreviated names183type WfExecRes struct {184 TskRes []TskRes `json:"tr"`185 ExecT int64 `json:"et"`186 Stat int `json:"s"`187}188189func (w *WfSvc) ExecWf(ctx context.Context, id string, mr int) (*WfExecRes, error) {190 // Implementation191}192```193</example>194195<function_design>196**Function Design:**197- Follow function length limits defined in go-coding-standards.mdc198- Single level of abstraction per function199- Minimize function parameters (max 3-4)200</function_design>201202<example type="function_design">203```go204// ✅ Good: Small, focused function205func (s *TaskService) ValidateTaskInput(task *core.Task) error {206 if err := s.validateRequiredFields(task); err != nil {207 return fmt.Errorf("validation failed: %w", err)208 }209 if err := s.validateBusinessRules(task); err != nil {210 return fmt.Errorf("business rule validation failed: %w", err)211 }212 return nil213}214215func (s *TaskService) validateRequiredFields(task *core.Task) error {216 if task.Title == "" {217 return errors.New("title is required")218 }219 if task.Type == "" {220 return errors.New("type is required")221 }222 return nil223}224```225</example>226227<error_handling_architecture>228**Error Handling Architecture:**229Follow unified error handling strategy from [go-coding-standards.mdc](mdc:.cursor/rules/go-coding-standards.mdc)230</error_handling_architecture>231232<example type="error_handling">233```go234// ✅ Good: Structured error handling235func (s *WorkflowService) ExecuteWorkflow(ctx context.Context, id core.ID) error {236 workflow, err := s.repo.FindWorkflow(ctx, id)237 if err != nil {238 return fmt.Errorf("failed to load workflow %s: %w", id, err)239 }240241 if err := s.validateWorkflow(workflow); err != nil {242 return core.NewError(err, "WORKFLOW_VALIDATION_FAILED", map[string]any{243 "workflow_id": id,244 "workflow_type": workflow.Type,245 })246 }247248 return s.executeWorkflowTasks(ctx, workflow)249}250```251</example>252253## Project-Specific Patterns254255### Domain Organization256257<package_structure>258**Package Structure:**259- Each domain in `engine/` has clear boundaries260- Shared types in `engine/core/`261- Infrastructure concerns in `engine/infra/`262</package_structure>263264### Service Construction265266<constructor_pattern type="mandatory">267**MANDATORY constructor pattern for all services**268- Use dependency injection through constructors269- Always provide nil-safe configuration handling270- *Implementation examples: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*271</constructor_pattern>272273### Context Propagation274275<context_requirements type="mandatory">276**Context as first parameter in all functions**277- Always handle context cancellation278- Propagate context through call chains279- *Context handling patterns: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*280</context_requirements>281282### Resource Management283284<cleanup_patterns>285**Resource cleanup requirements:**286- Use defer for cleanup operations287- Handle cleanup errors appropriately288- Implement timeout handling for long-running operations289- *Resource management patterns: see [go-patterns.mdc](mdc:.cursor/rules/go-patterns.mdc)*290</cleanup_patterns>291292## Anti-Patterns to Avoid293294### God Objects295```go296// ❌ Avoid: Too many responsibilities297type MegaService struct {298 // Too many dependencies and responsibilities299}300```301302### Tight Coupling303```go304// ❌ Avoid: Direct dependency on concrete types305type Service struct {306 db *sql.DB // Should be an interface307}308```309310### Circular Dependencies311```go312// ❌ Avoid: Package A imports B, B imports A313```314315### Magic Numbers/Strings316```go317// ❌ Avoid: Magic values318if status == 1 { /* what does 1 mean? */ }319320// ✅ Use: Named constants321const StatusActive = 1322if status == StatusActive { /* clear meaning */ }323```324325## Quality Metrics326327### Code Quality Indicators328- **Function complexity and length:** Follow limits defined in go-coding-standards.mdc329- **Package Coupling:** Minimize cross-package dependencies330- **Test Coverage:** Aim for 80%+ on business logic331332### Architecture Health333- **Dependency Direction:** Always inward toward domain334- **Interface Usage:** High ratio of interfaces to concrete types335- **Package Cohesion:** Related functionality grouped together336- **Separation of Concerns:** Clear boundaries between layers337338## Final Guidelines3393401. **Design for Change:** Assume requirements will evolve3412. **Favor Composition:** Over inheritance and complex hierarchies3423. **Explicit Dependencies:** Make all dependencies visible3434. **Fail Fast:** Validate inputs early and fail explicitly3445. **Document Decisions:** Capture architectural decisions and trade-offs3456. **Measure and Monitor:** Track architecture health metrics3467. **Refactor Continuously:** Improve design as understanding grows3478. **Test Architecture:** Verify architectural constraints in tests348
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| compozy/gograph.cursor/rules/api-standards.mdc · 9 | Cursor rules | lint-formatapidocs | 54/100 | 14 days ago | |
| compozy/gograph.cursor/rules/backwards-compatibility.mdc · 9 | Cursor rules | do-notagent-behaviour | 32/100 | 14 days ago | |
| compozy/gograph.cursor/rules/compozy-agent-config.mdc · 9 | Cursor rules | agent-behaviour | 45/100 | 14 days ago | |
| compozy/gograph.cursor/rules/compozy-examples.mdc · 9 | Cursor rules | stylearchtypesagent-behaviour | 58/100 | 14 days ago | |
| compozy/gograph.cursor/rules/compozy-project-config.mdc · 9 | Cursor rules | setupstyle | 54/100 | 14 days ago | |
| compozy/gograph.cursor/rules/compozy-shared-patterns.mdc · 9 | Cursor rules | styleagent-behaviour | 54/100 | 14 days ago | |
| compozy/gograph.cursor/rules/compozy-task-patterns.mdc · 9 | Cursor rules | stylearchagent-behaviour | 70/100 | 14 days ago | |
| compozy/gograph.cursor/rules/core-libraries.mdc · 9 | Cursor rules | testing-strategydependenciesdo-not | 60/100 | 14 days ago | |
| compozy/gograph.cursor/rules/critical-validation.mdc · 9 | Cursor rules | no sections | 24/100 | 14 days ago | |
| compozy/gograph.cursor/rules/cursor_rules.mdc · 9 | Cursor rules | no sections | 40/100 | 14 days ago | |
| compozy/gograph.cursor/rules/go-coding-standards.mdc · 9 | Cursor rules | stylearchdependencies | 62/100 | 14 days ago | |
| compozy/gograph.cursor/rules/go-patterns.mdc · 9 | Cursor rules | style | 66/100 | 14 days ago | |
| compozy/gograph.cursor/rules/no_linebreaks.mdc · 9 | Cursor rules | no sections | 31/100 | 14 days ago | |
| compozy/gograph.cursor/rules/prd-create.mdc · 9 | Cursor rules | stylearchagent-behaviour | 48/100 | 14 days ago | |
| compozy/gograph.cursor/rules/prd-tech-spec.mdc · 9 | Cursor rules | setuptestarchagent-behaviour | 56/100 | 14 days ago | |
| compozy/gograph.cursor/rules/quality-security.mdc · 9 | Cursor rules | securityperformancedo-not | 46/100 | 14 days ago | |
| compozy/gograph.cursor/rules/review-checklist.mdc · 9 | Cursor rules | testing-strategygit | 52/100 | 14 days ago | |
| compozy/gograph.cursor/rules/section_comments.mdc · 9 | Cursor rules | no sections | 31/100 | 14 days ago | |
| compozy/gograph.cursor/rules/task-developing.mdc · 9 | Cursor rules | agent-behaviour | 47/100 | 14 days ago | |
| compozy/gograph.cursor/rules/task-generate-list.mdc · 9 | Cursor rules | testlint-formatarchdo-not+1 | 85/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 46 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 14 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 46 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/compozy-gograph-cursor-rules-architecture)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.