A personal portfolio tracker PWA built with Next.js and Supabase for tracking stocks, crypto, real estate, and custom investments.
trackfolio/
βββ webapp/ # Next.js PWA application
β βββ src/
β β βββ app/ # Next.js 14 App Router
β β βββ components/ # React components
β β βββ lib/ # Utilities, Supabase client, types
β β βββ middleware.ts # Auth middleware
β βββ public/ # Static assets, PWA manifest
β βββ package.json
βββ database/ # Database schemas and scripts
β βββ database-setup.sql # Main database schema
β βββ row-level-security.sql # RLS policies
β βββ sample-data.sql # Test data
β βββ test-queries.sql # Validation queries
βββ docs/ # Documentation
βββ spec.md # Technical specification
βββ SETUP-INSTRUCTIONS.md # Database setup guide
- Multi-Asset Support: Stocks, ETFs, crypto, real estate, collectibles, cash
- Transaction Management: Buy/sell/dividend/bonus transactions with full history
- Custom Investments: Add your own assets (real estate, private companies, collectibles)
- Manual Pricing: Override market prices with your own valuations
- Portfolio Analytics: P&L, daily changes, performance metrics
- PWA Support: Install on mobile devices, offline-first design
- Next.js 14 with App Router and TypeScript
- Supabase for database, auth, and real-time updates
- Tailwind CSS for responsive design
- Google OAuth authentication
- Row-level security for multi-user data isolation
- Automatic Price Updates with Alpha Vantage API and Vercel cron
- Mock data for testing without database connection
The app includes comprehensive mock data for testing:
- Stocks: AAPL, MSFT (traditional investments)
- Crypto: Bitcoin (with manual price override)
- Real Estate: Primary residence ($465K)
- Collectibles: Vintage Rolex collection ($13K)
- Private Equity: Startup shares with custom valuation
- Cash: Available balance
# Install all dependencies
npm run setup
# Start development server
npm run dev
# Test automatic price updates
npm run update-daily-pricesVisit http://localhost:3000
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintnpm run setup # Install all dependencies
npm run install:webapp # Install webapp dependencies only
npm run clean # Clean build files and reinstallnpm run update-daily-prices # Update daily prices locally
npm run update-daily-prices:local # Update against local server
npm run update-daily-prices:prod # Update against production# Backfill historical price data for specific symbols
npm run backfill-symbol:local SYMBOL # Against local server
npm run backfill-symbol:prod SYMBOL # Against production
# Examples:
npm run backfill-symbol:local AAPL # Backfill Apple stock history
npm run backfill-symbol:prod MSFT # Backfill Microsoft history (prod)
npm run backfill-symbol:local BTC # Backfill Bitcoin history- Create a Supabase project at supabase.com
- Follow the detailed guide in
docs/SETUP-INSTRUCTIONS.md - Run the SQL scripts in this order:
database/database-setup.sqldatabase/row-level-security.sqldatabase/sample-data.sql(after updating user UUID)
# Copy environment template (from root directory)
cp webapp/.env.example webapp/.env.local
# Edit webapp/.env.local with your credentialsRequired environment variables:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Price Data API (Alpha Vantage)
ALPHA_VANTAGE_API_KEY=your_api_key
ALPHA_VANTAGE_PLAN=free
# Cron Job Security
CRON_SECRET=your_secure_random_string- Supabase: Create project at supabase.com
- Alpha Vantage: Get free API key at alphavantage.co
The app automatically fetches daily market prices using a Vercel cron job:
- Schedule: Daily at 9 PM UTC (4 PM EST, after US market close)
- Source: Alpha Vantage API (25 free requests/day)
- Security: Protected with authorization headers
- Coverage: Updates all non-custom symbols automatically
# Test locally (requires dev server running)
npm run update-daily-prices
# Test against production deployment
npm run update-daily-prices:prodFor new symbols or to populate historical data, use the backfill functionality:
- Symbol-by-symbol processing: Backfills one symbol at a time for precise control
- Full historical data: Fetches complete price history from Alpha Vantage (20+ years)
- Duplicate handling: Automatically detects and skips existing records
- Update existing records: Refreshes outdated historical data
- Custom symbol validation: Verifies symbol exists in database before processing
# Local development backfill
npm run backfill-symbol:local AAPL
# Production backfill
npm run backfill-symbol:prod MSFT
# Direct script usage with custom URL
cd webapp
node scripts/backfill-symbol.js https://your-app.vercel.app SYMBOLπ Starting historical price backfill for symbol: AAPL
π Retrieved 5847 historical price records for AAPL
πΎ Inserted 5847 price history records
π Updated last_price for 1 symbols
β
Backfill completed successfully!
- Symbol must exist in the database (add via UI first)
- Secrets are configured
- Only works with non-custom symbols (market-traded assets)
- Email:
test@trackfolio.com - Password:
testpassword123
Configure in Supabase Dashboard > Authentication > Providers
transactions- All portfolio transactionssymbols- Asset symbols (public + user custom)user_symbol_prices- Manual price overridessymbol_price_history- Historical market prices from APIs
buy- Asset purchasessell- Asset salesdividend- Dividend paymentsbonus- Free shares receiveddeposit- Cash additionswithdrawal- Cash withdrawals
stock- Public stocksetf- Exchange-traded fundscrypto- Cryptocurrenciesreal_estate- Real estate holdingscash- Cash positionsother- Custom assets (collectibles, private equity, etc.)
- Custom Assets: Use descriptive symbols like
MY_HOUSEorROLEX_COLLECTION - Manual Pricing: Perfect for real estate, collectibles, private investments
- Transaction History: Record all historical transactions for accurate P&L
- Mobile First: Designed for mobile use with PWA installation
- PWA Ready: Installable on mobile devices
- Offline Support: Works without internet connection
- Type Safe: Full TypeScript coverage
- Responsive: Mobile-first design with desktop support
- Scalable: Built for personal use, easily extensible
Personal project - use as you wish!
Built with β€οΈ for personal portfolio tracking