Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 17:55:18 +08:00
commit f33f21dd79
19 changed files with 3530 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
# Project Architecture
## Architecture Pattern
**Pattern**: [Hexagonal / Layered / Microservices / MVC / Clean / DDD]
### Core Principles
- [Principle 1]
- [Principle 2]
- [Principle 3]
## Project Structure
```
[Your project structure here]
Example for hexagonal:
src/
├── domain/ # Business logic (no external dependencies)
│ ├── models/ # Domain models
│ ├── services/ # Business services
│ └── exceptions/ # Domain exceptions
├── ports/ # Interface definitions (contracts)
│ ├── repositories/ # Data access interfaces
│ └── providers/ # External service interfaces
├── adapters/ # External integrations
│ ├── database/ # Database implementations
│ ├── api/ # External API clients
│ └── messaging/ # Message queue adapters
└── application/ # Use case orchestration
└── usecases/ # Application use cases
```
## Key Interfaces
List the important interfaces/contracts in your system:
- **[IRepository]**: [Description]
- **[IService]**: [Description]
- **[IProvider]**: [Description]
## Architectural Decisions
Document major architectural decisions:
### Decision 1: [Title]
**Date**: [YYYY-MM-DD]
**Context**: [Why this was needed]
**Decision**: [What was decided]
**Rationale**: [Why this approach]
### Decision 2: [Title]
**Date**: [YYYY-MM-DD]
**Context**: [Why this was needed]
**Decision**: [What was decided]
**Rationale**: [Why this approach]
## Patterns & Practices
### Design Patterns Used
- **[Pattern Name]**: [Where and why used]
- **[Pattern Name]**: [Where and why used]
### Best Practices
- [Practice 1]
- [Practice 2]
- [Practice 3]
## Dependencies Flow
Describe how dependencies flow in your architecture:
```
[Dependency flow diagram or description]
Example for hexagonal:
Outside → Adapters → Ports → Domain
↑ ↓
← Application ←──────
```
## Testing Strategy
- **Unit Tests**: [What to unit test and how]
- **Integration Tests**: [Integration boundaries]
- **E2E Tests**: [End-to-end scenarios]
## Notes for Developers
Additional guidance for developers working in this codebase:
- [Important note 1]
- [Important note 2]
- [Important note 3]

View File

@@ -0,0 +1,74 @@
# Session Management Configuration
session:
# Automatically track file changes during session
auto_track: true
# Create automatic checkpoints at intervals (false = manual only)
auto_checkpoint: false
checkpoint_interval: 30m
# Generate handoff document on session end
handoff_on_end: true
# Archive completed sessions after N days
archive_after_days: 30
context:
# Primary architecture pattern for this project
# Options: hexagonal, layered, microservices, mvc, clean, ddd
architecture: hexagonal
# Code patterns to detect and enforce
patterns:
- repository-pattern
- dependency-injection
# Project conventions
conventions:
- type-hints-required
- docstrings-required
tracking:
# File patterns to watch for changes
watch_patterns:
- "src/**/*.py"
- "tests/**/*.py"
- "docs/**/*.md"
# Patterns to ignore
ignore_patterns:
- "**/__pycache__/**"
- "**/node_modules/**"
- "**/.venv/**"
- "**/dist/**"
# Annotations to track
annotations:
- "TODO:"
- "FIXME:"
- "DECISION:"
- "BLOCKER:"
quality:
# Minimum test coverage threshold (%)
coverage_threshold: 85
# Require tests for new features
require_tests: true
# Block merge if quality thresholds not met
block_merge_on_quality: true
display:
# Use colored terminal output
color: true
# Verbosity level (false, true, debug)
verbose: false
# Use emoji in output
emoji: true
# Date/time format
date_format: "%Y-%m-%d %H:%M"

View File

