Repository navigation
feat: investment portfolio with Supabase auth, multi-asset tracking, and projections - #4
Merged
Merged
Conversation
…ng, and projections Transform FinForge from a calculator suite into a full investment portfolio app. Backend & Infrastructure - Add Supabase setup (@supabase/supabase-js, @supabase/ssr) - Create SQL migration with 5 tables (profiles, assets, fixed_income_details, transactions, price_cache) + RLS policies + auto-profile trigger - Add supabase/migrations/20251003000000_init.sql Authentication - Login/signup/logout pages with Server Actions - useAuth hook and UserMenu component - Middleware for session refresh Domain & Services (with 39 new Vitest tests) - portfolio.service: average cost, realized/unrealized P&L, partial sells - fixedIncome.service: CDI%, IPCA+, prefixado, maturity - projection.service: month-by-month with contribution/withdrawal/IPCA - allocation.service: diversification + concentration warnings - dividends.service: yield on cost, by month/by asset - priceFetcher.service: CoinGecko + Brapi + Yahoo Finance + AwesomeAPI with 15min cache in price_cache table - currency.service + portfolio-aggregator: BRL+USD aggregation Routes & UI - /login, /signup - /portfolio with sub-pages: holdings, allocation, projection, simulator, dividends, settings - /assets CRUD (stock/etf/fii/crypto/fixed_income/cash) - /transactions CRUD (buy/sell/dividend/income) - Shared PortfolioShell with sidebar + mobile tabs - AssetForm with 6 asset types including FI details - TransactionForm with 4 transaction types - RefreshPricesButton + /api/prices/refresh route - Backup/Restore JSON (export/import) - PortfolioTeaser on dashboard for logged-in users Calculator suite preserved and accessible from dashboard. UI fixes - Complete Tailwind v4 @theme color mapping (popover, accent, muted, secondary, destructive, border, input, ring, sidebar) - Fix Select component transparency with inline style fallback - Fix Recharts in server components (extract to client components) - Fix Supabase middleware to return Response not object - Fix native select bg-transparent across forms
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Vercel build failed with 'Super expression must either be null or function' on /portfolio/allocation because AllocationView.tsx used recharts (class components with browser dependencies) without 'use client' directive. Add 'use client' to AllocationView.tsx. Other recharts components (ProjectionPanel, Simulator, DividendsChart) already had it.
During Vercel build, the Supabase middleware was called for static page prerendering (/compound-interest, /fire-calculator, etc.) and threw 'Your project's URL and API key are required to create a Supabase client!' when env vars weren't configured in Vercel project settings. Make middleware gracefully skip auth refresh when env vars are missing, and wrap getUser() in try/catch to avoid breaking builds on network errors. Pages still work: - Public calculators: don't need auth, render normally - Protected portfolio pages: redirect via layout-level server checks
…v vars
Vercel preview deployments and local builds without .env.local were
failing prerender with:
'Your project's URL and API key are required to create a Supabase client!'
Even pages like /transactions that don't use Supabase auth were failing
because Next.js evaluates module graph for page data collection, and
the UserMenu (used in CalculatorLayout header) calls useAuth which
creates a browser client.
Fix:
- createClient in client.ts and server.ts now return a stub proxy
when env vars are missing instead of throwing
- Proxy chains .from().select().order().limit() and resolves with
{ data: null, error: { message: 'Supabase env vars ausentes' } }
for any await
- Auth methods return error responses
Pages render without Supabase data when env vars are absent (which is
fine for builds/preview), and work normally when env vars are present.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transforms FinForge from a calculator suite into a full investment portfolio app with auth, persistence, and projections.
What's new
Backend & Infrastructure
@supabase/supabase-js+@supabase/ssrAuthentication
/login,/signup, logout via Server ActionsuseAuthhook +UserMenudropdown with avatarDomain & Services (39 new Vitest tests, 116 total passing)
portfolio.service— average cost, P&L realized/unrealized, partial sellsfixedIncome.service— CDI%, IPCA+, prefixado, maturityprojection.service— month-by-month with contributions/withdrawals/IPCAallocation.service— diversification + concentration alerts (>20%)dividends.service— yield on cost, by month / by assetpriceFetcher.service— CoinGecko + Brapi + Yahoo + AwesomeAPI with 15min cachecurrency.service— BRL ↔ USD with USDBRL rate from cacheUI & Routes
/portfoliowith sub-pages: holdings, allocation, projection, simulator, settings/assets(list) +/assets/new+/assets/[id](view/edit/delete)/transactions(list) +/transactions/newPortfolioShellwith sidebar + mobile tabsAssetFormwith 6 types including fixed income detailsTransactionFormwith 4 transaction types (BUY/SELL/DIVIDEND/INCOME)/api/prices/refreshrouteUI fixes bundled
@theme inlinecolor mapping (popover, accent, muted, secondary, destructive, border, input, ring, sidebar)<select>bg-transparentissues across formsSetup
supabase/migrations/20251003000000_init.sqlin SQL Editor.env.localnpm install && npm run devTests