feat: initial finance SPA — phases 1 & 2

Next.js 16 personal finance dashboard connected to postgres-personal.

Phase 1 (Foundation):
- API routes: GET /api/transactions (paginated, filterable, sortable),
  GET /api/statements, GET /api/merchants
- Transactions data table with date/category/bank/search filters, pagination, sort
- Statements card grid with period, due date, amount, transaction count
- Sidebar layout with nav for all planned sections

Phase 2 (Normalisation):
- PATCH /api/transactions/[id] — upsert transaction_overrides
- POST /api/transactions/bulk — bulk categorize/normalize
- Inline click-to-edit category (22 options) and merchant name
- Blue dot override indicator, bulk action bar
- Effective values via COALESCE(override, llm_value) pattern

Stack: Next.js 16 (App Router, standalone), Prisma 7.x + @prisma/adapter-pg,
TanStack Query, Tailwind CSS. Auth via Traefik chain-oauth@file.
This commit is contained in:
2026-03-07 23:31:40 +11:00
parent 28207b42b5
commit 35a5be97b0
31 changed files with 2243 additions and 99 deletions
+46
View File
@@ -0,0 +1,46 @@
import { NextRequest, NextResponse } from "next/server";
import { getTransactionById } from "@/lib/queries";
import { prisma } from "@/lib/db";
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const txn = await getTransactionById(Number(id));
if (!txn) return NextResponse.json({ error: "Not found" }, { status: 404 });
return NextResponse.json(txn);
}
export async function PATCH(
req: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const transactionId = Number(id);
const body = await req.json();
const { category, merchant_normalized, notes } = body as {
category?: string;
merchant_normalized?: string;
notes?: string;
};
const data: Record<string, unknown> = { updated_at: new Date() };
if (category !== undefined) data.category_override = category;
if (merchant_normalized !== undefined) data.merchant_normalized = merchant_normalized;
if (notes !== undefined) data.notes = notes;
const override = await prisma.transaction_overrides.upsert({
where: { transaction_id: transactionId },
update: data,
create: {
transaction_id: transactionId,
category_override: category || null,
merchant_normalized: merchant_normalized || null,
notes: notes || null,
},
});
return NextResponse.json(override);
}