@@ -0,0 +1,258 @@
# Code Conventions
## Language & Framework
**Primary Language**: [Python / JavaScript / TypeScript / etc.]
**Version**: [Version number]
**Framework**: [Framework name and version]
## Code Style
### Naming Conventions
**Variables & Functions**:
- Style: [snake_case / camelCase / PascalCase]
- Examples: `user_name`, `calculate_total`, `process_payment`
**Classes**:
- Style: [PascalCase / snake_case]
- Examples: `UserService`, `PaymentProcessor`, `OrderRepository`
**Constants**:
- Style: [UPPER_SNAKE_CASE / camelCase]
- Examples: `MAX_RETRIES`, `API_BASE_URL`, `DEFAULT_TIMEOUT`
**Files**:
- Style: [snake_case / kebab-case]
- Examples: `user_service.py`, `payment-processor.ts`
### Formatting
- **Line Length**: [80 / 100 / 120] characters maximum
- **Indentation**: [2 / 4] spaces (no tabs)
- **String Quotes**: [single / double / either] quotes
- **Trailing Commas**: [required / optional / never]
## Type Safety
**Type Hints/Annotations**: [Required / Encouraged / Optional]
```python
# Example for Python
def process_user(user_id: int, name: str) -> User:
"""Process user with given ID and name."""
pass
```
**Type Checking**: [Tool name: mypy / TypeScript / Flow / None]
## Documentation
### Docstrings
**Style**: [Google / NumPy / Sphinx / JSDoc]
**Required for**:
- [ ] Public functions
- [ ] Public classes
- [ ] Modules
- [ ] Complex algorithms
**Example**:
```python
def calculate_total(items: List[Item], tax_rate: float) -> Decimal:
"""
Calculate total price including tax.
Args:
items: List of items to total
tax_rate: Tax rate as decimal (e.g., 0.08 for 8%)
Returns:
Total price including tax
Raises:
ValueError: If tax_rate is negative
"""
pass
```
### Comments
**When to Comment**:
- Complex algorithms
- Non-obvious business logic
- Workarounds or hacks
- TODOs and FIXMEs
**What NOT to Comment**:
- Self-explanatory code
- What code does (let code be self-documenting)
- Commented-out code (delete instead)
## Testing
### Test Coverage
- **Minimum Coverage**: [85 / 90 / 95]%
- **New Code Coverage**: [90 / 95 / 100]%
### Test Organization
```
tests/
├── unit/ # Unit tests
│ └── test_[module].py
├── integration/ # Integration tests
│ └── test_[feature].py
└── e2e/ # End-to-end tests
└── test_[scenario].py
```
### Test Naming
Pattern: `test_[what]_[condition]_[expected]`
Examples:
- `test_user_creation_with_valid_data_succeeds`
- `test_payment_processing_with_insufficient_funds_raises_error`
- `test_order_total_calculation_with_discount_returns_correct_amount`
### Test Structure
```python
def test_something():
# Arrange - Set up test data
user = User(name="John")
# Act - Perform the action
result = process_user(user)
# Assert - Verify results
assert result.processed == True
```
## Error Handling
### Exception Handling
- **Custom Exceptions**: [Required / Optional] for domain errors
- **Logging**: [Always / Sometimes / Never] log exceptions
- **Re-raising**: [Wrap / Re-raise / Handle] exceptions appropriately
**Example**:
```python
try:
result = risky_operation()
except SpecificError as e:
logger.error(f"Operation failed: {e}")
raise DomainError("User-friendly message") from e
```
## Git Conventions
### Commit Messages
**Format**: [Conventional Commits / Custom / Free-form]
```
<type>(<scope>): <subject>
<body>
<footer>
```
**Types**:
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation changes
- `style`: Code style (formatting, etc.)
- `refactor`: Code refactoring
- `test`: Test additions or changes
- `chore`: Build process or auxiliary tool changes
**Examples**:
```
feat(auth): Add JWT token generation
fix(payments): Correct tax calculation for international orders
docs(api): Update authentication endpoint documentation
```
### Branch Naming
**Format**: `<type>/<description>`
**Types**:
- `feature/` - New features
- `bugfix/` - Bug fixes
- `hotfix/` - Urgent production fixes
- `refactor/` - Code refactoring
- `docs/` - Documentation updates
**Examples**:
- `feature/user-authentication`
- `bugfix/payment-calculation-error`
- `hotfix/security-vulnerability`
## Code Review
### Review Checklist
- [ ] Code follows style guidelines
- [ ] Tests included and passing
- [ ] Documentation updated
- [ ] No commented-out code
- [ ] Error handling appropriate
- [ ] Performance considerations addressed
- [ ] Security implications reviewed
### Review Standards
- **Required Approvals**: [1 / 2 / 3]
- **Automated Checks**: [Must pass / Should pass]
- **Response Time**: [24 / 48 / 72] hours
## Security
### Security Practices
- [ ] No secrets in code
- [ ] Input validation on all external data
- [ ] SQL injection prevention
- [ ] XSS prevention (for web apps)
- [ ] CSRF protection (for web apps)
- [ ] Proper authentication and authorization
### Sensitive Data
- Use environment variables for secrets
- Never log sensitive information
- Sanitize error messages sent to users
## Performance
### Performance Guidelines
- [ ] Avoid N+1 queries
- [ ] Use appropriate data structures
- [ ] Cache when beneficial
- [ ] Profile before optimizing
- [ ] Document performance-critical code
## Accessibility (for web projects)
- [ ] Semantic HTML
- [ ] ARIA labels where needed
- [ ] Keyboard navigation support
- [ ] Screen reader compatibility
- [ ] Color contrast compliance
## Additional Guidelines
[Add any project-specific conventions here]
---
**Last Updated**: [YYYY-MM-DD]
**Maintained By**: [Team/Person]