How traejiik/pocketbook works
Pocketbook is a self-hosted personal-finance tracker. A user signs in, reviews dashboard and ledger data, and records or imports transactions; recurring rules, renewals, categories, and settings support that ledger. Server-rendered pages read finance data, while Server Actions perform mutations and refresh cached views. Scheduled jobs sync FX rates, log due recurring charges, and can generate monthly insights; on-demand insights stream from a local Ollama model and are saved for history. The tree and excerpts support the main entry points and some handlers, but not every page-to-action connection.
Main entry points: prisma.ts PostgreSQL · stream/route.ts Insight stream · monthly/route.ts Monthly generation · scheduler.ts UTC scheduler
Components 26
Access and finance UI
- Sign in
app/(auth)/login/page.tsx - Finance workspace
app/(app)/layout.tsx - Dashboard
app/(app)/dashboard/page.tsx
Ledger management
- Transactions
app/(app)/transactions/page.tsx - Categories
app/(app)/categories/page.tsx - Recurring rules
app/(app)/recurring/page.tsx - Renewal radar
app/(app)/renewals/page.tsx - Import review
components/import/TransactionImportReview.tsx - Recurring import review
components/import/RecurringImportReview.tsx - Transaction actions
server-actions/transactions.ts - Import actions
server-actions/import.ts - Recurring actions
server-actions/recurring.ts - Category actions
server-actions/categories.ts
Private insights
- Monthly insights
app/(app)/insights/page.tsx - Insight stream
app/api/insights/stream/route.ts - Monthly generation
app/api/insights/monthly/route.ts - Insight generation
lib/insights-generation.ts
Scheduled operations
- UTC scheduler
runtime/scheduler.ts - FX sync endpoint
app/api/fx/sync/route.ts - FX rate sync
lib/frankfurter.ts - Recurring sync endpoint
app/api/recurring/sync/route.ts - Due-rule processing
lib/recurring-sync.ts - Discord notifications
lib/notifications/send.ts
Other components
- Finance user
- Ollama model
- PostgreSQL
lib/prisma.ts
Connections 29
- Finance user → Sign in: signs in
- Sign in → Finance workspace: opens
- Finance workspace → Dashboard: renders
- Dashboard → PostgreSQL: reads finance data
- Transactions → PostgreSQL: reads ledger
- Categories → PostgreSQL: reads categories
- Recurring rules → PostgreSQL: reads rules
- Renewal radar → PostgreSQL: reads upcoming
- Import review → Import actions: commits rows
- Recurring import review → Import actions: commits rules
- Recurring import review → Category actions: creates category
- Transaction actions → PostgreSQL: writes ledger
- Recurring actions → PostgreSQL: writes rules
- Category actions → PostgreSQL: writes categories
- Import actions → PostgreSQL: writes imports
- Monthly insights → Insight stream: requests stream
- Insight stream → Insight generation: builds prompt
- Insight stream → Ollama model: streams generation
- Insight stream → PostgreSQL: saves insight
- UTC scheduler → FX sync endpoint: calls sync
- FX sync endpoint → FX rate sync: syncs rates
- FX rate sync → PostgreSQL: stores rates
- UTC scheduler → Recurring sync endpoint: calls sync
- Recurring sync endpoint → Due-rule processing: processes due rules
- Due-rule processing → PostgreSQL: writes transactions
- UTC scheduler → Monthly generation: triggers monthly
- Monthly generation → Insight generation: generates note
- Monthly generation → PostgreSQL: reads settings
- Monthly generation → Discord notifications: sends alert