Skip to content

Timcai06/Earnlytics

Repository files navigation

Earnlytics

AI-driven US tech company earnings analysis platform with Chinese summaries.

Production: https://earnlytics-ebon.vercel.app
Last Updated: 2026-02-27

๐ŸŽฏ Current Progress

Phase Status Completion Key Achievements
Plan 1: MVP โœ… Complete 100% 10 pages, Vercel deployed
Plan 2: AI Automation โœ… Complete 100% DeepSeek AI, 23 earnings analyzed, GitHub Actions
Plan 3: Scale โœ… Complete 100% 30 companies, 109 earnings, 100% AI coverage, email subscription
RAG AI Assistant โœ… Complete 100% Vector search, multi-turn dialogue, dynamic suggestions
Portfolio Optimization โœ… Complete 100% Real-time prices, glassmorphism design, auto-refresh

Database Status

  • Companies: 30 (Tier 1/2/3) - scripts support tier2/tier3 insertion
  • Earnings: 109 records - scripts for backfilling and seeding
  • AI Analyses: 100% coverage - analyze-batch.ts script available
  • Document Embeddings: Vector data populated - 1024-dim Cohere embeddings
  • Chat Conversations: Ready for AI assistant - multi-turn dialogue support
  • Subscribers: Ready (API + UI complete) - send-digests.ts script exists

๐Ÿ“‚ Project Structure

earnlytics/
โ”œโ”€โ”€ AGENTS.md                 # AI assistant knowledge base (updated 2026-02-11)
โ”œโ”€โ”€ README.md                 # This file
โ”œโ”€โ”€ .gitignore                # Root gitignore (minimal)
โ”œโ”€โ”€ doc/                      # Chinese documentation
โ”‚   โ”œโ”€โ”€ ่ฎกๅˆ’/                 # Execution plans (Plan 1-5)
โ”‚   โ”œโ”€โ”€ ็ญ–็•ฅ/                 # Strategy docs
โ”‚   โ”œโ”€โ”€ ๆŠ€ๆœฏ/                 # Technical docs
โ”‚   โ””โ”€โ”€ ้กน็›ฎ็Šถๆ€ๆŠฅๅ‘Š-20260210.md # Current status report
โ”œโ”€โ”€ earnlytics-web/           # Next.js 16 frontend โฌ…๏ธ Main codebase
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ app/             # App Router pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ earnings/[symbol]/ # Dynamic route for earnings
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ companies/   # Company list page
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ calendar/    # Earnings calendar
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ assistant/   # AI assistant (RAG chat) โœจ
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ portfolio/   # Portfolio management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ privacy/     # Privacy policy
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ terms/       # Terms of service
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api/         # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/          # shadcn/ui primitives
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ icons/       # SVG icon library (replaced all emoji)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ layout/      # Header, Footer
โ”‚   โ”‚   โ””โ”€โ”€ lib/             # Utilities (ai.ts, supabase.ts)
โ”‚   โ”œโ”€โ”€ scripts/             # 24 data scripts
โ”‚   โ”‚   โ”œโ”€โ”€ fetch-earnings.ts
โ”‚   โ”‚   โ”œโ”€โ”€ analyze-batch.ts
โ”‚   โ”‚   โ”œโ”€โ”€ generate-embeddings.ts  # Vector generation โœจ
โ”‚   โ”‚   โ”œโ”€โ”€ backfill-tier2.ts
โ”‚   โ”‚   โ””โ”€โ”€ send-digests.ts
โ”‚   โ””โ”€โ”€ supabase/migrations/ # Database schema
โ””โ”€โ”€ pencil-earnlytics.pen    # Design file (13 pages)

๐Ÿš€ Quick Start

# Frontend development
cd earnlytics-web && npm run dev          # Start dev server (localhost:3000)

# Data Operations
npm run fetch:earnings                    # Fetch latest earnings from FMP
npm run analyze:batch                     # Generate AI analysis (batch of 5)
npm run generate:embeddings               # Generate vector embeddings for RAG

# Build & Deploy
npm run build                             # Production build
npm run lint                              # Lint check

๐Ÿ›  Tech Stack

