How theboywai/blackbook works
1. Overall shape
This is a Vite + React single-page app with a small serverless API surface under api/, backed by Supabase. The browser app handles all user-facing finance workflows; Supabase is the system of record for auth and persisted finance data.
2. Application shell and routing
src/main.jsx, src/App.jsx, and src/pages/* define the client app’s route-level structure. src/components/Layout.jsx is the persistent shell: it provides navigation, the sticky status area, and shared chrome around all pages.
3. Authentication boundary
src/hooks/useAuth.js plus src/lib/supabase.js implement email/password login, session persistence, and protected-route behavior. src/pages/Login.jsx, Setup.jsx, and Settings.jsx sit on the auth/onboarding edge, while the rest of the pages assume an authenticated session.
4. State access and domain hooks
The app uses feature-specific hooks as the main data-access layer: useDashboard, useTransactions, useBudgets, useCategories, useCorpus, useReview, useLastUpload, and useTrips. These hooks encapsulate fetching, mutation, and derived state so pages stay mostly declarative.
5. Domain model and schema-aligned data files
src/data/* mirrors the finance domain: accounts, budgets, categories, investments, merchants, splits, transactions, trips, and uploads. These files act as canonical shapes/seed data for the UI and analytics logic, while src/constants/categories.js centralizes categorization taxonomy.
6. Analytics and metric computation layer
src/analytics/* is the calculation engine for dashboards and reports. It computes summaries such as overview KPIs, spend breakdowns, budget performance, trends, corpus/investment views, and insights; the UI consumes these derived outputs rather than raw rows.
7. Dashboard and shared UI components
src/pages/Dashboard.jsx combines KPI cards, charts, insight cards, budget bars, top merchants, and weekly history. Shared primitives in src/components/*—for example KPICard, SpendChart, InsightCard, TxnRow, Tooltip, and Card—form the reusable presentation layer across the app.
8. Transaction and review workflow
src/pages/Transactions.jsx shows the full ledger with search, category/direction filtering, and running net. src/pages/Review.jsx is the exception-handling queue where uncategorized or uncertain transactions are assigned categories; it also supports merchant promotion, which writes UPI/merchant metadata back to the database.
9. Budget control and configuration
src/pages/Budget.jsx and src/pages/Settings.jsx are the budget-management boundary. The budget page aggregates corpus, account-level cards, month-to-date totals, safe-to-spend, and projection; settings lets users edit budget limits inline and persist them immediately.
10. Ingestion, assistant, and deployment surfaces
The repo includes api/upload.js and api/finance-chat.js as serverless endpoints, with a separate api/package.json indicating a Node runtime boundary distinct from the SPA. The README also describes an upstream ingestion pipeline that converts PDFs through validation/categorization into Supabase, with reconciliation, deduplication, and internal-transfer detection; the UI’s sync indicator and review badge reflect that ingestion state. Deployment is configured for Vercel via vercel.json, and the app expects environment-backed Supabase credentials from .env.example.
Main entry points: App.jsx Router · Dashboard.jsx Dashboard · Budget.jsx Budget · Review.jsx Review
Components 31
App shell
Client entry, routing, and shared UI chrome.
Auth boundary
Session handling and auth-adjacent screens.
- Login · Email/password sign-in surface.
src/pages/Login.jsx - Setup · Initial account and profile setup.
src/pages/Setup.jsx - Settings · Budget and account configuration boundary.
src/pages/Settings.jsx - Auth hook · Session persistence and protected-route behavior.
src/hooks/useAuth.js - Supabase · System of record for auth and persisted finance data.
src/lib/supabase.js
Domain layer
Feature hooks and canonical finance data shapes.
- Dashboard · Main KPI and insight view.
src/pages/Dashboard.jsx - Transactions · Full transaction list with filters and running net.
src/pages/Transactions.jsx - Review · Categorization and merchant promotion workflow.
src/pages/Review.jsx - Budget · Budget control and safe-to-spend view.
src/pages/Budget.jsx - Investments · Corpus and investment view.
src/pages/Investments.jsx - Travel · Trip-oriented finance and tracking view.
src/pages/Travel.jsx - Upload · Document upload and sync surface.
src/pages/Upload.jsx - Assistant · Finance chat interface over the app data.
src/pages/FinanceAssistant.jsx - Feature hooks · Feature-specific fetching, mutation, and derived state hooks.
- Finance data · Canonical finance records and seed-aligned data files.
- Categories · Central categorization rules and labels.
src/constants/categories.js
Analytics engine
Derived metrics and reporting computations.
- Overview calc · Dashboard KPIs and summary computations.
src/analytics/overview.js - Spend calc · Spending breakdown and category analysis.
src/analytics/spend.js - Budget calc · Budget performance and projection logic.
src/analytics/budget.js - Trend calc · Temporal trends and weekly history.
src/analytics/trends.js - Corpus calc · Net worth and corpus views.
src/analytics/corpus.js - Insights · Derived recommendations and notable signals.
src/analytics/insights.js - Invest calc · Investment-related derived outputs.
src/analytics/investments.js
API and deploy
Serverless endpoints and runtime/deployment config.
- Upload API · Upload ingestion endpoint.
api/upload.js - Chat API · Assistant/chat endpoint.
api/finance-chat.js - API runtime · Separate Node package/runtime boundary for serverless functions.
api/package.json - Vite config · Client build and dev-server configuration.
vite.config.js - Vercel config · Deployment configuration for the hosted app.
vercel.json
Connections 44
- Entry → Router: mounts · Bootstraps the routed application.
- Router → Layout: wraps · All pages render inside the shared shell.
- Router → Login: routes · Public auth entry point.
- Router → Setup: routes · Onboarding flow.
- Router → Settings: routes · Config and account settings.
- Router → Dashboard: routes · Primary app landing page.
- Router → Transactions: routes · Ledger view.
- Router → Review: routes · Exception handling queue.
- Router → Budget: routes · Budget management page.
- Router → Investments: routes · Portfolio page.
- Router → Travel: routes · Trip finance page.
- Router → Upload: routes · Ingestion surface.
- Router → Assistant: routes · Chat assistant page.
- Login → Auth hook: uses · Sign-in and session handling.
- Setup → Auth hook: uses · Requires authenticated session.
- Settings → Auth hook: uses · Protected settings flow.
- Auth hook → Supabase: authenticates · Session and credentials are managed through Supabase.
- Feature hooks → Supabase: reads/writes · Feature hooks coordinate persistence and fetches.
- Dashboard → Feature hooks: consumes · Reads dashboard state through feature hooks.
- Dashboard → Overview calc: derives · KPI and summary computations.
- Dashboard → Spend calc: derives · Spend breakdowns and charts.
- Dashboard → Trend calc: derives · Weekly and time-series views.
- Dashboard → Insights: derives · Insight cards.
- Transactions → Feature hooks: consumes · Ledger data and filters.
- Review → Feature hooks: consumes · Review queue and mutation actions.
- Review → Categories: applies · Assigns canonical categories and merchant metadata.
- Budget → Feature hooks: consumes · Budget state and inline edits.
- Budget → Budget calc: derives · Budget bars, projections, and safe-to-spend.
- Budget → Corpus calc: derives · Corpus context for budget planning.
- Investments → Feature hooks: consumes · Investment and corpus data.
- Investments → Invest calc: derives · Portfolio-specific metrics.
- Travel → Feature hooks: consumes · Trip-related data.
- Upload → Upload API: calls · Submits document ingestion requests.
- Assistant → Chat API: calls · Requests finance chat completions.
- Upload API → API runtime: runs in · Serverless Node runtime boundary.
- Chat API → API runtime: runs in · Serverless Node runtime boundary.
- Vite config → Entry: builds · Client bundling and dev server configuration.
- Vercel config → Upload API: deploys · Exposes serverless endpoints in deployment.
- Vercel config → Chat API: deploys · Exposes serverless endpoints in deployment.
- Finance data → Categories: aligns · Domain records follow the shared categorization model.
- Finance data → Feature hooks: feeds · Hooks read and shape canonical finance records.
- Finance data → Review: supports · Review workflow acts on transaction and merchant data.
- Finance data → Budget calc: feeds · Budget metrics consume canonical finance records.
- Finance data → Corpus calc: feeds · Corpus metrics consume canonical finance records.