Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .cursor/rules/architecture.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
description:
globs: *.rs
alwaysApply: false
---
# Architecture Rules

## Core Principles

1. Each molecule must be a Working Piece of Software:
- Contains everything needed to run independently
- Represents a single domain concept
- Can be executed standalone or as part of a larger system
- Hides internal implementation details

2. Molecule Structure:
- Must have a `main.rs` for standalone execution
- Contains all related domain logic in one place
- Uses Rust modules for internal organization
- No artificial layering within molecules

3. Shared Code:
- Domain-agnostic utilities in `lib/`
- No domain logic in shared code
- Clear ownership of domain-specific code
- Unidirectional dependencies only

4. Module Integration:
- Molecules can be combined into larger features
- No circular dependencies allowed
- Clear dependency graph
- Explicit integration points

5. Feature Removal:
- Molecules can be removed without side effects
- No scattered references across codebase
- Clean removal process
- No feature flags needed

## Directory Structure

```
modules/
├── molecule/
│ ├── src/
│ │ ├── lib.rs // Public interface
│ │ ├── molecule.rs // Core domain logic
│ │ └── schema.rs // Data definitions
│ ├── Cargo.toml // Dependencies
│ └── main.rs // Standalone runner
├── aggregator/
│ ├── src/
│ │ └── main.rs // Combines molecules
│ └── Cargo.toml
└── lib/
├── src/
│ ├── lib.rs
│ └── utils.rs
└── Cargo.toml
```

## Naming Conventions

1. Molecules must be named after their domain concept
2. Files must reflect their primary responsibility
3. No generic names like "controller", "model", "view"
4. Use clear, domain-specific terminology
5. Follow Rust naming conventions:
- `snake_case` for modules and functions
- `CamelCase` for types and traits
- `SCREAMING_SNAKE_CASE` for constants
104 changes: 104 additions & 0 deletions .cursor/rules/code-style.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
description:
globs: *.rs
alwaysApply: false
---
# Code Style Rules

## Organization

1. Alphabetical ordering:
- Sort imports alphabetically
- Sort exports alphabetically
- Sort struct fields alphabetically
- Sort enum variants alphabetically
- Sort function parameters alphabetically

2. File structure:
- Module declarations at the top
- Imports after module declarations
- Types and traits next
- Constants after types
- Functions after constants
- Tests at the bottom

3. Function organization:
- Public functions first
- Private functions after
- Helper functions last

## Naming

1. Use domain-specific names:
- Avoid generic terms
- Names should reflect business concepts
- No technical implementation names

2. Function names:
- Start with verbs
- Be specific about action
- Include domain context
- Use `snake_case`

3. Variable names:
- Be descriptive
- Include type information
- Use domain terminology
- Use `snake_case`

## Abstractions

1. Only create abstractions for:
- Domain concepts
- DRY violations
- No other reasons

2. Keep abstractions:
- Close to their usage
- Simple and focused
- Well-documented

3. Avoid:
- Premature abstraction
- Over-engineering
- Unnecessary traits

## Molecule Structure

1. Keep related code together:
- Domain logic in one place
- No artificial layering
- Clear boundaries
- Use Rust modules for organization

2. Minimize dependencies:
- Only import what's needed
- No circular dependencies
- Clear dependency direction
- Use feature flags in Cargo.toml

3. Export only what's needed:
- Hide implementation details
- Clear public interface
- Domain-focused exports
- Use `pub(crate)` for internal visibility

## Rust-Specific Guidelines

1. Error handling:
- Use custom error types
- Implement `std::error::Error`
- Use `?` operator appropriately
- Provide context in error messages

2. Type safety:
- Use strong types
- Avoid `String` when possible
- Use newtypes for domain concepts
- Leverage the type system

3. Performance:
- Use references appropriately
- Avoid unnecessary cloning
- Use appropriate data structures
- Profile when needed
98 changes: 98 additions & 0 deletions .cursor/rules/documentation.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
description:
globs: *.rs
alwaysApply: false
---
# Documentation Rules