Layer Technology Version
Frontend Next.js 16.1.6
Frontend React 19.2.3
Frontend TypeScript 5
Styling Tailwind CSS 4
UI Components shadcn/ui Latest
Icons Lucide React + Custom SVG Latest
Path alias @/* โ†’ ./src/* -

Backend & Infrastructure

  • Hosting: Vercel Serverless
  • Database: Supabase PostgreSQL + pgvector
  • AI Service: DeepSeek API (ยฅ0.002/1K tokens)
  • Embedding: Cohere Embedding API (1024-dim, free tier)
  • Data Source: Financial Modeling Prep (FMP) API + SEC EDGAR
  • Automation: GitHub Actions (every 4 hours)

โšก Performance Updates (2026-02-27)

  • /home now uses server-side prefetch + cache (revalidate=300) to reduce client waterfall.
  • Added dynamic imports and viewport-triggered rendering for below-the-fold sections.
  • HeroStats counters start only when entering viewport.
  • MarketTicker animation pauses when tab hidden/offscreen to reduce CPU usage.
  • EarningsCard optimized with memo + memoized sparkline generation.
  • /api/market-ticker now supports in-memory short cache + ETag / 304.
  • Added Web Vitals collection pipeline:
    • client reporter: src/components/performance/WebVitalsReporter.tsx
    • API endpoint: src/app/api/web-vitals/route.ts (POST ingest + GET summary)
  • Added image optimization helper src/lib/image-optimization.ts to avoid unnecessary unoptimized.

๐Ÿ—‚ Architecture Docs Note

  • Legacy root doc earnlytics-web-architecture.md has been removed.
  • Use for_AGENTS/AGENTS.md and for_AGENTS/่ง„่Œƒๆ–‡ๆกฃ/* as the canonical architecture and implementation references.

๐Ÿ“‹ Development Plans (Based on Actual Code)

Phase Timeline Goal Status Evidence in Code
Plan 1: MVP Week 1-2 10 pages, 10 companies โœ… Complete 10+ pages in app/, shadcn/ui components
Plan 2: AI Automation Week 3-4 AI analysis, automation โœ… Complete ai.ts, analyze-batch.ts, GitHub Actions
Plan 3: Scale Month 2 30 companies, 109 earnings โœ… Complete tier2/tier3 scripts, backfill scripts
RAG AI Assistant Week 5-6 Vector search, AI chat โœ… Complete /assistant page, Cohere embeddings, RAG pipeline
Portfolio Optimization Week 6-7 Real-time prices, UI upgrade โœ… Complete 15-min refresh, glassmorphism design
Plan 4: Growth Month 3 SEO, traffic growth ๐Ÿ“‹ Planned -
Plan 5: Commercialization Month 4-6 Monetization ๐Ÿ“‹ Planned -

๐Ÿ’ฐ Cost Analysis (Based on Actual Implementation)

Phase Monthly Cost Main Expense Actual (Based on Code)
MVP ยฅ0 Free tier โœ… ยฅ0 (Vercel, Supabase free)
Automation ยฅ1-2 DeepSeek API โœ… ยฅ0.2-1 (batch processing)
Scale ยฅ10-20 Potential DB upgrade ๐Ÿš€ ยฅ0.2-1 (still on free tiers)

Current Monthly Cost: ~ยฅ0.2-1 (extremely low, all free tiers)

๐Ÿ”‘ Key Architecture Decisions (Visible in Code)

1. Dynamic Routing for Earnings

Changed from: /earnings?symbol=aapl (query params)
Changed to: /earnings/aapl (dynamic route)
Evidence: src/app/earnings/[symbol]/page.tsx exists
Reason: Next.js 15+ params are Promises, simpler to use dynamic segments

2. SVG Icons Instead of Emoji

All emoji replaced with SVG components
Evidence: src/components/icons/index.tsx exists with custom icons
Benefits: Consistent styling, better performance, no platform differences

3. AI Analysis Batch Processing

Approach: Process 5 earnings at a time
Evidence: scripts/analyze-batch.ts with batch logic
Reason: Control API costs, manageable execution time

๐Ÿ“š Documentation (Chinese)

Path Content Status
doc/่ฎกๅˆ’/ Execution plans (Plan 1-5) โœ… Complete
doc/็ญ–็•ฅ/ Strategy documents โœ… Complete
doc/ๆŠ€ๆœฏ/ Technical documentation โœ… Complete
doc/้กน็›ฎ็Šถๆ€ๆŠฅๅ‘Š-20260210.md Current status report โœ… Updated

โš ๏ธ Anti-Patterns (THIS PROJECT)

NEVER Do These

  • โŒ Run create-next-app in root directory (creates duplicate config)
  • โŒ Add API keys to git (use environment variables)
  • โŒ Use as any, @ts-ignore, @ts-expect-error
  • โŒ Add .gitignore rules that overlap with earnlytics-web/.gitignore
  • โŒ Commit .env.local or files containing secrets

ALWAYS Do These

  • โœ… Use SVG icons from src/components/icons/
  • โœ… Follow shadcn/ui patterns for components
  • โœ… Update progress documents when completing tasks
  • โœ… Use dynamic routes for parameterized pages
  • โœ… Test build before committing

๐Ÿ› Known Issues & Solutions (From Code Analysis)

Issue Solution Evidence
useSearchParams returns null Use dynamic route [symbol] instead earnings/[symbol]/page.tsx
params is Promise in Next.js 15 Use React.use() to unwrap earnings/[symbol]/page.tsx
Environment variables in scripts Use dotenv to load .env.local scripts/*.ts with config()
API keys leaked to git 1) Delete file, 2) Rotate keys, 3) Add to .gitignore Already fixed

๐Ÿ“ Notes

  • Project uses DOVE VPN proxy (HTTP 7897) for GitHub access
  • Doc folder uses Chinese naming conventions (่ฎกๅˆ’, ๆŠ€ๆœฏ, ๏ฟฝ๏ฟฝ๏ฟฝ็•ฅ)
  • Root .gitignore is minimal; full rules in earnlytics-web/.gitignore
  • Monthly AI cost: ~ยฅ0.2-1 (extremely low cost, batch processing)
  • All API keys must be rotated if accidentally committed
  • Dynamic routes use [symbol] format, accessed via React.use(params) in Next.js 15
  • 23 data scripts available for various operations

๐ŸŽ‰ Key Achievements

  1. โœ… Complete Frontend: 10+ pages with dynamic routing
  2. โœ… AI Integration: DeepSeek API with batch processing
  3. โœ… RAG AI Assistant: Vector search with Cohere embeddings, multi-turn dialogue
  4. โœ… Data Pipeline: 24 scripts for data fetching, analysis, and embeddings
  5. โœ… Database Schema: Supabase migrations with pgvector support
  6. โœ… UI System: shadcn/ui + custom SVG icons + glassmorphism design
  7. โœ… Automation: GitHub Actions for scheduled tasks
  8. โœ… Scalability: Support for 30 companies across 3 tiers
  9. โœ… Real-time Portfolio: 15-min price refresh with auto-update

Production: https://earnlytics-ebon.vercel.app
GitHub: https://github.com/Timcai06/Earnlytics
Branch: main
Last Updated: 2026-02-27

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors