- Database: Add login_history, ai_recommendation_log tables; is_platform_owner column on users; subscription fields on organizations (payment_date, confirmation_number, renewal_date) - Backend: New AdminAnalyticsService with platform metrics, tenant detail, and health score calculations (0-100 based on activity, budget, transactions, members, AI usage) - Backend: Login/org-switch now records to login_history; AI recommendations logged to ai_recommendation_log; platform owner protected from superadmin toggle - Frontend: 4-tab admin panel (Dashboard, Organizations, Users, Tenant Health) with tenant detail drawer, subscription management, health scoring visualization - Platform owner account (admin@hoaledgeriq.com) auto-redirects to admin panel - Seed data includes platform owner account and sample login history Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HOA LedgerIQ - Scripts
Standalone scripts for data fetching, maintenance, and automation tasks.
CD Rate Fetcher
Scrapes the top 25 CD rates from Bankrate.com and stores them in the shared.cd_rates PostgreSQL table.
Note: Bankrate renders rate data dynamically via JavaScript, so this script uses Puppeteer (headless Chrome) to fully render the page before extracting data.
Prerequisites
- Node.js 20+
- PostgreSQL with the
shared.cd_ratestable (created bydb/init/00-init.sqlordb/migrations/005-cd-rates.sql) - A
.envfile at the project root withDATABASE_URL
Manual Execution
cd scripts
npm install
npx tsx fetch-cd-rates.ts
Cron Setup
To run daily at 6:00 AM:
# Edit crontab
crontab -e
# Add this line (adjust path to your project directory):
0 6 * * * cd /path/to/HOA_Financial_Platform/scripts && /usr/local/bin/npx tsx fetch-cd-rates.ts >> /var/log/hoa-cd-rates.log 2>&1
For Docker-based deployments, you can use a host cron job that executes into the container:
0 6 * * * docker exec hoa-backend sh -c "cd /app/scripts && npx tsx fetch-cd-rates.ts" >> /var/log/hoa-cd-rates.log 2>&1
Troubleshooting
- 0 rates extracted: Bankrate likely changed their page structure. Inspect the page DOM in a browser and update the CSS selectors in
fetch-cd-rates.ts. - Database connection error: Verify
DATABASE_URLin.envpoints to the correct PostgreSQL instance. For local development (outside Docker), uselocalhost:5432instead ofpostgres:5432. - Puppeteer launch error: Ensure Chromium dependencies are installed. On Ubuntu:
apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 libasound2