Feature: Add AI-Powered Categorization section to Recategorize page

Add new card for AI categorization alongside rule-based:
- Rename existing section to "Rule-Based Categorization"
- Add "AI-Powered Categorization" section with provider badge
- Link to AICategorizePreview for AI category suggestions
- Display explanation of how AI categorization works
- Inject IConfiguration to read AI provider setting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 22:53:16 -05:00
parent f72c32c52f
commit 9fbbeca1e6
2 changed files with 55 additions and 3 deletions

View File

@@ -48,10 +48,10 @@
<div class="card shadow-sm mb-3">
<div class="card-header">
<strong>Auto-Categorize Existing Transactions</strong>
<strong>Rule-Based Categorization</strong>
</div>
<div class="card-body">
<p>Use the category mappings to automatically categorize transactions that are already in your database.</p>
<p>Use the category mappings to automatically categorize transactions based on pattern matching.</p>
<div class="row g-3">
<div class="col-md-6">
@@ -87,6 +87,51 @@
</div>
</div>
<div class="card shadow-sm mb-3">
<div class="card-header d-flex justify-content-between align-items-center">
<strong>AI-Powered Categorization</strong>
<span class="badge bg-info">@Model.AIProvider</span>
</div>
<div class="card-body">
<p>Use AI to analyze transaction names and suggest categories. High-confidence matches will automatically create new mapping rules for future use.</p>
<div class="row g-3">
<div class="col-md-6">
<div class="border rounded p-3 h-100">
<h5 class="mb-3">AI Categorize Uncategorized</h5>
<p class="text-muted small">
Process up to 50 uncategorized transactions. Review AI suggestions before applying.
</p>
@if (Model.Stats.Uncategorized > 0)
{
<a asp-page="/AICategorizePreview" class="btn btn-success">
AI Categorize with Preview
</a>
}
else
{
<button type="button" class="btn btn-success" disabled>
AI Categorize with Preview
</button>
}
</div>
</div>
<div class="col-md-6">
<div class="border rounded p-3 h-100">
<h5 class="mb-3">How AI Categorization Works</h5>
<ul class="text-muted small mb-0">
<li>AI analyzes transaction name, memo, and amount</li>
<li>Suggests category and canonical merchant name</li>
<li>Creates pattern rules for 70%+ confidence matches</li>
<li>Future transactions auto-match the new rules</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="card shadow-sm">
<div class="card-header">
<strong>How It Works</strong>

View File

@@ -11,15 +11,22 @@ namespace MoneyMap.Pages
private readonly MoneyMapContext _db;
private readonly ITransactionCategorizer _categorizer;
private readonly ITransactionStatisticsService _statsService;
private readonly IConfiguration _config;
public RecategorizeModel(MoneyMapContext db, ITransactionCategorizer categorizer, ITransactionStatisticsService statsService)
public RecategorizeModel(
MoneyMapContext db,
ITransactionCategorizer categorizer,
ITransactionStatisticsService statsService,
IConfiguration config)
{
_db = db;
_categorizer = categorizer;
_statsService = statsService;
_config = config;
}
public RecategorizeStats Stats { get; set; } = new();
public string AIProvider => _config["AI:CategorizationProvider"] ?? "OpenAI";
[TempData]
public string? SuccessMessage { get; set; }