How ferxodj/cash-flow-supabase works
1. This is a single Next.js App Router application that serves both the UI and the backend. The repository is organized around app/, with pages, layouts, client components, and a large set of server route.ts handlers under app/api/.
2. The UI is split into two major product modes:
- home_finanzas_solo for personal finances.
- home_finanzas_parejas for shared/couple finances.
These have their own shells, sidebars, dashboards, charts, and section pages, so the architecture is intentionally domain-separated at the route and component level.
3. The public/auth surfaces are small but important: landing pages, a not-authenticated screen, auth callback handling, password reset, and couple invitation acceptance/rejection flows. The repo also has dedicated routes for login/logout/me and OAuth/session management.
4. The backend is mostly API-first. The app/api/ tree exposes CRUD and summary endpoints for finance entities such as incomes, savings, debts, investments, budget categories, fx losses, user preferences/goals, and profile data. Many endpoints are grouped by domain, with nested routes for actions like withdraw, revert, analytics, monthly summaries, and item-by-id operations.
5. There are two data domains with different boundaries:
- Solo finances: incomes, savings, investments, budget distribution, losses, profile, and personal analytics.
- Couple finances: invite/accept/reject lifecycle, shared views, annual panel, combined net summary, shared budget, debts, and notification management.
This is the main architectural split in the app.
6. Persistence is backed by Supabase. The repo includes app/lib/supabase.ts for client access and app/lib/supabaseAdmin.ts for privileged server-side operations, plus SQL schema files in supabase/. That suggests the app uses Supabase Postgres as the system of record, with some routes requiring elevated access for administrative actions or password/email flows.
7. Authentication and authorization are handled across the app by session utilities and middleware. The presence of middleware.ts, app/lib/session.ts, and the session/profile routes indicates route protection, user identity propagation, and request-time access checks are central to the architecture.
8. Notifications are a first-class backend subsystem. Debt alerts are sent through app/api/debts/notify and app/api/cron/debts-notify, with the README describing Vercel Cron integration and anti-spam tracking via a notifications table. Email delivery is abstracted behind app/lib/mailer.ts.
9. Reporting and analytics are implemented as server-backed summary endpoints plus client chart components. Examples include annual panels, net summary, monthly income/savings views, investment analytics, and budget distribution charts. The UI generally fetches aggregated data from API routes rather than computing everything client-side.
10. There is also a data export path: app/api/export/csv produces CSV output from financial data, which means the backend exposes a reporting boundary separate from the dashboard views.
11. Shared UI infrastructure lives in app/components/ and the various lib/ helpers. These include global loading, headers, access inputs/cards, fetch-header installers, and navigation blockers, which support the app shell and cross-cutting UX behavior rather than a single business domain.
12. Deployment/runtime assumptions matter here: the app is designed for Vercel, with cron support declared in vercel.ts and environment variables for Supabase, session secrets, cron authorization, and optional mail/reset flows. The repo is therefore a serverless Next.js app with Supabase as the main backend service and Vercel as the hosting/scheduling layer.
Main entry points: invite/route.ts Couple finance API · app/page.tsx App root · notify/route.ts Notifications · home_finanzas_solo/page.tsx Solo mode
Components 20
UI routes
Public pages and the two finance product modes
- App root · Top-level App Router entrypoint and route composition
app/page.tsx - Public pages · Landing, unauthenticated, auth callback, and password reset surfaces
app/no_autenticado/page.tsx - Solo mode · Standalone personal-finance shell and route set
app/home_finanzas_solo/page.tsx - Couple mode · Shared/couple-finance shell and route set
app/home_finanzas_parejas/page.tsx - Solo shell · Sidebar and layout wrapper for personal-finance views
app/home_finanzas_solo/components/HomeSoloShell.tsx - Couple shell · Sidebar and layout wrapper for couple-finance views
app/home_finanzas_parejas/components/HomeParejasShell.tsx - Solo dashboards · Annual panel, savings, investments, budget, transactions, and profile screens
app/home_finanzas_solo/panel_anual/page.tsx - Couple dashboards · Annual panel, savings, debts, investments, budget, notifications, and profile screens
app/home_finanzas_parejas/panel_anual/page.tsx - Couple invite flow · Accept/reject invitation and registration-linked couple flows
app/pareja/aceptar/page.tsx
API routes
Server-side endpoints grouped by domain
- Session API · Login, logout, me, and OAuth session endpoints
app/api/session/login/route.ts - Profile API · Profile read/update, password, and email-change endpoints
app/api/profile/me/route.ts - Solo finance API · Incomes, savings, investments, budget 50/30/20, FX losses, goals, preferences, and exports
app/api/incomes/route.ts - Couple finance API · Couple invite lifecycle, shared views, annual panel, net summary, notifications, and shared budgets/debts
app/api/couple/invite/route.ts - Notifications · Debt notification endpoint and cron-driven notification job
app/api/debts/notify/route.ts
Shared infra
Cross-cutting components and server helpers
- Supabase client · Browser/server Supabase access helper
app/lib/supabase.ts - Supabase admin · Server-only elevated Supabase helper for protected flows
app/lib/supabaseAdmin.ts - Session utils · Session propagation, request-time checks, and middleware support
app/lib/session.ts - Mailer · Email transport used by password reset, invitations, and account flows
app/lib/mailer.ts
Data/runtime
Persistence schema and deployment/runtime config
- Supabase SQL · Database schema and seed/migration SQL for the finance domains
supabase/finanzas.sql - Vercel runtime · Deployment, environment variables, and scheduled cron execution
vercel.ts
Connections 22
- App root → Public pages: routes · App-level public entrypoints
- App root → Solo mode: routes · Personal-finance product area
- App root → Couple mode: routes · Shared-finance product area
- Solo mode → Solo shell: uses · Solo views render within the personal shell
- Couple mode → Couple shell: uses · Couple views render within the shared shell
- Solo mode → Solo dashboards: contains · Solo mode sections and dashboards
- Couple mode → Couple dashboards: contains · Couple mode sections and dashboards
- Couple invite flow → Couple finance API: invites · Invitation acceptance/rejection is backed by couple APIs
- Session API → Session utils: uses · Session routes depend on shared auth/session helpers
- Profile API → Session utils: uses · Account operations are protected by session checks
- Solo finance API → Supabase client: reads/writes · Personal-finance endpoints access database data
- Couple finance API → Supabase client: reads/writes · Shared-finance endpoints access database data
- Profile API → Supabase admin: privileged · Email/password/profile flows may need elevated access
- Notifications → Supabase admin: checks · Notification anti-spam and job actions use server privileges
- Notifications → Mailer: sends · Debt alerts are delivered by email
- Solo finance API → Supabase SQL: persists · Solo finance data is stored in Supabase Postgres
- Couple finance API → Supabase SQL: persists · Couple finance data is stored in Supabase Postgres
- Session API → Vercel runtime: runs on · Auth and cron flows are deployed on Vercel
- Notifications → Vercel runtime: scheduled by · Debt notification checks are cron-triggered
- Public pages → Session API: auth · Public surfaces connect into session management
- Solo dashboards → Solo finance API: fetches · Solo dashboards consume aggregated API data
- Couple dashboards → Couple finance API: fetches · Couple dashboards consume aggregated API data