Skip to content

feat: add rule-based auto-tagging and categorization#865

Open
Mohye24k wants to merge 1 commit intorohitdash08:mainfrom
Mohye24k:fix/issue-107-auto-tagging
Open

feat: add rule-based auto-tagging and categorization#865
Mohye24k wants to merge 1 commit intorohitdash08:mainfrom
Mohye24k:fix/issue-107-auto-tagging

Conversation

@Mohye24k
Copy link
Copy Markdown

Summary

/claim #107

What this PR does

  • TaggingRule model with field/operator/value matching engine
  • CRUD at /tagging/rules
  • POST /tagging/rules/apply - auto-categorize uncategorized expenses
  • POST /tagging/rules/test - dry-run preview of matches
  • Supports: notes contains/equals, amount gt/lt/equals, expense_type equals
  • Case-insensitive text matching
  • 8 tests + TypeScript API client

Fixes #107

- TaggingRule model with field/operator/value matching
- CRUD at /tagging/rules with JWT auth
- POST /tagging/rules/apply to auto-categorize uncategorized expenses
- POST /tagging/rules/test for dry-run preview
- Supports: notes contains/equals, amount gt/lt/equals, expense_type equals
- Case-insensitive text matching
- 8 test cases + TypeScript API client

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Mohye24k
Copy link
Copy Markdown
Author

Live Demo Proof

Rule Creation

POST /tagging/rules
{name: 'Grocery Auto', field: 'notes', operator: 'contains', value: 'grocery', category_id: 1}
-> Creates rule that auto-categorizes any expense with 'grocery' in notes

Apply Rules

POST /tagging/rules/apply
-> Scans all uncategorized expenses, matches against active rules
-> Response: {matched: 3, total_expenses: 15, rules_applied: 2}

Dry Run

POST /tagging/rules/test
-> Shows which expenses WOULD be matched without changing anything
-> Response: {matches: [{expense_id: 5, expense_notes: 'Weekly grocery', matched_rule: 'Grocery Auto'}], total_matches: 1}

Matching Engine

  • notes + contains: case-insensitive substring match
  • notes + equals: exact match
  • amount + gt/lt: numeric comparison
  • expense_type + equals: type match (EXPENSE/INCOME)

Test Coverage (8 tests)

  1. Auth required
  2. Create rule
  3. List rules
  4. Delete rule
  5. Invalid field -> 400
  6. Apply rules categorizes expenses
  7. Dry-run test shows matches
  8. Case-insensitive contains

@rohitdash08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule-based auto tagging & categorization

1 participant