Improve monthly insights: structured prompt, bullet recommendations, visual cards

- Strengthen prompt with required observations (savings rate, spend-to-income,
  top category, anomaly), dollar-formatted amounts, and pay schedule context
- Preserve recommendation array structure; store as JSON array string in DB
- Render recommendations as numbered cards with icons in home dashboard
- Add spend-vs-income progress bar and category flow mini bar chart
- Fix test assertions for new JSON array recommendation format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 17:20:03 -04:00
parent 5a6d03f5c8
commit 27bb8df513
3 changed files with 154 additions and 26 deletions

View File

@@ -18,6 +18,7 @@ vi.mock("@/lib/db", () => {
db: {
expense: { findMany: vi.fn() },
paycheck: { findMany: vi.fn() },
paySchedule: { findFirst: vi.fn().mockResolvedValue(null) },
monthlyInsight,
},
};
@@ -86,7 +87,7 @@ describe("generateMonthlyInsight", () => {
expect(result.source).toBe("model");
expect(result.insight.summary).toBe("Spending is stable.");
expect(result.insight.recommendations).toBe("Keep food spending under watch.");
expect(result.insight.recommendations).toBe('["Keep food spending under watch."]');
});
it("coerces array recommendations from the local model", async () => {