## Code Documentation

1. Function documentation:
- Purpose and intent
- Parameters and return values
- Usage examples
- No implementation details
- Use `///` for doc comments

2. Type documentation:
- Domain meaning
- Usage context
- Constraints
- Examples
- Use `///` for doc comments

3. Module documentation:
- Purpose and scope
- Dependencies
- Usage guidelines
- Examples
- Use `//!` for module-level docs

## Molecule Documentation

1. Core documentation:
- Domain concept
- Standalone capabilities
- Integration points
- Dependencies
- Cargo.toml metadata

2. Molecule structure:
- File organization
- Key components
- Data flow
- External interfaces
- Module hierarchy

3. Molecule usage:
- How to run standalone
- How to integrate
- Configuration options
- Examples
- Feature flags

## System Documentation

1. Architecture overview:
- Molecule relationships
- Dependency graph
- Integration patterns
- Deployment options
- Workspace structure

2. Shared resources:
- Library usage
- Common utilities
- Cross-cutting concerns
- Best practices
- Cargo workspace

3. Development workflow:
- Adding new molecules
- Removing molecules
- Testing strategy
- Deployment process
- Cargo commands

## Documentation Standards

1. Documentation location:
- Code comments for implementation
- README.md for modules
- Architecture docs for system
- API docs for interfaces
- Cargo doc for API docs

2. Documentation format:
- Clear and concise
- Use markdown
- Include examples
- Keep up to date
- Follow rustdoc conventions

3. Documentation maintenance:
- Update with code changes
- Review regularly
- Remove obsolete docs
- Version control docs
- Run `cargo doc` regularly
106 changes: 106 additions & 0 deletions .cursor/rules/testing.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
description:
globs: *.rs
alwaysApply: false
---
# Testing Rules

## Core Principles

1. Each molecule must be independently testable:
- No dependencies on other molecules
- Use in-memory databases for testing
- Mock external services
- Use feature flags for test dependencies

2. Test organization:
- Unit tests in `#[cfg(test)]` modules
- Integration tests in `tests/` directory
- End-to-end tests for aggregators
- Use test attributes appropriately

3. Test naming:
- Describe the scenario
- Include expected outcome
- Use domain terminology
- Follow Rust test naming conventions

## Test Structure

1. Test file organization:
- Group related tests
- Alphabetical ordering within groups
- Clear test descriptions
- Use test modules for organization

2. Test setup:
- Minimal setup required
- Clear test data
- Isolated test environment
- Use test fixtures when needed

3. Test assertions:
- One concept per test
- Clear failure messages
- Domain-specific assertions
- Use appropriate assertion macros

## Testing Practices

1. Test coverage:
- Core business logic
- Edge cases
- Error conditions
- Use `cargo tarpaulin` for coverage

2. Test data:
- Use realistic data
- Include edge cases
- Document test data purpose
- Use const for test data

3. Test maintenance:
- Keep tests simple
- Update tests with code changes
- Remove obsolete tests
- Run tests in CI

## Molecule Testing

1. Standalone testing:
- Test molecule in isolation
- Use in-memory services
- No external dependencies
- Use test features in Cargo.toml

2. Integration testing:
- Test molecule boundaries
- Verify integration points
- Check dependency handling
- Use test helpers

3. Aggregator testing:
- Test molecule combinations
- Verify system behavior
- Check communication flow
- Use workspace tests

## Rust-Specific Testing

1. Test attributes:
- Use `#[test]` for test functions
- Use `#[cfg(test)]` for test modules
- Use `#[ignore]` for slow tests
- Use `#[should_panic]` for panic tests

2. Test utilities:
- Use `assert!` for boolean checks
- Use `assert_eq!` for equality
- Use `assert_ne!` for inequality
- Use `assert_matches!` for pattern matching

3. Test organization:
- Use `mod tests` for unit tests
- Use `tests/` directory for integration
- Use `benches/` for benchmarks
- Use `examples/` for examples
Loading